10 #ifndef TEUCHOS_SERIAL_COMM_HPP
11 #define TEUCHOS_SERIAL_COMM_HPP
25 template<
class OrdinalType>
43 template<
typename Ordinal>
79 const int rootRank,
const Ordinal bytes,
char buffer[]
83 gather (
const Ordinal sendBytes,
const char sendBuffer[],
84 const Ordinal recvBytes,
char recvBuffer[],
85 const int root)
const;
88 const Ordinal sendBytes,
const char sendBuffer[]
89 ,
const Ordinal recvBytes,
char recvBuffer[]
94 ,
const Ordinal bytes,
const char sendBuffer[],
char globalReducts[]
99 ,
const Ordinal bytes,
const char sendBuffer[],
char scanReducts[]
103 const Ordinal bytes,
const char sendBuffer[],
const int destRank
107 send (
const Ordinal bytes,
108 const char sendBuffer[],
110 const int tag)
const;
113 const Ordinal bytes,
const char sendBuffer[],
const int destRank
117 ssend (
const Ordinal bytes,
118 const char sendBuffer[],
120 const int tag)
const;
123 const int sourceRank,
const Ordinal bytes,
char recvBuffer[]
133 const char sendBuffer[],
135 const int tag)
const;
145 const int tag)
const;
154 const int sourceRank,
155 const int tag)
const;
192 template<
typename Ordinal>
206 template<
typename Ordinal>
210 template<
typename Ordinal>
218 template<
typename Ordinal>
225 template<
typename Ordinal>
232 template<
typename Ordinal>
239 template<
typename Ordinal>
241 const int ,
const Ordinal ,
char []
248 template<
typename Ordinal>
250 const Ordinal sendBytes,
const char sendBuffer[]
251 ,
const Ordinal recvBytes,
char recvBuffer[]
261 std::copy(sendBuffer,sendBuffer+sendBytes,recvBuffer);
265 template<
typename Ordinal>
268 const char sendBuffer[],
269 const Ordinal recvBytes,
271 const int root)
const
281 std::copy (sendBuffer, sendBuffer + sendBytes, recvBuffer);
285 template<
typename Ordinal>
288 ,
const Ordinal bytes,
const char sendBuffer[],
char globalReducts[]
292 std::copy(sendBuffer,sendBuffer+bytes,globalReducts);
296 template<
typename Ordinal>
299 ,
const Ordinal bytes,
const char sendBuffer[],
char scanReducts[]
303 std::copy(sendBuffer,sendBuffer+bytes,scanReducts);
307 template<
typename Ordinal>
309 const Ordinal ,
const char [],
const int
313 true, std::logic_error
314 ,
"SerialComm<Ordinal>::send(...): Error, you can not call send(...) when you"
315 " only have one process!"
319 template<
typename Ordinal>
327 true, std::logic_error
328 ,
"SerialComm<Ordinal>::send(...): Error, you can not call send(...) when you"
329 " only have one process!"
333 template<
typename Ordinal>
335 const Ordinal ,
const char [],
const int
339 true, std::logic_error
340 ,
"SerialComm<Ordinal>::send(...): Error, you can not call ssend(...) when you"
341 " only have one process!"
345 template<
typename Ordinal>
353 true, std::logic_error
354 ,
"SerialComm<Ordinal>::send(...): Error, you can not call ssend(...) when you"
355 " only have one process!"
359 template<
typename Ordinal>
361 const int ,
const Ordinal ,
char []
365 true, std::logic_error
366 ,
"SerialComm<Ordinal>::receive(...): Error, you can not call receive(...) when you"
367 " only have one process!"
372 template<
typename Ordinal>
379 true, std::logic_error
380 ,
"SerialComm<Ordinal>::readySend(...): Error, you can not call readySend(...) when you"
381 " only have one process!"
385 template<
typename Ordinal>
388 const char sendBuffer[],
398 true, std::logic_error
399 ,
"SerialComm<Ordinal>::readySend(...): Error, you can not call readySend(...) when you"
400 " only have one process!"
404 template<
typename Ordinal>
410 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::isend: You cannot call isend when you only have one process." );
414 template<
typename Ordinal>
421 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::isend: You cannot call isend when you only have one process." );
425 template<
typename Ordinal>
431 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::ireceive: You cannot call isend when you only have one process." );
435 template<
typename Ordinal>
442 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::ireceive: You cannot call isend when you only have one process." );
446 template<
typename Ordinal>
454 template<
typename Ordinal>
461 std::invalid_argument,
"Teuchos::SerialComm::waitAll: There are not enough "
462 "entries in the statuses array to hold all the results of the communication"
463 " requests. requests.size() = " << requests.size() <<
" > statuses.size() "
464 "= " << statuses.size() <<
".");
467 it != requests.end(); ++it) {
472 template<
typename Ordinal>
478 "Teuchos::SerialComm::wait: On input, the request pointer is null.");
487 template<
typename Ordinal>
494 template<
typename Ordinal>
505 template<
typename Ordinal>
509 if ((ranks.
size()) == 1 && (ranks[0] == 0)) {
519 template<
typename Ordinal>
522 std::ostringstream oss;
531 #endif // TEUCHOS_SERIAL_COMM_HPP
virtual RCP< CommStatus< Ordinal > > wait(const Ptr< RCP< CommRequest< Ordinal > > > &request) const
virtual void barrier() const
int getTag() const
The current tag.
virtual RCP< CommRequest< Ordinal > > isend(const ArrayView< const char > &sendBuffer, const int destRank) const
virtual RCP< CommRequest< Ordinal > > ireceive(const ArrayView< char > &Buffer, const int sourceRank) const
virtual int receive(const int sourceRank, const Ordinal bytes, char recvBuffer[]) const
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
size_type size() const
The total number of items in the managed array.
Concrete serial communicator subclass.
virtual void broadcast(const int rootRank, const Ordinal bytes, char buffer[]) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
virtual void waitAll(const ArrayView< RCP< CommRequest< Ordinal > > > &requests) const
Encapsulation of the result of a receive (blocking or nonblocking).
virtual void scan(const ValueTypeReductionOp< Ordinal, char > &reductOp, const Ordinal bytes, const char sendBuffer[], char scanReducts[]) const
std::string description() const
Implementation of CommStatus for a serial communicator.
OrdinalType getTag()
The tag of the received message.
virtual RCP< Comm< Ordinal > > createSubcommunicator(const ArrayView< const int > &ranks) const
Abstract interface for distributed-memory communication.
virtual void readySend(const ArrayView< const char > &sendBuffer, const int destRank) const
Defines basic traits for the ordinal field type.
virtual RCP< Comm< Ordinal > > split(const int color, const int key) const
virtual void gather(const Ordinal sendBytes, const char sendBuffer[], const Ordinal recvBytes, char recvBuffer[], const int root) const
Gather values from all processes to the root process.
OrdinalType getSourceRank()
The source rank that sent the message (must be zero).
static std::string name()
Returns name of this ordinal type.
virtual void reduceAll(const ValueTypeReductionOp< Ordinal, char > &reductOp, const Ordinal bytes, const char sendBuffer[], char globalReducts[]) const
Smart reference counting pointer class for automatic garbage collection.
virtual void gatherAll(const Ordinal sendBytes, const char sendBuffer[], const Ordinal recvBytes, char recvBuffer[]) const
Encapsulation of a pending nonblocking communication operation.
SerialCommStatus()
Default constructor.
virtual RCP< Comm< Ordinal > > duplicate() const
virtual int getRank() const
virtual void ssend(const Ordinal bytes, const char sendBuffer[], const int destRank) const
int incrementTag()
Increments the tag and then returns it.
RCP< SerialComm< Ordinal > > createSerialComm()
Nonmember constructor.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call...
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
virtual void send(const Ordinal bytes, const char sendBuffer[], const int destRank) const
virtual int getSize() const