MPITcl binary data.


MPITcl binary data -- Receiving binary data in compiled MPITcl extensions


#include <mpitcl.h>
static const int MPI_TAG_SCRIPT(1); 
static const int MPI_TAG_TCLDATA(2);
static const int MPI_TAG_BINDATA(3);

typedef void (*MPIBinDataHandler)(int, int, void*);
void MPITcl_setBinaryDataHandler(MPIBinDataHandler handler);



It is reasonable to think about compiled extensions being layered on top of the mpitcl interpreter. These extensions can hook into the message passing as follows:

Extensions can use MPI_Send to send MPI_CHAR data with one of the tags MPI_TAG_SCRIPT (if a script is being sent for execution in the target), or MPI_TAG_TCLDATA if Tcl friendly data are being sent for receipt in the targe. In both cases, the data must be sent with the data type MPI_CHAR.

It's also possible for an extension to register to be called if data with the tag MPI_TAG_BINDATA tag has been received by is process.

Such binary data handlers are registered by calling MPITcl_setBinaryDataHandler. Note tht passing nullptr as a parameter removes any existing data handler. Note as well that in the event this is called several times, only the most recently established data handler is used.

Data handlers are void functions that accept three parameters, The first parameter is the rank that sent the message. The second is the size of the message in bytes (really in MPI_CHAR. The last a pointer to the received data. If the data are required for longer than the duration of execution of the handler function it must be copied.

Note as well that a data handler established by MPITcl_setBinaryDataHandler is only called in rank 0 when that interpreter has entered the event loop via, e.g. vwait.