The DataCommunicator class provides the infrastructure needed to exchange data among processes. More...
Public Member Functions | |
DataCommunicator (MPI_Comm communicator) | |
~DataCommunicator () | |
bool | areRecvsContinuous () |
void | cancelAllRecvs (bool synchronous=false) |
void | cancelAllSends (bool synchronous=false) |
void | cancelRecv (int rank) |
void | cancelSend (int rank) |
void | clearAllRecvs (bool synchronous=false) |
void | clearAllSends (bool synchronous=false) |
void | clearRecv (int rank) |
void | clearSend (int rank) |
void | discoverRecvs () |
void | discoverSends () |
void | finalize (bool synchronous=false) |
const MPI_Comm & | getCommunicator () const |
int | getDiscoverTag () const |
int | getExchangeTag () const |
int | getNotificationTag () const |
int | getProcessorCount () const |
int | getRank () const |
RecvBuffer & | getRecvBuffer (int rank) |
int | getRecvCount () |
const std::vector< int > & | getRecvRanks () const |
SendBuffer & | getSendBuffer (int rank) |
int | getSendCount () |
const std::vector< int > & | getSendRanks () const |
int | getTag () const |
bool | isRecvActive (int rank) |
bool | isSendActive (int rank) |
void | resizeRecv (int rank, long resize) |
void | resizeSend (int rank, long resize) |
void | setDiscoverTag (int tag) |
void | setExchangeTag (int tag) |
void | setNotificationTag (int tag) |
void | setRecv (int rank, long length=0) |
void | setRecvsContinuous (bool enabled) |
void | setSend (int rank, long length=0) |
void | setTag (int exchangeTag) |
void | setTags (int exchangeTag, int discoverTag, int notificationTag) |
void | startAllRecvs () |
void | startAllSends () |
void | startRecv (int srcRank) |
void | startSend (int dstRank) |
void | waitAllRecvs () |
void | waitAllSends () |
int | waitAnyRecv (const std::vector< int > &blackList=std::vector< int >()) |
int | waitAnySend (const std::vector< int > &blackList=std::vector< int >()) |
void | waitRecv (int rank) |
void | waitSend (int rank) |
Static Public Attributes | |
static BITPIT_PUBLIC_API const int | TAG_AUTO = -1 |
The DataCommunicator class provides the infrastructure needed to exchange data among processes.
Definition at line 41 of file communications.hpp.
bitpit::DataCommunicator::DataCommunicator | ( | MPI_Comm | communicator | ) |
Creates a new communicator for data exchange.
Definition at line 45 of file communications.cpp.
bitpit::DataCommunicator::~DataCommunicator | ( | ) |
Destructor.
Definition at line 59 of file communications.cpp.
bool bitpit::DataCommunicator::areRecvsContinuous | ( | ) |
Checks if the recevies are in "continuous" mode.
Definition at line 293 of file communications.cpp.
void bitpit::DataCommunicator::cancelAllRecvs | ( | bool | synchronous = false | ) |
Cancels all the receives.
synchronous | if this parameter is set to true, the function will cancel the receive requests of the current rank and than will wait until all remote processes that receives data from the current rank cancel their receive requests. This guarantees that, at the end of the function, both the current rank and all remote processes involved in a data exchange with it have canceled their receive requests. When synchronous mode is enabled send and receive requests have to match among all the processes. |
Definition at line 1171 of file communications.cpp.
void bitpit::DataCommunicator::cancelAllSends | ( | bool | synchronous = false | ) |
Cancels all the sends.
synchronous | if this parameter is set to true, the function will cancel the send requests of the current rank and than will wait until all remote processes that sends data to the current rank cancel their send requests. This guarantees that, at the end of the function, both the current rank and all remote processes involved in a data exchange with it have canceled their send requests. When synchronous mode is enabled send and receive requests have to match among all the processes. |
Definition at line 1066 of file communications.cpp.
void bitpit::DataCommunicator::cancelRecv | ( | int | rank | ) |
Cancels the receive associated to the specified rank.
rank | is the rank associated to the receive to cancel |
Definition at line 1040 of file communications.cpp.
void bitpit::DataCommunicator::cancelSend | ( | int | rank | ) |
Cancels the send associated to the specified rank.
rank | is the rank associated to the send to cancel |
Definition at line 1020 of file communications.cpp.
void bitpit::DataCommunicator::clearAllRecvs | ( | bool | synchronous = false | ) |
Clear all the receives.
synchronous | if this parameter is set to true, the function will cancel the receive requests of the current rank and than will wait until all remote processes that receives data from the current rank cancel their receive requests as well. This guarantees that, at the end of the function, both the current rank and all remote processes involved in a data exchange with it have canceled their receive requests. |
Definition at line 544 of file communications.cpp.
void bitpit::DataCommunicator::clearAllSends | ( | bool | synchronous = false | ) |
Clear all the sends.
synchronous | if this parameter is set to true, the function will cancel the send requests of the current rank and than will wait until all remote processes that sends data to the current rank cancel their send requests as well. This guarantees that, at the end of the function, both the current rank and the remote processes involved in a data exchange with the current rank have canceled their send requests. |
Definition at line 522 of file communications.cpp.
void bitpit::DataCommunicator::clearRecv | ( | int | rank | ) |
Clear the receive associated to the specified process.
rank | is the ranks associated to the receive that will be cleared |
Definition at line 489 of file communications.cpp.
void bitpit::DataCommunicator::clearSend | ( | int | rank | ) |
Clear the send associated to the specified process.
rank | is the ranks associated to the send that will be cleared |
Definition at line 461 of file communications.cpp.
void bitpit::DataCommunicator::discoverRecvs | ( | ) |
Discover the receives inspecting the sends that the user has already set.
This function implements the "Nonblocking Consensus" algorithm proposed in "Scalable Communication Protocols for Dynamic Sparse Data Exchange", Torsten Hoefler, Christian Siebert and Andrew Lumsdaine, Proceedings of the 2010 ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP'10), presented in Bangalore, India, pages 159–168, ACM, ISBN: 978-1-60558-708-0, Jan. 2010.
Definition at line 387 of file communications.cpp.
void bitpit::DataCommunicator::discoverSends | ( | ) |
Discover the sends inspecting the receives that the user has already set.
This function implements the "Nonblocking Consensus" algorithm proposed in "Scalable Communication Protocols for Dynamic Sparse Data Exchange", Torsten Hoefler, Christian Siebert and Andrew Lumsdaine, Proceedings of the 2010 ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP'10), presented in Bangalore, India, pages 159–168, ACM, ISBN: 978-1-60558-708-0, Jan. 2010.
Definition at line 308 of file communications.cpp.
void bitpit::DataCommunicator::finalize | ( | bool | synchronous = false | ) |
Finalizes the communicator
synchronous | if this parameter is set to true, the function will cancel all requests of the current rank and than will wait until all remote processes that exchange data with the current rank cancel their requests as well. This guarantees that, at the end of the function, both the current rank and the remote processes involved in a data exchange with the current rank have canceled their requests. |
Definition at line 124 of file communications.cpp.
const MPI_Comm & bitpit::DataCommunicator::getCommunicator | ( | ) | const |
Gets the MPI communicator
Definition at line 109 of file communications.cpp.
int bitpit::DataCommunicator::getDiscoverTag | ( | ) | const |
Gets the tag to be used for data size discover communications
Definition at line 242 of file communications.cpp.
int bitpit::DataCommunicator::getExchangeTag | ( | ) | const |
Gets the tag to be used for data exchange communications
Definition at line 232 of file communications.cpp.
int bitpit::DataCommunicator::getNotificationTag | ( | ) | const |
Gets the tag to be used for notifications
Definition at line 252 of file communications.cpp.
int bitpit::DataCommunicator::getProcessorCount | ( | ) | const |
Gets the number of processes in the MPI communicator
Definition at line 96 of file communications.cpp.
int bitpit::DataCommunicator::getRank | ( | ) | const |
Gets the rank in the MPI communicator
Definition at line 83 of file communications.cpp.
RecvBuffer & bitpit::DataCommunicator::getRecvBuffer | ( | int | rank | ) |
Gets the receive buffer associated with the specified rank
rank | is the rank for which the buffer is requested |
Definition at line 709 of file communications.cpp.
int bitpit::DataCommunicator::getRecvCount | ( | ) |
Counts the number of receives that will be performed.
Definition at line 662 of file communications.cpp.
const std::vector< int > & bitpit::DataCommunicator::getRecvRanks | ( | ) | const |
Get a constant reference to the list of ranks for which a receive has been set.
Definition at line 685 of file communications.cpp.
SendBuffer & bitpit::DataCommunicator::getSendBuffer | ( | int | rank | ) |
Gets the send buffer associated with the requested rank
rank | is the rank for which the buffer is requested |
Definition at line 696 of file communications.cpp.
int bitpit::DataCommunicator::getSendCount | ( | ) |
Counts the number of sends that will be performed.
Definition at line 652 of file communications.cpp.
const std::vector< int > & bitpit::DataCommunicator::getSendRanks | ( | ) | const |
Get a constant reference to the list of ranks for which a send has been set.
Definition at line 673 of file communications.cpp.
int bitpit::DataCommunicator::getTag | ( | ) | const |
Gets the tag to be used for data exchange communications
Definition at line 222 of file communications.cpp.
bool bitpit::DataCommunicator::isRecvActive | ( | int | rank | ) |
Checkis if the receive associated to the sepcified rank is active.
A receive is considered active if the associated request is not set to 'MPI_REQUEST_NULL'.
rank | is the rank associated to the receive |
Definition at line 1008 of file communications.cpp.
bool bitpit::DataCommunicator::isSendActive | ( | int | rank | ) |
Checkis if the send associated to the sepcified rank is active.
A send is considered active if the associated request is not set to 'MPI_REQUEST_NULL'.
rank | is the rank associated to the send |
Definition at line 993 of file communications.cpp.
void bitpit::DataCommunicator::resizeRecv | ( | int | rank, |
long | size ) |
Resize the receive associated to the specified rank
rank | is the rank of the process associated to the receive |
size | is the size, expressed in bytes, of the receive |
Definition at line 630 of file communications.cpp.
void bitpit::DataCommunicator::resizeSend | ( | int | rank, |
long | size ) |
Resize the send associated to the specified rank
rank | is the rank of the process associated to the send |
size | is the size, expressed in bytes, of the send |
Definition at line 607 of file communications.cpp.
void bitpit::DataCommunicator::setDiscoverTag | ( | int | tag | ) |
Sets the tag to be used for data size discover
By default, a unique tag is generated in the constructor. However, using this function, it is possible to assign a custom tag.
tag | is the custom tag to be used for data size discover |
Definition at line 189 of file communications.cpp.
void bitpit::DataCommunicator::setExchangeTag | ( | int | tag | ) |
Sets the tag to be used for data exchange
By default, a unique tag is generated in the constructor. However, using this function, it is possible to assign a custom tag.
tag | is the custom tag to be used for data exchange |
Definition at line 171 of file communications.cpp.
void bitpit::DataCommunicator::setNotificationTag | ( | int | tag | ) |
Sets the tag to be used for notifications
By default, a unique tag is generated in the constructor. However, using this function, it is possible to assign a custom tag.
tag | is the custom tag to be used for notifications |
Definition at line 207 of file communications.cpp.
void bitpit::DataCommunicator::setRecv | ( | int | rank, |
long | length = 0 ) |
Set recevie information for the specified rank
rank | is the rank of the process associated to the receive |
length | is the length, expressed in bytes, of the data to be received |
Definition at line 582 of file communications.cpp.
void bitpit::DataCommunicator::setRecvsContinuous | ( | bool | enabled | ) |
Set the recevies in "continuous" mode.
When the recives are in "continuous" mode they will be restarted as soon as they end. In this way there is always a buffer ready for receiveing data.
Calling this function will cancels all current receives.
enabled | if set to true enables the "continuous" mode. |
Definition at line 268 of file communications.cpp.
void bitpit::DataCommunicator::setSend | ( | int | rank, |
long | length = 0 ) |
Set send information for the specified rank
rank | is the rank of the process associated to the send |
length | is the length, expressed in bytes, of the data to be sent |
Definition at line 562 of file communications.cpp.
void bitpit::DataCommunicator::setTag | ( | int | exchangeTag | ) |
Sets the tag to be used for the data exchange.
By default, a unique tag for data exchange is generated in the constructor. However, using this function, it is possible to assign a custom tag.
exchangeTag | is the custom tag to be used for data exchange |
Definition at line 141 of file communications.cpp.
void bitpit::DataCommunicator::setTags | ( | int | exchangeTag, |
int | discoverTag, | ||
int | notificationTag ) |
Sets the tags to be used for the communications.
By default, unique tags are generated in the constructor. However, using this function, it is possible to assign custom tags.
exchangeTag | is the custom tag to be used for data exchange |
discoverTag | is the custom tag to be used for data size discover |
notificationTag | is the custom tag to be used for notifications |
Definition at line 156 of file communications.cpp.
void bitpit::DataCommunicator::startAllRecvs | ( | ) |
Starts receiving the data from all the ranks
Definition at line 784 of file communications.cpp.
void bitpit::DataCommunicator::startAllSends | ( | ) |
Starts sending the data to all the ranks
Definition at line 740 of file communications.cpp.
void bitpit::DataCommunicator::startRecv | ( | int | srcRank | ) |
Starts receiving the data from the specified rank
srcRank | is the source rank |
Definition at line 772 of file communications.cpp.
void bitpit::DataCommunicator::startSend | ( | int | dstRank | ) |
Starts sending the data to the specified rank
dstRank | is the destination rank |
Definition at line 721 of file communications.cpp.
void bitpit::DataCommunicator::waitAllRecvs | ( | ) |
Waits for all the receives to complete.
Definition at line 961 of file communications.cpp.
void bitpit::DataCommunicator::waitAllSends | ( | ) |
Waits for all the sends to complete.
Definition at line 869 of file communications.cpp.
int bitpit::DataCommunicator::waitAnyRecv | ( | const std::vector< int > & | blackList = std::vector<int>() | ) |
Waits for any receive to completes and returns the associated rank.
If there are no active recevies, the call returns MPI_UNDEFINED.
blackList | is a list of ranks whose recevies don't have to be waited for |
Definition at line 894 of file communications.cpp.
int bitpit::DataCommunicator::waitAnySend | ( | const std::vector< int > & | blackList = std::vector<int>() | ) |
Waits for any send to completes and returns the associated rank.
If there are no active sends, the call returns MPI_UNDEFINED.
blackList | is a list of ranks whose sends don't have to be waited for |
Definition at line 821 of file communications.cpp.
void bitpit::DataCommunicator::waitRecv | ( | int | rank | ) |
Waits for the receive associate to the sepcified rank to complete.
rank | is the rank associated to the receive to wait for |
Definition at line 935 of file communications.cpp.
void bitpit::DataCommunicator::waitSend | ( | int | rank | ) |
Waits for the send associate to the sepcified rank to complete.
rank | is the rank associated to the send to wait for |
Definition at line 851 of file communications.cpp.
|
static |
Definition at line 45 of file communications.hpp.