Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
bitpit::DataCommunicator Class Reference

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
 
RecvBuffergetRecvBuffer (int rank)
 
int getRecvCount ()
 
const std::vector< int > & getRecvRanks () const
 
SendBuffergetSendBuffer (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
 

Detailed Description

The DataCommunicator class provides the infrastructure needed to exchange data among processes.

Definition at line 41 of file communications.hpp.

Constructor & Destructor Documentation

◆ DataCommunicator()

bitpit::DataCommunicator::DataCommunicator ( MPI_Comm communicator)

Creates a new communicator for data exchange.

Definition at line 45 of file communications.cpp.

◆ ~DataCommunicator()

bitpit::DataCommunicator::~DataCommunicator ( )

Destructor.

Definition at line 59 of file communications.cpp.

Member Function Documentation

◆ areRecvsContinuous()

bool bitpit::DataCommunicator::areRecvsContinuous ( )

Checks if the recevies are in "continuous" mode.

Returns
Returns true if the receives are in "continuous" mode, false otherwise.

Definition at line 293 of file communications.cpp.

◆ cancelAllRecvs()

void bitpit::DataCommunicator::cancelAllRecvs ( bool synchronous = false)

Cancels all the receives.

Parameters
synchronousif 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.

◆ cancelAllSends()

void bitpit::DataCommunicator::cancelAllSends ( bool synchronous = false)

Cancels all the sends.

Parameters
synchronousif 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.

◆ cancelRecv()

void bitpit::DataCommunicator::cancelRecv ( int rank)

Cancels the receive associated to the specified rank.

Parameters
rankis the rank associated to the receive to cancel

Definition at line 1040 of file communications.cpp.

◆ cancelSend()

void bitpit::DataCommunicator::cancelSend ( int rank)

Cancels the send associated to the specified rank.

Parameters
rankis the rank associated to the send to cancel

Definition at line 1020 of file communications.cpp.

◆ clearAllRecvs()

void bitpit::DataCommunicator::clearAllRecvs ( bool synchronous = false)

Clear all the receives.

Parameters
synchronousif 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.

◆ clearAllSends()

void bitpit::DataCommunicator::clearAllSends ( bool synchronous = false)

Clear all the sends.

Parameters
synchronousif 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.

◆ clearRecv()

void bitpit::DataCommunicator::clearRecv ( int rank)

Clear the receive associated to the specified process.

Parameters
rankis the ranks associated to the receive that will be cleared

Definition at line 489 of file communications.cpp.

◆ clearSend()

void bitpit::DataCommunicator::clearSend ( int rank)

Clear the send associated to the specified process.

Parameters
rankis the ranks associated to the send that will be cleared

Definition at line 461 of file communications.cpp.

◆ discoverRecvs()

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.

◆ discoverSends()

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.

◆ finalize()

void bitpit::DataCommunicator::finalize ( bool synchronous = false)

Finalizes the communicator

Parameters
synchronousif 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.

◆ getCommunicator()

const MPI_Comm & bitpit::DataCommunicator::getCommunicator ( ) const

Gets the MPI communicator

Returns
The MPI communicator.

Definition at line 109 of file communications.cpp.

◆ getDiscoverTag()

int bitpit::DataCommunicator::getDiscoverTag ( ) const

Gets the tag to be used for data size discover communications

Returns
The tag to be used for data size discover communications.

Definition at line 242 of file communications.cpp.

◆ getExchangeTag()

int bitpit::DataCommunicator::getExchangeTag ( ) const

Gets the tag to be used for data exchange communications

Returns
The tag to be used for data exchange communications.

Definition at line 232 of file communications.cpp.

◆ getNotificationTag()

int bitpit::DataCommunicator::getNotificationTag ( ) const

Gets the tag to be used for notifications

Returns
The tag to be used for notifications.

Definition at line 252 of file communications.cpp.

◆ getProcessorCount()

int bitpit::DataCommunicator::getProcessorCount ( ) const

Gets the number of processes in the MPI communicator

Returns
The number of processes in the MPI communicator.

Definition at line 96 of file communications.cpp.

◆ getRank()

int bitpit::DataCommunicator::getRank ( ) const

Gets the rank in the MPI communicator

Returns
the MPI rank.

Definition at line 83 of file communications.cpp.

◆ getRecvBuffer()

RecvBuffer & bitpit::DataCommunicator::getRecvBuffer ( int rank)

Gets the receive buffer associated with the specified rank

Parameters
rankis the rank for which the buffer is requested
Returns
The receive buffer associated with the specified rank.

Definition at line 709 of file communications.cpp.

◆ getRecvCount()

int bitpit::DataCommunicator::getRecvCount ( )

Counts the number of receives that will be performed.

Returns
The number of receives that will be performed.

Definition at line 662 of file communications.cpp.

◆ getRecvRanks()

const std::vector< int > & bitpit::DataCommunicator::getRecvRanks ( ) const

Get a constant reference to the list of ranks for which a receive has been set.

Returns
A constant reference to the list of ranks for with a receive has been set.

Definition at line 685 of file communications.cpp.

◆ getSendBuffer()

SendBuffer & bitpit::DataCommunicator::getSendBuffer ( int rank)

Gets the send buffer associated with the requested rank

Parameters
rankis the rank for which the buffer is requested
Returns
The send buffer associated with the requested rank.

Definition at line 696 of file communications.cpp.

◆ getSendCount()

int bitpit::DataCommunicator::getSendCount ( )

Counts the number of sends that will be performed.

Returns
The number of sends that will be performed.

Definition at line 652 of file communications.cpp.

◆ getSendRanks()

const std::vector< int > & bitpit::DataCommunicator::getSendRanks ( ) const

Get a constant reference to the list of ranks for which a send has been set.

Returns
A constant reference to the list of ranks for with a send has been set.

Definition at line 673 of file communications.cpp.

◆ getTag()

int bitpit::DataCommunicator::getTag ( ) const

Gets the tag to be used for data exchange communications

Returns
The tag to be used for data exchange communications.

Definition at line 222 of file communications.cpp.

◆ isRecvActive()

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'.

Parameters
rankis the rank associated to the receive

Definition at line 1008 of file communications.cpp.

◆ isSendActive()

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'.

Parameters
rankis the rank associated to the send

Definition at line 993 of file communications.cpp.

◆ resizeRecv()

void bitpit::DataCommunicator::resizeRecv ( int rank,
long size )

Resize the receive associated to the specified rank

Parameters
rankis the rank of the process associated to the receive
sizeis the size, expressed in bytes, of the receive

Definition at line 630 of file communications.cpp.

◆ resizeSend()

void bitpit::DataCommunicator::resizeSend ( int rank,
long size )

Resize the send associated to the specified rank

Parameters
rankis the rank of the process associated to the send
sizeis the size, expressed in bytes, of the send

Definition at line 607 of file communications.cpp.

◆ setDiscoverTag()

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.

Parameters
tagis the custom tag to be used for data size discover

Definition at line 189 of file communications.cpp.

◆ setExchangeTag()

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.

Parameters
tagis the custom tag to be used for data exchange

Definition at line 171 of file communications.cpp.

◆ setNotificationTag()

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.

Parameters
tagis the custom tag to be used for notifications

Definition at line 207 of file communications.cpp.

◆ setRecv()

void bitpit::DataCommunicator::setRecv ( int rank,
long length = 0 )

Set recevie information for the specified rank

Parameters
rankis the rank of the process associated to the receive
lengthis the length, expressed in bytes, of the data to be received

Definition at line 582 of file communications.cpp.

◆ setRecvsContinuous()

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.

Parameters
enabledif set to true enables the "continuous" mode.

Definition at line 268 of file communications.cpp.

◆ setSend()

void bitpit::DataCommunicator::setSend ( int rank,
long length = 0 )

Set send information for the specified rank

Parameters
rankis the rank of the process associated to the send
lengthis the length, expressed in bytes, of the data to be sent

Definition at line 562 of file communications.cpp.

◆ setTag()

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.

Parameters
exchangeTagis the custom tag to be used for data exchange

Definition at line 141 of file communications.cpp.

◆ setTags()

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.

Parameters
exchangeTagis the custom tag to be used for data exchange
discoverTagis the custom tag to be used for data size discover
notificationTagis the custom tag to be used for notifications

Definition at line 156 of file communications.cpp.

◆ startAllRecvs()

void bitpit::DataCommunicator::startAllRecvs ( )

Starts receiving the data from all the ranks

Definition at line 784 of file communications.cpp.

◆ startAllSends()

void bitpit::DataCommunicator::startAllSends ( )

Starts sending the data to all the ranks

Definition at line 740 of file communications.cpp.

◆ startRecv()

void bitpit::DataCommunicator::startRecv ( int srcRank)

Starts receiving the data from the specified rank

Parameters
srcRankis the source rank

Definition at line 772 of file communications.cpp.

◆ startSend()

void bitpit::DataCommunicator::startSend ( int dstRank)

Starts sending the data to the specified rank

Parameters
dstRankis the destination rank

Definition at line 721 of file communications.cpp.

◆ waitAllRecvs()

void bitpit::DataCommunicator::waitAllRecvs ( )

Waits for all the receives to complete.

Definition at line 961 of file communications.cpp.

◆ waitAllSends()

void bitpit::DataCommunicator::waitAllSends ( )

Waits for all the sends to complete.

Definition at line 869 of file communications.cpp.

◆ waitAnyRecv()

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.

Parameters
blackListis a list of ranks whose recevies don't have to be waited for
Returns
The rank of the completed receive or MPI_UNDEFINED if there was no active receives.

Definition at line 894 of file communications.cpp.

◆ waitAnySend()

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.

Parameters
blackListis a list of ranks whose sends don't have to be waited for
Returns
The rank of the completed send or MPI_UNDEFINED if there was no active sends.

Definition at line 821 of file communications.cpp.

◆ waitRecv()

void bitpit::DataCommunicator::waitRecv ( int rank)

Waits for the receive associate to the sepcified rank to complete.

Parameters
rankis the rank associated to the receive to wait for

Definition at line 935 of file communications.cpp.

◆ waitSend()

void bitpit::DataCommunicator::waitSend ( int rank)

Waits for the send associate to the sepcified rank to complete.

Parameters
rankis the rank associated to the send to wait for

Definition at line 851 of file communications.cpp.

Member Data Documentation

◆ TAG_AUTO

BITPIT_PUBLIC_API const int bitpit::DataCommunicator::TAG_AUTO = -1
static

Definition at line 45 of file communications.hpp.


The documentation for this class was generated from the following files:
--- layout: doxygen_footer ---