42 #ifndef TEUCHOS_SERIAL_COMM_HPP 43 #define TEUCHOS_SERIAL_COMM_HPP 45 #include "Teuchos_Comm.hpp" 57 template<
class OrdinalType>
75 template<
typename Ordinal>
100 virtual int getRank()
const;
102 virtual int getSize()
const;
104 virtual void barrier()
const;
106 virtual void broadcast(
107 const int rootRank,
const Ordinal bytes,
char buffer[]
111 gather (
const Ordinal sendBytes,
const char sendBuffer[],
112 const Ordinal recvBytes,
char recvBuffer[],
113 const int root)
const;
115 virtual void gatherAll(
116 const Ordinal sendBytes,
const char sendBuffer[]
117 ,
const Ordinal recvBytes,
char recvBuffer[]
122 ,
const Ordinal bytes,
const char sendBuffer[],
char globalReducts[]
125 TEUCHOS_DEPRECATED
virtual void reduceAllAndScatter(
127 ,
const Ordinal sendBytes,
const char sendBuffer[]
128 ,
const Ordinal recvCounts[],
char myGlobalReducts[]
133 ,
const Ordinal bytes,
const char sendBuffer[],
char scanReducts[]
137 const Ordinal bytes,
const char sendBuffer[],
const int destRank
141 send (
const Ordinal bytes,
142 const char sendBuffer[],
144 const int tag)
const;
147 const Ordinal bytes,
const char sendBuffer[],
const int destRank
151 ssend (
const Ordinal bytes,
152 const char sendBuffer[],
154 const int tag)
const;
157 const int sourceRank,
const Ordinal bytes,
char recvBuffer[]
167 const char sendBuffer[],
169 const int tag)
const;
179 const int tag)
const;
188 const int sourceRank,
189 const int tag)
const;
191 virtual void waitAll(
215 std::string description()
const;
226 template<
typename Ordinal>
240 template<
typename Ordinal>
244 template<
typename Ordinal>
252 template<
typename Ordinal>
259 template<
typename Ordinal>
266 template<
typename Ordinal>
273 template<
typename Ordinal>
275 const int ,
const Ordinal ,
char []
282 template<
typename Ordinal>
284 const Ordinal sendBytes,
const char sendBuffer[]
285 ,
const Ordinal recvBytes,
char recvBuffer[]
295 std::copy(sendBuffer,sendBuffer+sendBytes,recvBuffer);
299 template<
typename Ordinal>
302 const char sendBuffer[],
303 const Ordinal recvBytes,
305 const int root)
const 315 std::copy (sendBuffer, sendBuffer + sendBytes, recvBuffer);
319 template<
typename Ordinal>
322 ,
const Ordinal bytes,
const char sendBuffer[],
char globalReducts[]
326 std::copy(sendBuffer,sendBuffer+bytes,globalReducts);
330 template<
typename Ordinal>
334 ,
const Ordinal sendBytes,
const char sendBuffer[]
335 ,
const Ordinal recvCounts[],
char myGlobalReducts[]
343 (void)myGlobalReducts;
348 std::copy(sendBuffer,sendBuffer+sendBytes,myGlobalReducts);
352 template<
typename Ordinal>
355 ,
const Ordinal bytes,
const char sendBuffer[],
char scanReducts[]
359 std::copy(sendBuffer,sendBuffer+bytes,scanReducts);
363 template<
typename Ordinal>
365 const Ordinal ,
const char [],
const int 369 true, std::logic_error
370 ,
"SerialComm<Ordinal>::send(...): Error, you can not call send(...) when you" 371 " only have one process!" 375 template<
typename Ordinal>
383 true, std::logic_error
384 ,
"SerialComm<Ordinal>::send(...): Error, you can not call send(...) when you" 385 " only have one process!" 389 template<
typename Ordinal>
391 const Ordinal ,
const char [],
const int 395 true, std::logic_error
396 ,
"SerialComm<Ordinal>::send(...): Error, you can not call ssend(...) when you" 397 " only have one process!" 401 template<
typename Ordinal>
404 const char sendBuffer[],
409 true, std::logic_error
410 ,
"SerialComm<Ordinal>::send(...): Error, you can not call ssend(...) when you" 411 " only have one process!" 415 template<
typename Ordinal>
417 const int ,
const Ordinal ,
char []
421 true, std::logic_error
422 ,
"SerialComm<Ordinal>::receive(...): Error, you can not call receive(...) when you" 423 " only have one process!" 428 template<
typename Ordinal>
435 true, std::logic_error
436 ,
"SerialComm<Ordinal>::readySend(...): Error, you can not call readySend(...) when you" 437 " only have one process!" 441 template<
typename Ordinal>
444 const char sendBuffer[],
454 true, std::logic_error
455 ,
"SerialComm<Ordinal>::readySend(...): Error, you can not call readySend(...) when you" 456 " only have one process!" 460 template<
typename Ordinal>
466 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::isend: You cannot call isend when you only have one process." );
470 template<
typename Ordinal>
477 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::isend: You cannot call isend when you only have one process." );
481 template<
typename Ordinal>
487 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::ireceive: You cannot call isend when you only have one process." );
491 template<
typename Ordinal>
498 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
"SerialComm<Ordinal>::ireceive: You cannot call isend when you only have one process." );
502 template<
typename Ordinal>
510 template<
typename Ordinal>
517 std::invalid_argument,
"Teuchos::SerialComm::waitAll: There are not enough " 518 "entries in the statuses array to hold all the results of the communication" 519 " requests. requests.size() = " << requests.size() <<
" > statuses.size() " 520 "= " << statuses.size() <<
".");
523 it != requests.end(); ++it) {
528 template<
typename Ordinal>
534 "Teuchos::SerialComm::wait: On input, the request pointer is null.");
543 template<
typename Ordinal>
550 template<
typename Ordinal>
561 template<
typename Ordinal>
565 if ((ranks.
size()) == 1 && (ranks[0] == 0)) {
575 template<
typename Ordinal>
578 std::ostringstream oss;
587 #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
TEUCHOS_DEPRECATED void scan(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *scanReduct)
Deprecated.
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
Deprecated .
Encapsulation of the result of a receive (blocking or nonblocking).
void send(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of send() that takes a tag (and restores the correct order of arguments). ...
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.
RCP< CommRequest< Ordinal > > ireceive(const ArrayRCP< Packet > &recvBuffer, const int sourceRank, const int tag, const Comm< Ordinal > &comm)
Variant of ireceive that takes a tag argument (and restores the correct order of arguments).
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.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
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).
void ssend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of ssend() that takes a tag (and restores the correct order of arguments).
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 TEUCHOS_DEPRECATED void reduceAllAndScatter(const ValueTypeReductionOp< Ordinal, char > &reductOp, const Ordinal sendBytes, const char sendBuffer[], const Ordinal recvCounts[], char myGlobalReducts[]) const
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
void readySend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of readySend() that accepts a message tag.
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