libsc
2.8.7
The SC library provides support for parallel scientific applications.
|
Provide a consistent MPI interface with and without MPI configured. More...
Go to the source code of this file.
Data Structures | |
struct | sc_MPI_Status |
Replacement of MPI_Status for non-MPI configuration. More... | |
struct | sc_no_mpiio_file |
Replacement structure for MPI_File . More... | |
Macros | |
#define | sc_MPI_SUCCESS SC3_MPI_SUCCESS |
Emulate SC_MPI_SUCCESS . | |
#define | sc_MPI_ERR_ARG SC3_MPI_ERR_ARG |
Emulate SC_MPI_ERR_ARG . | |
#define | sc_MPI_ERR_COUNT SC3_MPI_ERR_COUNT |
Emulate SC_MPI_ERR_COUNT . | |
#define | sc_MPI_ERR_UNKNOWN SC3_MPI_ERR_UNKNOWN |
Emulate SC_MPI_ERR_UNKNOWN . | |
#define | sc_MPI_ERR_OTHER SC3_MPI_ERR_OTHER |
Emulate SC_MPI_ERR_OTHER . | |
#define | sc_MPI_ERR_NO_MEM SC3_MPI_ERR_NO_MEM |
Emulate SC_MPI_ERR_NO_MEM . | |
#define | sc_MPI_ERR_FILE SC3_MPI_ERR_FILE |
Emulate SC_MPI_ERR_FILE . | |
#define | sc_MPI_ERR_NOT_SAME SC3_MPI_ERR_NOT_SAME |
Emulate SC_MPI_ERR_NOT_SAME . | |
#define | sc_MPI_ERR_AMODE SC3_MPI_ERR_AMODE |
Emulate SC_MPI_ERR_AMODE . | |
#define | sc_MPI_ERR_UNSUPPORTED_DATAREP SC3_MPI_ERR_UNSUPPORTED_DATAREP |
Emulate SC_MPI_ERR_UNSUPPORTED_DATAREP . | |
#define | sc_MPI_ERR_UNSUPPORTED_OPERATION SC3_MPI_ERR_UNSUPPORTED_OPERATION |
Emulate SC_MPI_ERR_UNSUPPORTED_OPERATION . | |
#define | sc_MPI_ERR_NO_SUCH_FILE SC3_MPI_ERR_NO_SUCH_FILE |
Emulate SC_MPI_ERR_NO_SUCH_FILE . | |
#define | sc_MPI_ERR_FILE_EXISTS SC3_MPI_ERR_FILE_EXISTS |
Emulate SC_MPI_ERR_FILE_EXISTS . | |
#define | sc_MPI_ERR_BAD_FILE SC3_MPI_ERR_BAD_FILE |
Emulate SC_MPI_ERR_BAD_FILE . | |
#define | sc_MPI_ERR_ACCESS SC3_MPI_ERR_ACCESS |
Emulate SC_MPI_ERR_ACCESS . | |
#define | sc_MPI_ERR_NO_SPACE SC3_MPI_ERR_NO_SPACE |
Emulate SC_MPI_ERR_NO_SPACE . | |
#define | sc_MPI_ERR_QUOTA SC3_MPI_ERR_QUOTA |
Emulate SC_MPI_ERR_QUOTA . | |
#define | sc_MPI_ERR_READ_ONLY SC3_MPI_ERR_READ_ONLY |
Emulate SC_MPI_ERR_READ_ONLY . | |
#define | sc_MPI_ERR_FILE_IN_USE SC3_MPI_ERR_FILE_IN_USE |
Emulate SC_MPI_ERR_FILE_IN_USE . | |
#define | sc_MPI_ERR_DUP_DATAREP SC3_MPI_ERR_DUP_DATAREP |
Emulate SC_MPI_ERR_DUP_DATAREP . | |
#define | sc_MPI_ERR_CONVERSION SC3_MPI_ERR_CONVERSION |
Emulate SC_MPI_ERR_CONVERSION . | |
#define | sc_MPI_ERR_IO SC3_MPI_ERR_IO |
Emulate SC_MPI_ERR_IO . | |
#define | sc_MPI_ERR_LASTCODE SC3_MPI_ERR_LASTCODE |
Emulate SC_MPI_ERR_LASTCODE . | |
#define | sc_MPI_MAX_ERROR_STRING SC3_MPI_MAX_ERROR_STRING |
Emulate MPI_MAX_ERROR_STRING . | |
#define | sc_MPI_COMM_NULL SC3_MPI_COMM_NULL |
Emulate the null communicator. | |
#define | sc_MPI_COMM_WORLD SC3_MPI_COMM_WORLD |
Emulate the world communicator. | |
#define | sc_MPI_COMM_SELF SC3_MPI_COMM_SELF |
Emulate the self communicator. | |
#define | sc_MPI_GROUP_NULL ((sc_MPI_Group) 0x54000000) /* TODO change val */ |
Emulate the null group. More... | |
#define | sc_MPI_GROUP_EMPTY ((sc_MPI_Group) 0x54000001) /* TODO change val */ |
Emulate the empty group. More... | |
#define | sc_MPI_MIN SC3_MPI_MIN |
Minimum operator. | |
#define | sc_MPI_MAX SC3_MPI_MAX |
Maximum operator. | |
#define | sc_MPI_SUM SC3_MPI_SUM |
Summation operator. | |
#define | sc_MPI_UNDEFINED SC3_MPI_UNDEFINED |
Emulate MPI_UNDEFINED . | |
#define | sc_MPI_INFO_NULL NULL |
Emulate null Info. | |
#define | sc_MPI_COMM_TYPE_SHARED sc_MPI_UNDEFINED |
#define | sc_MPI_FILE_NULL NULL |
The null MPI file. | |
Typedefs | |
typedef int | sc_MPI_Group |
Emulate an MPI group. | |
typedef int | sc_MPI_Request |
Emulate an MPI request. | |
typedef sc3_MPI_Comm_t | sc_MPI_Comm |
Emulate an MPI communicator. | |
typedef sc3_MPI_Info_t | sc_MPI_Info |
Emulate an MPI Info object. | |
typedef sc3_MPI_Datatype_t | sc_MPI_Datatype |
Emulate MPI datatypes. | |
typedef sc3_MPI_Op_t | sc_MPI_Op |
Emulate MPI operations. | |
typedef struct sc_MPI_Status | sc_MPI_Status |
Replacement of MPI_Status for non-MPI configuration. | |
typedef long | sc_MPI_Offset |
Emulate the MPI offset type. | |
typedef struct sc_no_mpiio_file * | sc_MPI_File |
Replacement object for an MPI file. | |
Enumerations | |
enum | sc_tag_t { SC_TAG_FIRST = 's' + 'c' , SC_TAG_AG_ALLTOALL = SC_TAG_FIRST , SC_TAG_AG_RECURSIVE_A , SC_TAG_AG_RECURSIVE_B , SC_TAG_AG_RECURSIVE_C , SC_TAG_NOTIFY_CENSUS , SC_TAG_NOTIFY_CENSUSV , SC_TAG_NOTIFY_NBX , SC_TAG_NOTIFY_NBXV , SC_TAG_NOTIFY_WRAPPER , SC_TAG_NOTIFY_WRAPPERV , SC_TAG_NOTIFY_RANGES , SC_TAG_NOTIFY_PAYLOAD , SC_TAG_NOTIFY_SUPER_TRUE , SC_TAG_NOTIFY_SUPER_EXTRA , SC_TAG_NOTIFY_RECURSIVE , SC_TAG_NOTIFY_NARY = SC_TAG_NOTIFY_RECURSIVE + 32 , SC_TAG_REDUCE = SC_TAG_NOTIFY_NARY + 32 , SC_TAG_PSORT_LO , SC_TAG_PSORT_HI , SC_TAG_LAST } |
Enumerate all MPI tags used internally to the sc library. More... | |
Functions | |
int | sc_mpi_is_enabled (void) |
Return whether MPI is configured. More... | |
int | sc_mpi_is_shared (void) |
Return whether MPI supports type split and shared windows. More... | |
int | sc_MPI_Init (int *argc, char ***argv) |
MPI initialization. More... | |
int | sc_MPI_Finalize (void) |
MPI finalization. | |
int | sc_MPI_Abort (sc_MPI_Comm mpicomm, int ecode) |
Abort an MPI program. More... | |
int | sc_MPI_Comm_dup (sc_MPI_Comm mpicomm, sc_MPI_Comm *dupcomm) |
Duplicate an MPI communicator. More... | |
int | sc_MPI_Comm_free (sc_MPI_Comm *freecomm) |
Free a previously created MPI communicator. More... | |
int | sc_MPI_Type_size (sc_MPI_Datatype datatype, int *size) |
Return size of an MPI datatype. More... | |
int | sc_MPI_Pack (const void *inbuf, int incount, sc_MPI_Datatype datatype, void *outbuf, int outsize, int *position, sc_MPI_Comm comm) |
Pack several instances of the same datatype into contiguous memory. More... | |
int | sc_MPI_Unpack (const void *inbuf, int insize, int *position, void *outbuf, int outcount, sc_MPI_Datatype datatype, sc_MPI_Comm comm) |
Unpack contiguous memory into several instances of the same datatype. More... | |
int | sc_MPI_Pack_size (int incount, sc_MPI_Datatype datatype, sc_MPI_Comm comm, int *size) |
Determine space needed to pack several instances of the same datatype. More... | |
int | sc_MPI_Comm_size (sc_MPI_Comm mpicomm, int *mpisize) |
Query size of an MPI communicator. More... | |
int | sc_MPI_Comm_rank (sc_MPI_Comm mpicomm, int *mpirank) |
Query rank of an MPI process within a communicator. More... | |
int | sc_MPI_Group_size (sc_MPI_Group mpigroup, int *size) |
Query size of an MPI group. More... | |
int | sc_MPI_Group_rank (sc_MPI_Group mpigroup, int *rank) |
Query rank of an MPI process within a group. More... | |
int | sc_MPI_Barrier (sc_MPI_Comm mpicomm) |
Execute a parallel barrier. More... | |
int | sc_MPI_Bcast (void *, int, sc_MPI_Datatype, int, sc_MPI_Comm) |
Execute the MPI_Bcast algorithm. | |
int | sc_MPI_Gather (void *, int, sc_MPI_Datatype, void *, int, sc_MPI_Datatype, int, sc_MPI_Comm) |
int | sc_MPI_Gatherv (void *, int, sc_MPI_Datatype, void *, int *, int *, sc_MPI_Datatype, int, sc_MPI_Comm) |
int | sc_MPI_Allgather (void *, int, sc_MPI_Datatype, void *, int, sc_MPI_Datatype, sc_MPI_Comm) |
Execute the MPI_Allgather algorithm. | |
int | sc_MPI_Allgatherv (void *, int, sc_MPI_Datatype, void *, int *, int *, sc_MPI_Datatype, sc_MPI_Comm) |
Execute the MPI_Allgatherv algorithm. | |
int | sc_MPI_Alltoall (void *, int, sc_MPI_Datatype, void *, int, sc_MPI_Datatype, sc_MPI_Comm) |
Execute the MPI_Alltoall algorithm. | |
int | sc_MPI_Reduce (void *, void *, int, sc_MPI_Datatype, sc_MPI_Op, int, sc_MPI_Comm) |
Execute the MPI_Reduce algorithm. | |
int | sc_MPI_Reduce_scatter_block (void *, void *, int, sc_MPI_Datatype, sc_MPI_Op, sc_MPI_Comm) |
int | sc_MPI_Allreduce (void *, void *, int, sc_MPI_Datatype, sc_MPI_Op, sc_MPI_Comm) |
Execute the MPI_Allreduce algorithm. | |
int | sc_MPI_Scan (void *, void *, int, sc_MPI_Datatype, sc_MPI_Op, sc_MPI_Comm) |
Execute the MPI_Scan algorithm. | |
int | sc_MPI_Exscan (void *, void *, int, sc_MPI_Datatype, sc_MPI_Op, sc_MPI_Comm) |
Execute the MPI_Exscan algorithm. | |
sc_MPI_Aint | sc_MPI_Aint_diff (sc_MPI_Aint a, sc_MPI_Aint b) |
double | sc_MPI_Wtime (void) |
Execute the MPI_Wtime function. More... | |
int | sc_MPI_Comm_split (sc_MPI_Comm, int, int, sc_MPI_Comm *) |
Return the input communicator in lieu of splitting. More... | |
int | sc_MPI_Comm_create (sc_MPI_Comm, sc_MPI_Group, sc_MPI_Comm *) |
int | sc_MPI_Comm_compare (sc_MPI_Comm, sc_MPI_Comm, int *) |
int | sc_MPI_Comm_group (sc_MPI_Comm, sc_MPI_Group *) |
int | sc_MPI_Group_free (sc_MPI_Group *) |
int | sc_MPI_Group_translate_ranks (sc_MPI_Group, int, int *, sc_MPI_Group, int *) |
int | sc_MPI_Group_compare (sc_MPI_Group, sc_MPI_Group, int *) |
int | sc_MPI_Group_union (sc_MPI_Group, sc_MPI_Group, sc_MPI_Group *) |
int | sc_MPI_Group_intersection (sc_MPI_Group, sc_MPI_Group, sc_MPI_Group *) |
int | sc_MPI_Group_difference (sc_MPI_Group, sc_MPI_Group, sc_MPI_Group *) |
int | sc_MPI_Group_incl (sc_MPI_Group, int, int *, sc_MPI_Group *) |
int | sc_MPI_Group_excl (sc_MPI_Group, int, int *, sc_MPI_Group *) |
int | sc_MPI_Group_range_incl (sc_MPI_Group, int, int ranges[][3], sc_MPI_Group *) |
int | sc_MPI_Group_range_excl (sc_MPI_Group, int, int ranges[][3], sc_MPI_Group *) |
int | sc_MPI_Recv (void *, int, sc_MPI_Datatype, int, int, sc_MPI_Comm, sc_MPI_Status *) |
int | sc_MPI_Irecv (void *, int, sc_MPI_Datatype, int, int, sc_MPI_Comm, sc_MPI_Request *) |
int | sc_MPI_Send (void *, int, sc_MPI_Datatype, int, int, sc_MPI_Comm) |
int | sc_MPI_Isend (void *, int, sc_MPI_Datatype, int, int, sc_MPI_Comm, sc_MPI_Request *) |
int | sc_MPI_Probe (int, int, sc_MPI_Comm, sc_MPI_Status *) |
int | sc_MPI_Iprobe (int, int, sc_MPI_Comm, int *, sc_MPI_Status *) |
int | sc_MPI_Get_count (sc_MPI_Status *, sc_MPI_Datatype, int *) |
int | sc_MPI_Wait (sc_MPI_Request *, sc_MPI_Status *) |
int | sc_MPI_Waitsome (int, sc_MPI_Request *, int *, int *, sc_MPI_Status *) |
int | sc_MPI_Waitall (int, sc_MPI_Request *, sc_MPI_Status *) |
int | sc_MPI_Testall (int, sc_MPI_Request *, int *, sc_MPI_Status *) |
int | sc_MPI_Comm_split_type (sc_MPI_Comm mpicomm, int split_type, int key, sc_MPI_Info info, sc_MPI_Comm *newcomm) |
Wrapper to split an MPI communicator by shared node type. More... | |
int | sc_MPI_Init_thread (int *argc, char ***argv, int required, int *provided) |
int | sc_MPI_Error_class (int errorcode, int *errorclass) |
Turn an MPI error code into its error class. More... | |
int | sc_MPI_Error_string (int errorcode, char *string, int *resultlen) |
Turn MPI error code into a string. More... | |
size_t | sc_mpi_sizeof (sc_MPI_Datatype t) |
Return the size of MPI datatypes. More... | |
Provide a consistent MPI interface with and without MPI configured.
When MPI is configured, we redefine many MPI functions and objects. Without MPI, we emulate collective MPI routines to work as expected.
The goal is to make code compile and execute cleanly when --enable-mpi
is not given on the configure line. To this end, several MPI routines that are meaningful to call on one processor are provided with the prefix sc_MPI_
, as well as necessary types and defines. If --enable-mpi
is given, this file provides macros that map the sc_
-prefixed form to the standard form of the symbols.
When including this file in your code, everything inside #ifdef SC_ENABLE_MPI may as well use the standard MPI API. Outside of this definition block, the sc_MPI_* routines specified here are allow to seamlessly use MPI calls without breaking non-MPI code.
Some send and receive routines are wrapped. They can thus be used in code outside of #ifdef SC_ENABLE_MPI even though they will abort. If no messages are sent to the same processor when mpisize == 1, such aborts will not occur. The MPI_Wait*
routines are safe to call as long as no or only MPI_REQUEST_NULL requests are passed in.
#define sc_MPI_GROUP_EMPTY ((sc_MPI_Group) 0x54000001) /* TODO change val */ |
Emulate the empty group.
Group operations are not supported without MPI.
#define sc_MPI_GROUP_NULL ((sc_MPI_Group) 0x54000000) /* TODO change val */ |
Emulate the null group.
Group operations are not supported without MPI.
enum sc_tag_t |
Enumerate all MPI tags used internally to the sc library.
Enumerator | |
---|---|
SC_TAG_FIRST | Anything really. |
SC_TAG_AG_ALLTOALL | Used in MPI alltoall replacement. |
SC_TAG_AG_RECURSIVE_A | Internal tag; do not use. |
SC_TAG_AG_RECURSIVE_B | Internal tag; do not use. |
SC_TAG_AG_RECURSIVE_C | Internal tag; do not use. |
SC_TAG_NOTIFY_CENSUS | Internal tag to sc_notify. |
SC_TAG_NOTIFY_CENSUSV | Internal tag to sc_notify. |
SC_TAG_NOTIFY_NBX | Internal tag to sc_notify. |
SC_TAG_NOTIFY_NBXV | Internal tag to sc_notify. |
SC_TAG_NOTIFY_WRAPPER | Internal tag to sc_notify. |
SC_TAG_NOTIFY_WRAPPERV | Internal tag to sc_notify. |
SC_TAG_NOTIFY_RANGES | Internal tag to sc_notify. |
SC_TAG_NOTIFY_PAYLOAD | Internal tag to sc_notify. |
SC_TAG_NOTIFY_SUPER_TRUE | Internal tag to sc_notify. |
SC_TAG_NOTIFY_SUPER_EXTRA | Internal tag to sc_notify. |
SC_TAG_NOTIFY_RECURSIVE | Internal tag to sc_notify. |
SC_TAG_NOTIFY_NARY | Internal tag to sc_notify. |
SC_TAG_REDUCE | Used in MPI reduce replacement. |
SC_TAG_PSORT_LO | Internal tag to sc_psort. |
SC_TAG_PSORT_HI | Internal tag to sc_psort. |
SC_TAG_LAST | End marker of tag enumeration. |
int sc_MPI_Abort | ( | sc_MPI_Comm | mpicomm, |
int | ecode | ||
) |
Abort an MPI program.
[in] | mpicomm | Communicator across which to abort. |
[in] | ecode | Error code returned to the system. |
int sc_MPI_Barrier | ( | sc_MPI_Comm | mpicomm | ) |
Execute a parallel barrier.
[in] | mpicomm | Valid communicator. |
int sc_MPI_Comm_dup | ( | sc_MPI_Comm | mpicomm, |
sc_MPI_Comm * | dupcomm | ||
) |
Duplicate an MPI communicator.
[in] | mpicomm | Communicator to duplicate. |
[out] | dupcomm | Duplicated communicator. |
int sc_MPI_Comm_free | ( | sc_MPI_Comm * | freecomm | ) |
Free a previously created MPI communicator.
[out] | freecomm | Communicator to free. |
int sc_MPI_Comm_rank | ( | sc_MPI_Comm | mpicomm, |
int * | mpirank | ||
) |
Query rank of an MPI process within a communicator.
[in] | mpicomm | Valid MPI communicator. |
[out] | mpirank | Without MPI this is always 0. |
int sc_MPI_Comm_size | ( | sc_MPI_Comm | mpicomm, |
int * | mpisize | ||
) |
Query size of an MPI communicator.
[in] | mpicomm | Valid MPI communicator. |
[out] | mpisize | Without MPI this is always 1. |
int sc_MPI_Comm_split | ( | sc_MPI_Comm | , |
int | , | ||
int | , | ||
sc_MPI_Comm * | |||
) |
Return the input communicator in lieu of splitting.
int sc_MPI_Comm_split_type | ( | sc_MPI_Comm | mpicomm, |
int | split_type, | ||
int | key, | ||
sc_MPI_Info | info, | ||
sc_MPI_Comm * | newcomm | ||
) |
Wrapper to split an MPI communicator by shared node type.
With MPI and MPICOMMSHARED enabled, call MPI_Comm_split type. Otherwise, call sc_MPI_Comm_split with the rank as color and key. Without MPI, the latter falls back to duplicate the communicator.
int sc_MPI_Error_class | ( | int | errorcode, |
int * | errorclass | ||
) |
Turn an MPI error code into its error class.
When MPI is enabled, we pass version 1.1 errors to MPI_Error_class. When MPI I/O is not enabled, we process file errors outside of MPI. Thus, within libsc, it is always legal to call this function with any errorcode defined above in this header file.
[in] | errorcode | Returned from a direct MPI call or libsc. |
[out] | errorclass | Non-NULL pointer. Filled with matching error class on success. |
int sc_MPI_Error_string | ( | int | errorcode, |
char * | string, | ||
int * | resultlen | ||
) |
Turn MPI error code into a string.
[in] | errorcode | This (MPI) error code is converted. |
[in,out] | string | At least sc_MPI_MAX_ERROR_STRING bytes. |
[out] | resultlen | Length of string on return. |
int sc_MPI_Group_rank | ( | sc_MPI_Group | mpigroup, |
int * | rank | ||
) |
Query rank of an MPI process within a group.
[in] | mpigroup | Valid MPI group. |
[out] | rank | Without MPI this is always 0. |
int sc_MPI_Group_size | ( | sc_MPI_Group | mpigroup, |
int * | size | ||
) |
Query size of an MPI group.
[in] | mpigroup | Valid MPI group. |
[out] | size | Without MPI this is always 1. |
int sc_MPI_Init | ( | int * | argc, |
char *** | argv | ||
) |
MPI initialization.
[in,out] | argc | Command line argument count. |
[in,out] | argv | Command line arguments. |
int sc_mpi_is_enabled | ( | void | ) |
Return whether MPI is configured.
int sc_mpi_is_shared | ( | void | ) |
Return whether MPI supports type split and shared windows.
int sc_MPI_Pack | ( | const void * | inbuf, |
int | incount, | ||
sc_MPI_Datatype | datatype, | ||
void * | outbuf, | ||
int | outsize, | ||
int * | position, | ||
sc_MPI_Comm | comm | ||
) |
Pack several instances of the same datatype into contiguous memory.
[in] | inbuf | Buffer of elements of type datatype. |
[in] | incount | Number of elements in inbuf. |
[in] | datatype | Datatype of elements in inbuf. |
[out] | outbuf | Output buffer in which elements are packed. |
[in] | outsize | Size of output buffer in bytes. |
[in,out] | position | The current position in the output buffer. |
[in] | comm | Valid MPI communicator. |
int sc_MPI_Pack_size | ( | int | incount, |
sc_MPI_Datatype | datatype, | ||
sc_MPI_Comm | comm, | ||
int * | size | ||
) |
Determine space needed to pack several instances of the same datatype.
[in] | incount | Number of elements to pack. |
[in] | datatype | Datatype of elements to pack. |
[in] | comm | Valid MPI communicator. |
[out] | size | Number of bytes needed to packed incount instances of datatype. |
size_t sc_mpi_sizeof | ( | sc_MPI_Datatype | t | ) |
Return the size of MPI datatypes.
[in] | t | MPI datatype. |
int sc_MPI_Type_size | ( | sc_MPI_Datatype | datatype, |
int * | size | ||
) |
Return size of an MPI datatype.
[in] | datatype | Valid MPI datatype. |
[out] | size | Size of MPI datatype in bytes. |
int sc_MPI_Unpack | ( | const void * | inbuf, |
int | insize, | ||
int * | position, | ||
void * | outbuf, | ||
int | outcount, | ||
sc_MPI_Datatype | datatype, | ||
sc_MPI_Comm | comm | ||
) |
Unpack contiguous memory into several instances of the same datatype.
[in] | inbuf | Buffer of packed data. |
[in] | insize | Number of bytes in inbuf |
[in,out] | position | The current position in the input buffer. |
[out] | outbuf | Output buffer in which elements are unpacked. |
[in] | outcount | Number of elements to unpack. |
[in] | datatype | Datatype of elements to be unpacked. |
[in] | comm | Valid MPI communicator. |
double sc_MPI_Wtime | ( | void | ) |
Execute the MPI_Wtime function.