We provide some bindings for the MPI library to natively handle PnlObjects.
The functionnalities described in this chapter are declared in pnl/pnl_mpi.h.
All the following functions return an error code as an integer value. This returned value should be tested against MPI_SUCCESS to check that no error occurred.
int pnl_object_mpi_pack_size (const PnlObject *Obj, MPI_Comm comm, int
*size)
Description Compute in size the amount of space needed to pack Obj.
int pnl_object_mpi_pack (const PnlObject *Obj, void *buf, int bufsize, int *pos,
MPI_Comm comm)
Description Pack Obj into buf which must be at least of length size. size must be at
least equal to the value returned by pnl_object_mpi_pack_size.
int pnl_object_mpi_unpack (PnlObject *Obj, void *buf, int bufsize, int *pos,
MPI_Comm comm)
Description Unpack the content of buf starting at position pos (unless several objects
have been packed contiguously, *pos should be equal to 0). buf is a contigous memery
area of length bufsize (note that the size is counted in bytes). pos is incremented and
is on output the first location in the input buffer after the locations occupied by the
message that was unpacked. pos is properly set for a future call to MPI_Unpack if any.
int pnl_object_mpi_send (const PnlObject *Obj, int dest, int tag, MPI_Comm
comm)
Description Perform a standard-mode blocking send of Obj. The object is sent to the
process with rank dest.
int pnl_object_mpi_ssend (const PnlObject *Obj, int dest, int tag, MPI_Comm
comm)
Description Perform a standard-mode synchronous blocking send of Obj. The object
is sent to the process with rank dest.
int pnl_object_mpi_recv (PnlObject *Obj, int src, int tag, MPI_Comm comm,
MPI_Status *status)
Description Perform a standard-mode blocking receive of Obj. The object is sent to
the process with rank dest. Note that Obj should be an already allocated object and
that its type should match the true type of the object to be received. src is the rank of
the process who sent the object.
int pnl_object_mpi_bcast (PnlObject *Obj, int root, MPI_Comm comm)
Description Broadcast the object Obj from the process with rank root to all other
processes of the group comm.
int pnl_object_mpi_reduce (PnlObject *Sendbuf, PnlObject *Recvbuf, MPI_Op
op, int root, MPI_Comm comm)
Description Perform the reduction described by op on the objects Sendbuf and stores
the result into Recvbuf. Note that Recvbuf and Sendbuf must be of the same type. The
argument root is the index of the root process and comm is a communicator. Not all
reductions are implemented for all types. Here is the list of compatible reductions
MPI_SUM | PnlVect, PnlVectInt, PnlVectComplex, |
PnlMat, PnlMatInt, PnlMatComplex | |
MPI_PROD, MPI_MAX, | PnlVect, PnlVectInt, PnlMat, PnlMatInt |
MPI_MIN |
For more expect users, we provide the following nonblocking functions.
int pnl_object_mpi_isend (const PnlObject *Obj, int dest, int tag, MPI_Comm
comm, MPI_Request *request)
Description Start a standard-mode, nonblocking send of object Obj to the process
with rank dest.
int pnl_object_mpi_irecv (void **buf, int *size, int src, int tag, MPI_Comm
comm, int *flag, MPI_Request *request)
Description Start a standard-mode, nonblocking receive of object Obj from the
process with rank root. On output flag equals to TRUE if the object can be received
and FALSE otherwise (this is the same as for MPI_Iprobe).
The interface is only accessible when the MPI bindings are compiled since it is based on the Packing/Unpacking facilities of MPI.
The functionnalities described in this chapter are declared in pnl/pnl_mpi.h.
PnlRng ** pnl_rng_create_from_file (char *str, int n)
Description Load n rng from the file of name str and returns an array of n PnlRng .
int pnl_rng_save_to_file (PnlRng **rngtab, int n, char *str)
Description Save n rng stored in rngtab into the file of name str.
int pnl_object_save (PnlObject *O, FILE *stream)
Description Save the object O into the stream stream. stream is typically created by
calling fopen with mode="wb". This function can be called several times to save several
objects in the same stream.
PnlObject* pnl_object_load (FILE *stream)
Description Load an object from the stream stream. stream is typically created by
calling fopen with mode="rb". This function can be called several times to load several
objects from the same stream. If stream was empty or it did not contain any PnlObjects,
the function returns NULL.
PnlList* pnl_object_load_into_list (FILE *stream)
Description Load as many objects as possible from the stream stream and stores
them into a PnlList . stream is typically created by calling fopen with mode="rb". If
stream was empty or it did not contain any PnlObjects, the function returns NULL.