From 9186e24e77ab6b825e56d21191ec36bc9ea8d0e7 Mon Sep 17 00:00:00 2001 From: schnetter Date: Tue, 10 May 2005 08:15:24 +0000 Subject: Introduce new function Slab_MultiTransfer that transfers slabs of several grid functions at once. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Slab/trunk@40 2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8 --- src/slab.c | 168 ++++++++++++++++++++++++++++++++++++++++++++----------------- src/slab.h | 10 ++++ 2 files changed, 132 insertions(+), 46 deletions(-) diff --git a/src/slab.c b/src/slab.c index f95f750..f4cea36 100644 --- a/src/slab.c +++ b/src/slab.c @@ -19,7 +19,7 @@ #undef CHECK /* Omit all self-checks? (Overrides CHECK) */ -#undef NDEBUG +#define NDEBUG /* Byte value for poison checks: use 255 for nan, or e.g. 113 for a large value */ @@ -294,13 +294,19 @@ get_mpi_comm (const cGH * restrict const cctkGH) { #ifdef CCTK_MPI # if defined CARPET_CARPET || defined CARPETORIG_CARPET - if (CCTK_IsThornActive ("Carpet")) { - return CarpetMPIComm (); + { + static int Carpet_active = -1; + if (Carpet_active == -1) Carpet_active = CCTK_IsThornActive ("Carpet"); + assert (Carpet_active >= 0); + if (Carpet_active) return CarpetMPIComm (); } # endif # if defined CACTUSPUGH_PUGH - if (CCTK_IsThornActive ("PUGH")) { - return PUGH_pGH(cctkGH)->PUGH_COMM_WORLD; + { + static int PUGH_active = -1; + if (PUGH_active == -1) PUGH_active = CCTK_IsThornActive ("PUGH"); + assert (PUGH_active >= 0); + if (PUGH_active) return PUGH_pGH(cctkGH)->PUGH_COMM_WORLD; } # endif return MPI_COMM_WORLD; @@ -612,14 +618,15 @@ static void bbox_xform (struct bbox * restrict const ydst, -int Slab_Transfer (cGH const * restrict const cctkGH, - int const dim, - struct xferinfo const * restrict const xferinfo, - int const options, - int const srctype, - void const * const srcptr, - int const dsttype, - void * const dstptr) +int Slab_MultiTransfer (cGH const * const cctkGH, + int const dim, + struct xferinfo const * const xferinfo, + int const options, + int const nvars, + int const * const srctypes, + void const * const * const srcptrs, + int const * const dsttypes, + void * const * const dstptrs) { struct info * restrict info; size_t srclentot, dstlentot; @@ -628,8 +635,10 @@ int Slab_Transfer (cGH const * restrict const cctkGH, struct bbox * restrict srcdetail; struct bbox * restrict dstdetail; + int * restrict srcelems; int * restrict srccount; int * restrict srcoffset; + int * restrict dstelems; int * restrict dstcount; int * restrict dstoffset; @@ -642,6 +651,7 @@ int Slab_Transfer (cGH const * restrict const cctkGH, int size, rank; MPI_Datatype srcdatatype, dstdatatype; + int var; int i, j, k; int n; int d; @@ -650,10 +660,15 @@ int Slab_Transfer (cGH const * restrict const cctkGH, assert (cctkGH); assert (dim >= 0); assert (xferinfo); - assert (srctype >= 0); -/* assert (srcptr); */ - assert (dsttype >= 0); -/* assert (dstptr); */ + assert (nvars >= 0); + assert (nvars==0 || srctypes); + for (var=0; var= 0); + assert (nvars==0 || srcptrs); +/* for (var=0; var= 0); + assert (nvars==0 || dstptrs); +/* for (var=0; var= 1); + int const srctype = srctypes[0]; + int const dsttype = dsttypes[0]; + for (var=0; var 0); @@ -887,29 +909,32 @@ int Slab_Transfer (cGH const * restrict const cctkGH, } } + srcelems = malloc (size * sizeof *srcelems); + assert (srcelems); srccount = malloc (size * sizeof *srccount); assert (srccount); srcoffset = malloc ((size + 1) * sizeof *srcoffset); assert (srcoffset); srcoffset[0] = 0; for (n = 0; n < size; ++n) { - srccount[n] = 1; + srcelems[n] = 1; for (d=0; d=0 && srcindi=0 && srcindj=0 && srcindk=0 && srcindi=0 && srcindj=0 && srcindk=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk