OpenAtom
Version1.5a
|
Class that buffers incoming data (via messages/RDMA) till it counts a pre-specified number of arrivals, and then spits the collated data out (packaged in the same incoming message type) via a CkCallback. More...
#include <MessageDataCollator.h>
Public Member Functions | |
MessageDataCollator () | |
MessageDataCollator (std::string debugID, CkCallback callbk, const unsigned int nExpected, bool manageBuffer=false, const unsigned int offsetStart=0) | |
Collators should be constructed thus. More... | |
~MessageDataCollator () | |
Destructor. | |
void | operator() (msgType *msg) |
PUP method. More... | |
template<class tokenType > | |
void | setupRDMA (RDMASetupRequestMsg< tokenType > *msg, tokenType *replyToken=0) |
Called by a data sender to setup an RDMA link with me (data receiver) | |
void | operator() (void) |
RDMA equivalent of msg handling. When data arrives via RDMA, this is called for handling it. Gets called from the CmiDirect code via a callback. | |
void | expectNext () |
Ask me to notify converse that we're ready for the next batch of messages. | |
unsigned int | getNumExpected () const |
Get the number of messages this collator has been configured to buffer. | |
unsigned int | getNumReceived () const |
Check the number of messages that have arrived. | |
unsigned int | getNumBatchesDone () const |
Get the number of batches of incoming messages already processed. | |
msgType * | getSampleMsg () |
Get a copy of a sample message from the last completed batch of messages. Copy managed by the user. More... | |
Static Public Member Functions | |
static void | collatorCallback (void *thisObj) |
Fed to CmiDirect as a callback to be triggered when some data is deposited by RDMA. | |
Private Attributes | |
std::string | myName |
A string that encodes some kind of ID supplied by the owner of an instance. | |
CkCallback | uponCompletion |
Callback that is passed in to trigger the post-collation work. | |
bool | isBufferMine |
If buffer is mine, I manage it, viz. reuse the same buffer for every batch of msgs where possible. If not, I allocate a fresh buffer and let the client manage it. | |
msgType * | outputMsg |
The message (which has the data buffer) in which the incoming data is collated. | |
dataType * | dataBuffer |
A pointer to the memory region (contained in outputMsg) where incoming data is collated. | |
msgType * | sampleMsg |
Handle to a sample message copied from every batch of incoming messages. | |
unsigned int | numExpected |
Counters to keep track of the messages. | |
unsigned int | numReceived |
unsigned int | numBatchesProcessed |
unsigned int | numRows |
Variables related to the message/buffer sizes. | |
unsigned int | numCols |
unsigned int | numUnitsInMsg |
unsigned int | bufferSizeInUnits |
unsigned int | minSender |
Senders should have an ID accessed by msgType::sender(). More... | |
CkVec< rdmaHandleType > | RDMAhandles |
A vector of RDMA handles, one for each sender. | |
bool | isNextBatchViaRDMA |
Booleans indicating if the next/current batch of messages are via RDMA. | |
bool | isThisBatchViaRDMA |
Class that buffers incoming data (via messages/RDMA) till it counts a pre-specified number of arrivals, and then spits the collated data out (packaged in the same incoming message type) via a CkCallback.
Assumptions:
Definition at line 53 of file MessageDataCollator.h.
|
inline |
Definition at line 58 of file MessageDataCollator.h.
|
inline |
Collators should be constructed thus.
Copying has not been restricted so that collator classes can be passed in as arguments. Hence, be careful when copying collators to make sure multiple collators dont use the same memory region as a data buffer and kill you.
Definition at line 63 of file MessageDataCollator.h.
References cp::paircalc::MessageDataCollator< msgType, dataType >::isBufferMine, cp::paircalc::MessageDataCollator< msgType, dataType >::myName, cp::paircalc::MessageDataCollator< msgType, dataType >::numExpected, and cp::paircalc::MessageDataCollator< msgType, dataType >::RDMAhandles.
|
inline |
Get a copy of a sample message from the last completed batch of messages. Copy managed by the user.
Useful in case the msg has info other than the data() field.
These can then be extracted in a case-specific manner, by the client code directly.
Definition at line 267 of file MessageDataCollator.h.
Referenced by PairCalculator::acceptLeftData(), and PairCalculator::acceptRightData().
void MessageDataCollator< msgType, dataType >::operator() | ( | msgType * | msg | ) |
PUP method.
Makes this a functor so that it can be fed messages by any entity that just knows the MessageHandler API.
If we're in the middle of a batch of messages
else, if this is a fresh batch of messages
First, ensure that I was not expecting the next batch of data via RDMA
Since, this is the first message in a new batch, flag this whole batch as NOT via RDMA
Get the message size
Get the required buffer size
If buffer exists AND I manage it AND its not big enough for this batch of messages, delete it
If the buffer is unallocated ...
Get some memory to hold the message data
Zero out the memory region
endif
Ensure that the output message and its data buffer exist
Ensure that this message has the same size as the others in this batch
Compute the offset for this message. This will depend on the sender index and thisIndex.
Copy the data from the message into the contiguous data buffer
Increment the tally of received messages
If the expected number have arrived ...
Increment the number of message batches that have been processed
Create a copy of this message for a sample from this batch
Call the trigger functor
Reset the number received so that we can start collating all over again
If you are not managing the buffer, then you need to forget about it
endif
Do NOT delete the msg; MessageDataCollator is not a chare and doesnt worry about the message formalities. Let the user code handle this
Definition at line 163 of file MessageDataCollator.h.
|
private |
Senders should have an ID accessed by msgType::sender().
This stores the minimum value of sender(), so that offsets into the memory buffer can be computed
Definition at line 153 of file MessageDataCollator.h.