Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_Comm.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_COMM_HPP
11 #define TEUCHOS_COMM_HPP
12 
13 #include "Teuchos_ReductionOp.hpp"
14 #include "Teuchos_ArrayRCP.hpp"
15 
16 
17 namespace Teuchos {
18 
38 template<class OrdinalType>
39 class CommStatus {
40 public:
42  virtual ~CommStatus() {}
43 
45  virtual OrdinalType getSourceRank () = 0;
46 
48  virtual OrdinalType getTag () = 0;
49 };
50 
51 // Forward declaration for CommRequest::wait.
52 template<class OrdinalType>
53 class Comm;
54 
104 template<class OrdinalType>
106 public:
114  virtual ~CommRequest() {}
115 
116  virtual bool isReady() = 0;
117 
119  virtual RCP<CommStatus<OrdinalType> > wait () = 0;
120 };
121 
281 template<typename Ordinal>
282 class Comm : virtual public Describable {
283 public:
289  virtual int getTag () const = 0;
290 
292  virtual int incrementTag() = 0;
293 
295 
296 
298  virtual ~Comm() {}
300 
302 
303 
310  virtual int getRank() const = 0;
311 
318  virtual int getSize() const = 0;
319 
321 
323 
324 
328  virtual void barrier() const = 0;
329 
344  virtual void broadcast(
345  const int rootRank, const Ordinal bytes, char buffer[]
346  ) const = 0;
347 
349  virtual void
350  gather (const Ordinal sendBytes, const char sendBuffer[],
351  const Ordinal recvBytes, char recvBuffer[],
352  const int root) const = 0;
353 
376  virtual void gatherAll(
377  const Ordinal sendBytes, const char sendBuffer[]
378  ,const Ordinal recvBytes, char recvBuffer[]
379  ) const = 0;
380 
394  virtual void reduceAll(
395  const ValueTypeReductionOp<Ordinal,char> &reductOp
396  ,const Ordinal bytes, const char sendBuffer[], char globalReducts[]
397  ) const = 0;
398 
412  virtual void scan(
413  const ValueTypeReductionOp<Ordinal,char> &reductOp
414  ,const Ordinal bytes, const char sendBuffer[], char scanReducts[]
415  ) const = 0;
416 
418 
419 
440  virtual void send(
441  const Ordinal bytes, const char sendBuffer[], const int destRank
442  ) const = 0;
443 
445  virtual void
446  send (const Ordinal bytes,
447  const char sendBuffer[],
448  const int destRank,
449  const int tag) const = 0;
450 
470  virtual void ssend(
471  const Ordinal bytes, const char sendBuffer[], const int destRank
472  ) const = 0;
473 
475  virtual void
476  ssend (const Ordinal bytes,
477  const char sendBuffer[],
478  const int destRank,
479  const int tag) const = 0;
480 
501  virtual int receive(
502  const int sourceRank, const Ordinal bytes, char recvBuffer[]
503  ) const = 0;
504 
505 
517  virtual void readySend(
518  const ArrayView<const char> &sendBuffer,
519  const int destRank
520  ) const = 0;
521 
523  virtual void
524  readySend (const Ordinal bytes,
525  const char sendBuffer[],
526  const int destRank,
527  const int tag) const = 0;
528 
530 
532 
545  const ArrayView<const char> &sendBuffer,
546  const int destRank
547  ) const = 0;
548 
550  virtual RCP<CommRequest<Ordinal> >
551  isend (const ArrayView<const char> &sendBuffer,
552  const int destRank,
553  const int tag) const = 0;
554 
570  const ArrayView<char> &recvBuffer,
571  const int sourceRank
572  ) const = 0;
573 
575  virtual RCP<CommRequest<Ordinal> >
576  ireceive (const ArrayView<char> &recvBuffer,
577  const int sourceRank,
578  const int tag) const = 0;
579 
590  virtual void waitAll(
591  const ArrayView<RCP<CommRequest<Ordinal> > > &requests
592  ) const = 0;
593 
610  virtual void
611  waitAll (const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
612  const ArrayView<RCP<CommStatus<Ordinal> > >& statuses) const = 0;
613 
637  virtual RCP<CommStatus<Ordinal> >
638  wait (const Ptr<RCP<CommRequest<Ordinal> > >& request) const = 0;
639 
641 
643 
644 
712  virtual RCP< Comm > duplicate() const = 0;
713 
751  virtual RCP<Comm> split (const int color, const int key) const = 0;
752 
775  virtual RCP<Comm>
776  createSubcommunicator (const ArrayView<const int>& ranks) const = 0;
778 
779 }; // class Comm
780 
781 } // namespace Teuchos
782 
783 #endif // TEUCHOS_COMM_HPP
virtual bool isReady()=0
virtual void waitAll(const ArrayView< RCP< CommRequest< Ordinal > > > &requests) const =0
Wait on a set of communication requests.
virtual void gatherAll(const Ordinal sendBytes, const char sendBuffer[], const Ordinal recvBytes, char recvBuffer[]) const =0
Gather values from each process to collect on all processes.
virtual int getSize() const =0
Returns the number of processes that make up this communicator.
virtual int getRank() const =0
Returns the rank of this process.
virtual ~CommRequest()
Destructor; cancels the request if it is still pending.
virtual RCP< Comm > createSubcommunicator(const ArrayView< const int > &ranks) const =0
Create a subcommunicator containing the specified processes.
virtual RCP< Comm > split(const int color, const int key) const =0
Split a communicator into subcommunicators based on color and key.
virtual RCP< CommStatus< Ordinal > > wait(const Ptr< RCP< CommRequest< Ordinal > > > &request) const =0
Wait on a single communication request, and return its status.
virtual int receive(const int sourceRank, const Ordinal bytes, char recvBuffer[]) const =0
Blocking receive of data from this process to another process.
virtual void barrier() const =0
Pause every process in *this communicator until all the processes reach this point.
virtual ~Comm()
Destructor, declared virtual for safety of derived classes.
virtual RCP< CommRequest< Ordinal > > ireceive(const ArrayView< char > &recvBuffer, const int sourceRank) const =0
Non-blocking receive.
virtual void reduceAll(const ValueTypeReductionOp< Ordinal, char > &reductOp, const Ordinal bytes, const char sendBuffer[], char globalReducts[]) const =0
Global reduction.
virtual void gather(const Ordinal sendBytes, const char sendBuffer[], const Ordinal recvBytes, char recvBuffer[], const int root) const =0
Gather values from all processes to the root process.
virtual RCP< Comm > duplicate() const =0
Duplicate this communicator.
Encapsulation of the result of a receive (blocking or nonblocking).
virtual void readySend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Ready send of data from this process to another process.
virtual ~CommStatus()
Destructor (declared virtual for memory safety)
virtual void broadcast(const int rootRank, const Ordinal bytes, char buffer[]) const =0
Broadcast values from the root process to the slave processes.
Abstract interface for distributed-memory communication.
Nonowning array view.
virtual OrdinalType getTag()=0
The tag of the received message.
virtual void send(const Ordinal bytes, const char sendBuffer[], const int destRank) const =0
Possibly blocking send of data from this process to another process.
virtual void ssend(const Ordinal bytes, const char sendBuffer[], const int destRank) const =0
Always blocking send of data from this process to another process.
virtual int incrementTag()=0
Increments the tag and then returns it.
Base class for all objects that can describe themselves.
virtual OrdinalType getSourceRank()=0
The source rank that sent the message.
Smart reference counting pointer class for automatic garbage collection.
Encapsulation of a pending nonblocking communication operation.
virtual RCP< CommRequest< Ordinal > > isend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Non-blocking send.
virtual void scan(const ValueTypeReductionOp< Ordinal, char > &reductOp, const Ordinal bytes, const char sendBuffer[], char scanReducts[]) const =0
Scan reduction.
virtual int getTag() const =0
The current tag.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
virtual RCP< CommStatus< OrdinalType > > wait()=0
Wait on this request (a blocking operation).