Teuchos - Trilinos Tools Package Version of the Day
Loading...
Searching...
No Matches
Teuchos_Comm.hpp
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
17namespace Teuchos {
18
38template<class OrdinalType>
40public:
42 virtual ~CommStatus() {}
43
45 virtual OrdinalType getSourceRank () = 0;
46
48 virtual OrdinalType getTag () = 0;
49};
50
51// Forward declaration for CommRequest::wait.
52template<class OrdinalType>
53class Comm;
54
104template<class OrdinalType>
106public:
114 virtual ~CommRequest() {}
115
116 virtual bool isReady() = 0;
117
120};
121
281template<typename Ordinal>
282class Comm : virtual public Describable {
283public:
289 virtual int getTag () const = 0;
290
292
293
295 virtual ~Comm() {}
297
299
300
307 virtual int getRank() const = 0;
308
315 virtual int getSize() const = 0;
316
318
320
321
325 virtual void barrier() const = 0;
326
341 virtual void broadcast(
342 const int rootRank, const Ordinal bytes, char buffer[]
343 ) const = 0;
344
346 virtual void
347 gather (const Ordinal sendBytes, const char sendBuffer[],
348 const Ordinal recvBytes, char recvBuffer[],
349 const int root) const = 0;
350
373 virtual void gatherAll(
374 const Ordinal sendBytes, const char sendBuffer[]
375 ,const Ordinal recvBytes, char recvBuffer[]
376 ) const = 0;
377
391 virtual void reduceAll(
393 ,const Ordinal bytes, const char sendBuffer[], char globalReducts[]
394 ) const = 0;
395
409 virtual void scan(
411 ,const Ordinal bytes, const char sendBuffer[], char scanReducts[]
412 ) const = 0;
413
415
416
437 virtual void send(
438 const Ordinal bytes, const char sendBuffer[], const int destRank
439 ) const = 0;
440
442 virtual void
443 send (const Ordinal bytes,
444 const char sendBuffer[],
445 const int destRank,
446 const int tag) const = 0;
447
467 virtual void ssend(
468 const Ordinal bytes, const char sendBuffer[], const int destRank
469 ) const = 0;
470
472 virtual void
473 ssend (const Ordinal bytes,
474 const char sendBuffer[],
475 const int destRank,
476 const int tag) const = 0;
477
498 virtual int receive(
499 const int sourceRank, const Ordinal bytes, char recvBuffer[]
500 ) const = 0;
501
502
514 virtual void readySend(
516 const int destRank
517 ) const = 0;
518
520 virtual void
521 readySend (const Ordinal bytes,
522 const char sendBuffer[],
523 const int destRank,
524 const int tag) const = 0;
525
527
529
543 const int destRank
544 ) const = 0;
545
549 const int destRank,
550 const int tag) const = 0;
551
568 const int sourceRank
569 ) const = 0;
570
574 const int sourceRank,
575 const int tag) const = 0;
576
587 virtual void waitAll(
589 ) const = 0;
590
607 virtual void
609 const ArrayView<RCP<CommStatus<Ordinal> > >& statuses) const = 0;
610
635 wait (const Ptr<RCP<CommRequest<Ordinal> > >& request) const = 0;
636
638
640
641
709 virtual RCP< Comm > duplicate() const = 0;
710
748 virtual RCP<Comm> split (const int color, const int key) const = 0;
749
772 virtual RCP<Comm>
775
776}; // class Comm
777
778} // namespace Teuchos
779
780#endif // TEUCHOS_COMM_HPP
Nonowning array view.
Encapsulation of a pending nonblocking communication operation.
virtual ~CommRequest()
Destructor; cancels the request if it is still pending.
virtual RCP< CommStatus< OrdinalType > > wait()=0
Wait on this request (a blocking operation).
Encapsulation of the result of a receive (blocking or nonblocking).
virtual OrdinalType getSourceRank()=0
The source rank that sent the message.
virtual ~CommStatus()
Destructor (declared virtual for memory safety)
virtual OrdinalType getTag()=0
The tag of the received message.
Abstract interface for distributed-memory communication.
virtual void broadcast(const int rootRank, const Ordinal bytes, char buffer[]) const =0
Broadcast values from the root process to the slave processes.
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< CommRequest< Ordinal > > ireceive(const ArrayView< char > &recvBuffer, const int sourceRank, const int tag) const =0
Variant of ireceive that takes a tag.
virtual RCP< Comm > split(const int color, const int key) const =0
Split a communicator into subcommunicators based on color and key.
virtual void waitAll(const ArrayView< RCP< CommRequest< Ordinal > > > &requests) const =0
Wait on a set of communication requests.
virtual void readySend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Ready send of data from this process to another process.
virtual RCP< Comm > duplicate() const =0
Duplicate this communicator.
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 ~Comm()
Destructor, declared virtual for safety of derived classes.
virtual int getSize() const =0
Returns the number of processes that make up this communicator.
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 RCP< Comm > createSubcommunicator(const ArrayView< const int > &ranks) const =0
Create a subcommunicator containing the specified processes.
virtual void ssend(const Ordinal bytes, const char sendBuffer[], const int destRank, const int tag) const =0
Variant of ssend() that takes a message tag.
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 RCP< CommStatus< Ordinal > > wait(const Ptr< RCP< CommRequest< Ordinal > > > &request) const =0
Wait on a single communication request, and return its status.
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.
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 ssend(const Ordinal bytes, const char sendBuffer[], const int destRank) const =0
Always blocking send of data from this process to another process.
virtual RCP< CommRequest< Ordinal > > isend(const ArrayView< const char > &sendBuffer, const int destRank, const int tag) const =0
Variant of isend() that takes a tag.
virtual int getRank() const =0
Returns the rank of this process.
virtual void readySend(const Ordinal bytes, const char sendBuffer[], const int destRank, const int tag) const =0
Variant of readySend() that accepts a message tag.
virtual void barrier() const =0
Pause every process in *this communicator until all the processes reach this point.
virtual void waitAll(const ArrayView< RCP< CommRequest< Ordinal > > > &requests, const ArrayView< RCP< CommStatus< Ordinal > > > &statuses) const =0
Wait on communication requests, and return their statuses.
virtual RCP< CommRequest< Ordinal > > isend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Non-blocking send.
virtual void send(const Ordinal bytes, const char sendBuffer[], const int destRank, const int tag) const =0
Variant of send() that takes a tag.
Base class for all objects that can describe themselves.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists.
Smart reference counting pointer class for automatic garbage collection.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...