Partial implementation of MPI using only threads. More...
Classes | |
| struct | PLMD::thread_mpi::tmpi_status_ |
| tMPI Status. More... | |
Namespaces | |
| namespace | PLMD |
| Fast (possibly busy-wait-based) barrier type. | |
| namespace | PLMD::thread_mpi |
Macros | |
| #define | TMPI |
| tMPI definition. | |
| #define | TMPI_ANY_SOURCE -1 |
| Source number wildcard so tMPI_Recv(), etc. | |
| #define | TMPI_ANY_TAG -1 |
| Tag number wildcard so tMPI_Recv(), etc. | |
| #define | TMPI_CART 1 |
| Return code for Cartesian topology with tMPI_Topo_test(). | |
| #define | TMPI_COMM_NULL nullptr |
| A pre-defined NULL communicator to compare against, to check comm validity. | |
| #define | TMPI_COMM_SELF |
| The thread-specific comm containing only the thread itself. | |
| #define | TMPI_GRAPH 2 |
| Return code for graph topology with tMPI_Topo_test(). | |
| #define | TMPI_GROUP_NULL nullptr |
| A pre-defined NULL group to compare against, to check group validity. | |
| #define | TMPI_IN_PLACE NULL |
| collective communication special to signify that the send buffer is to function as receive buffer. | |
| #define | TMPI_MAX_ERROR_STRING 256 |
| Maximum length of error string for tMPI_Error_string() | |
| #define | TMPI_MAX_PROCESSOR_NAME 128 |
| The maximum processor name returned using tMPI_Get_processor_name(). | |
| #define | TMPI_REQUEST_NULL NULL |
| NULL request. | |
| #define | TMPI_STATUS_IGNORE NULL |
| Used as NULL status for tMPI_Recv(), etc. | |
| #define | TMPI_STATUSES_IGNORE NULL |
| Used as NULL status list for tMPI_Waitall(), etc. | |
| #define | TMPI_UNDEFINED -1 |
| default code for undefined value, | |
tMPI_Comm_compare() return codes | |
| #define | TMPI_CONGRUENT 1 |
| Comms with the same members in the same order. | |
| #define | TMPI_IDENT 0 |
| Identical comms. | |
| #define | TMPI_SIMILAR 2 |
| Comms with the same members in the different order. | |
| #define | TMPI_UNEQUAL 3 |
| Comms with the different members. | |
Typedefs | |
| typedef struct tmpi_comm_ * | PLMD::thread_mpi::tMPI_Comm |
| tMPI Communicator | |
| typedef struct tmpi_datatype_ * | PLMD::thread_mpi::tMPI_Datatype |
| tMPI datatype | |
| typedef struct tmpi_errhandler_ * | PLMD::thread_mpi::tMPI_Errhandler |
| error handler object | |
| typedef void(* | PLMD::thread_mpi::tMPI_Errhandler_fn) (tMPI_Comm *, int *) |
| error handler function | |
| typedef struct tmpi_group_ * | PLMD::thread_mpi::tMPI_Group |
| tMPI Group | |
| typedef struct tmpi_req_ * | PLMD::thread_mpi::tMPI_Request |
| tMPI Request | |
| typedef struct PLMD::thread_mpi::tmpi_status_ | PLMD::thread_mpi::tMPI_Status |
| tMPI Status. | |
Functions | |
| tMPI_Comm | PLMD::thread_mpi::tMPI_Get_comm_self (void) |
Initialization and exit functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Abort (tMPI_Comm comm, int errorcode) |
| Just kills all threads. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Finalize (void) |
| Waits for all other threads to finish and cleans up. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Finalized (int *flag) |
| Determine whether tMPI_Finalize has been run. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Get_N (int *argc, char ***argv, const char *optname, int *nthreads) |
| get the number of threads from the command line | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Init (int *argc, char ***argv, int(*start_function)(int, char **)) |
| Traditional MPI initializer; spawns threads that start at the given function. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Init_fn (int main_thread_returns, int N, tMPI_Affinity_strategy aff_strategy, void(*start_function)(const void *), const void *arg) |
| Generic init function thread MPI intializer and thread spawner. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Initialized (int *flag) |
| whether tMPI_Init, but not yet tMPI_Finalize, has been run | |
Error handling functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_get_errhandler (tMPI_Comm comm, tMPI_Errhandler *errhandler) |
| get the error handler. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_set_errhandler (tMPI_Comm comm, tMPI_Errhandler errhandler) |
| Set the error handler. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Create_errhandler (tMPI_Errhandler_fn *function, tMPI_Errhandler *errhandler) |
| Create an error handler object from a function. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Errhandler_free (tMPI_Errhandler *errhandler) |
| Free the error handler object. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Error_string (int errorcode, char *string, int *resultlen) |
| get the error string associated with an error code. | |
tMPI_Group functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_group (tMPI_Comm comm, tMPI_Group *group) |
| Get a pointer to the group in the comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Group_free (tMPI_Group *group) |
| De-allocate a group. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Group_incl (tMPI_Group group, int n, const int *ranks, tMPI_Group *newgroup) |
| Create a new group as a the collection of threads with given ranks. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Group_rank (tMPI_Group group, int *rank) |
| Get the rank of a thread in a group. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Group_size (tMPI_Group group, int *size) |
| Get the size (number of members) of a group. | |
tMPI_Comm functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_compare (tMPI_Comm comm1, tMPI_Comm comm2, int *result) |
| Compare two comms. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_create (tMPI_Comm comm, tMPI_Group group, tMPI_Comm *newcomm) |
| Create a comm based on group membership. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_dup (tMPI_Comm comm, tMPI_Comm *newcomm) |
| Make a duplicate of a comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_free (tMPI_Comm *comm) |
| De-allocate a comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_rank (tMPI_Comm comm, int *rank) |
| get the rank in comm of the current process | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_size (tMPI_Comm comm, int *size) |
| Get the comm size (nr. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Comm_split (tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm) |
| Split up a group into same-colored sub-groups ordered by key. | |
Topology functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_coords (tMPI_Comm comm, int rank, int maxdims, int *coords) |
| Get coordinates of a process rank in a Cartesian topology. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_create (tMPI_Comm comm_old, int ndims, const int *dims, const int *periods, int reorder, tMPI_Comm *comm_cart) |
| Create a comm with a Cartesian topology. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_get (tMPI_Comm comm, int maxdims, int *dims, int *periods, int *coords) |
| Get the size and pbc a of a comm with a Cartesian topology has. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_map (tMPI_Comm comm, int ndims, const int *dims, const int *periods, int *newrank) |
| Get optimal rank this process would have in a Cartesian topology. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_rank (tMPI_Comm comm, const int *coords, int *rank) |
| Get rank that a specific set of process coordinates has in a Cartesian topology. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cart_sub (tMPI_Comm comm, const int *remain_dims, tMPI_Comm *newcomm) |
| Create a comms that are sub-spaces of the Cartesian topology communicator. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Cartdim_get (tMPI_Comm comm, int *ndims) |
| Get the dimensionality of a comm with a topology. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Topo_test (tMPI_Comm comm, int *status) |
| Check what type of topology the comm has. | |
Data type manipulation functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Type_commit (tMPI_Datatype *datatype) |
| Make a data type ready for use. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Type_contiguous (int count, tMPI_Datatype oldtype, tMPI_Datatype *newtype) |
| Create a contiguous data type (the only type possible right now). | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Type_free (tMPI_Datatype *datatype) |
| Free the datatype. | |
Point-to-point communication functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Get_count (const tMPI_Status *status, tMPI_Datatype datatype, int *count) |
| get the number of actually transferred items from a receive status. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Irecv (void *buf, int count, tMPI_Datatype datatype, int source, int tag, tMPI_Comm comm, tMPI_Request *request) |
| Initiate receiving a message. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Isend (const void *buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm, tMPI_Request *request) |
| Initiate sending a message, non-blocking. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Recv (void *buf, int count, tMPI_Datatype datatype, int source, int tag, tMPI_Comm comm, tMPI_Status *status) |
| Receive message; blocks until buf is filled. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Send (const void *buf, int count, tMPI_Datatype datatype, int dest, int tag, tMPI_Comm comm) |
| Send message; blocks until buf is reusable. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Sendrecv (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, int dest, int sendtag, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int source, int recvtag, tMPI_Comm comm, tMPI_Status *status) |
| Send & receive message at the same time. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Test (tMPI_Request *request, int *flag, tMPI_Status *status) |
| Test whether a message is transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Testall (int count, tMPI_Request *array_of_requests, int *flag, tMPI_Status *array_of_statuses) |
| Test whether several messages are transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Testany (int count, tMPI_Request *array_of_requests, int *index, int *flag, tMPI_Status *status) |
| Test whether one of several messages is transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Testsome (int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses) |
| Test whether some of several messages are transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Wait (tMPI_Request *request, tMPI_Status *status) |
| Wait until a message is transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Waitall (int count, tMPI_Request *array_of_requests, tMPI_Status *array_of_statuses) |
| Wait until several messages are transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Waitany (int count, tMPI_Request *array_of_requests, int *index, tMPI_Status *status) |
| Wait until one of several messages is transferred. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Waitsome (int incount, tMPI_Request *array_of_requests, int *outcount, int *array_of_indices, tMPI_Status *array_of_statuses) |
| Wait until some of several messages are transferred. | |
Synchronization functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Barrier (tMPI_Comm comm) |
| Block until all threads in the comm call this function. | |
Multicast communication functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Alltoall (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, tMPI_Comm comm) |
| Spread out parts of sendbuf to all processes from all processes in comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Alltoallv (const void *sendbuf, const int *sendcounts, const int *sdispls, tMPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *rdispls, tMPI_Datatype recvtype, tMPI_Comm comm) |
| Spread out irregularly laid out parts of sendbuf to all processes from all processes in comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Bcast (void *buffer, int count, tMPI_Datatype datatype, int root, tMPI_Comm comm) |
| Broadcast from one thread to all others in comm. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Gather (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm) |
| Gather data from all threads in comm to root. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Gatherv (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *displs, tMPI_Datatype recvtype, int root, tMPI_Comm comm) |
| Gather irregularly laid out data from all processes in comm to root. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Scatter (const void *sendbuf, int sendcount, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm) |
| Spread parts of sendbuf to all processes in comm from root. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Scatterv (const void *sendbuf, const int *sendcounts, const int *displs, tMPI_Datatype sendtype, void *recvbuf, int recvcount, tMPI_Datatype recvtype, int root, tMPI_Comm comm) |
| Spread irregularly laid out parts of sendbuf to all processes in comm from root. | |
Reduce functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Allreduce (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm) |
| Do an operation between all locally held buffers on all items in the buffers and broadcast the results. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Reduce (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm) |
| Do an operation between all locally held buffers on all items in the buffers, and send the results to root. | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Reduce_fast (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm) |
| Do an tMPI_Reduce, but with the following assumption: recvbuf points to a valid buffer in all calling threads, or sendbuf has the value TMPI_IN_PLACE (in which case the values of sendbuf may be changed in that thread). | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Scan (const void *sendbuf, void *recvbuf, int count, tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm) |
| Do a partial reduce operation, based on rank: the results of the reduction operation of ranks 0 - i will be put in the recvbuf of rank i. | |
Environment query functions | |
| TMPI_EXPORT int | PLMD::thread_mpi::tMPI_Get_processor_name (char *name, int *resultlen) |
| returns string with thread number. | |
| #define | tMPI_This_threadnr() |
| TMPI_EXPORT double | PLMD::thread_mpi::tMPI_Wtick (void) |
| get the resolution of tMPI_Wtime as a double, in seconds | |
| TMPI_EXPORT double | PLMD::thread_mpi::tMPI_Wtime (void) |
| get a time value as a double, in seconds. | |
Partial implementation of MPI using only threads.
See the MPI specification at http://www.mpi-forum.org/docs/docs.html for an explanation of what these functions do.
Because this is a thread-based library, be very careful with global variables and static variables in functions: they will be shared across all threads and lead to conflicts if not properly mutex-ed or barrier-ed out.
| #define TMPI |
tMPI definition.
Use this to check for thread_mpi with the preprocessor.
| #define TMPI_ANY_SOURCE -1 |
Source number wildcard so tMPI_Recv(), etc.
can receive from any source.
| #define TMPI_ANY_TAG -1 |
Tag number wildcard so tMPI_Recv(), etc.
can receive messages with any tag.
| #define TMPI_CART 1 |
Return code for Cartesian topology with tMPI_Topo_test().
| #define TMPI_COMM_NULL nullptr |
A pre-defined NULL communicator to compare against, to check comm validity.
| #define TMPI_COMM_SELF |
The thread-specific comm containing only the thread itself.
| #define TMPI_CONGRUENT 1 |
Comms with the same members in the same order.
| #define TMPI_GRAPH 2 |
Return code for graph topology with tMPI_Topo_test().
| #define TMPI_GROUP_NULL nullptr |
A pre-defined NULL group to compare against, to check group validity.
| #define TMPI_IDENT 0 |
Identical comms.
| #define TMPI_IN_PLACE NULL |
collective communication special to signify that the send buffer is to function as receive buffer.
Used, for example in tMPI_Reduce.
| #define TMPI_MAX_ERROR_STRING 256 |
Maximum length of error string for tMPI_Error_string()
| #define TMPI_MAX_PROCESSOR_NAME 128 |
The maximum processor name returned using tMPI_Get_processor_name().
| #define TMPI_REQUEST_NULL NULL |
NULL request.
| #define TMPI_SIMILAR 2 |
Comms with the same members in the different order.
| #define TMPI_STATUS_IGNORE NULL |
Used as NULL status for tMPI_Recv(), etc.
| #define TMPI_STATUSES_IGNORE NULL |
Used as NULL status list for tMPI_Waitall(), etc.
| #define tMPI_This_threadnr | ( | ) |
| #define TMPI_UNDEFINED -1 |
default code for undefined value,
For example for undefined color in tMPI_Split().
| #define TMPI_UNEQUAL 3 |
Comms with the different members.
Hosted by GitHub
|
1.13.2
|