diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-07-15 12:11:40 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-07-15 13:30:25 -0500 |
commit | eab9c028bf17183891b2687d028eaefa67a37c2a (patch) | |
tree | 51abc65069742967a6d41c2d81ba983ac9cb6dc0 /Carpet/CarpetLib/src | |
parent | b962688a49b6a86b1dc6d52ce28c195671fc06a6 (diff) |
Move implementation of create_mpi_datatype from CarpetInterp2 to CarpetLib
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r-- | Carpet/CarpetLib/src/dist.cc | 21 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/dist.hh | 13 |
2 files changed, 34 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/dist.cc b/Carpet/CarpetLib/src/dist.cc index 7ac6f73f6..c870990fb 100644 --- a/Carpet/CarpetLib/src/dist.cc +++ b/Carpet/CarpetLib/src/dist.cc @@ -53,6 +53,27 @@ namespace dist { MPI_Finalize (); } + + + // Create an MPI datatype from a C datatype description + void create_mpi_datatype (size_t const count, + mpi_struct_descr_t const descr[], + MPI_Datatype & newtype) + { + int blocklengths[count]; + MPI_Aint displacements[count]; + MPI_Datatype types[count]; + for (size_t n=0; n<count; ++n) { + blocklengths [n] = descr[n].blocklength; + displacements[n] = descr[n].displacement; + types [n] = descr[n].type; + } + MPI_Type_struct (count, blocklengths, displacements, types, &newtype); + MPI_Type_commit (&newtype); + } + + + void checkpoint (const char* file, int line) { DECLARE_CCTK_PARAMETERS; if (verbose) { diff --git a/Carpet/CarpetLib/src/dist.hh b/Carpet/CarpetLib/src/dist.hh index ae7953f99..cf4cbd70c 100644 --- a/Carpet/CarpetLib/src/dist.hh +++ b/Carpet/CarpetLib/src/dist.hh @@ -30,6 +30,19 @@ namespace dist { void pseudoinit (MPI_Comm const c); void finalize (); + // Create MPI datatypes from C structures + struct mpi_struct_descr_t { + int blocklength; + MPI_Aint displacement; + MPI_Datatype type; + }; + + void create_mpi_datatype (size_t const count, + mpi_struct_descr_t const descr[], + MPI_Datatype & newtype); + + + // Debugging output #define CHECKPOINT dist::checkpoint(__FILE__, __LINE__) void checkpoint (const char* file, int line); |