From faa526b62885a9e9f6ecad7c928cb4c89df39f66 Mon Sep 17 00:00:00 2001 From: schnetter Date: Wed, 23 Oct 2002 13:21:35 +0000 Subject: Added "TODO" point. Added a bit more documentation. Added some restrict qualifiers. git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Slab/trunk@7 2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8 --- doc/documentation.tex | 11 ++++++++--- src/slab.c | 44 ++++++++++++++++++++++++++------------------ src/slab.h | 14 +++++++------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/doc/documentation.tex b/doc/documentation.tex index 4c5b203..7ccf999 100644 --- a/doc/documentation.tex +++ b/doc/documentation.tex @@ -100,11 +100,12 @@ The Slab thorn provides generic slabbing facilities. A slab is a sub-array of another array. Both can be multidimensional, and the slab can have a non-unit stride. The Slab thorn provides a routine to copy a slab from one array into a slab of another array, while -possibly transposing or inverting the slab. This combines get-slab -and put-slab interfaces. +possibly transposing or inverting the slab. The distribution of the +arrays can be specified freely, so that the Slab thorn can also be +used to interface to non-Cactus libraries with different data layouts. The Slab thorn is driver independent, i.e.\ not tied to PUGH or -Carpet, and does not require MPI. +Carpet, and does not require MPI for single-processor configurations. \end{abstract} % The following sections are suggestive only. @@ -112,6 +113,10 @@ Carpet, and does not require MPI. \section{Introduction} +A \emph{Slab} is a subarray of another array. This concept is used in +many places with many different names. Fortran has so-called ``array +subscript triplets'', which are the same thing. + \section{Physical System} \section{Numerical Implementation} diff --git a/src/slab.c b/src/slab.c index af5e8f9..27f6258 100644 --- a/src/slab.c +++ b/src/slab.c @@ -7,6 +7,7 @@ Test slabbing without MPI Allow using / not setting the ghost zones Allow not using / not setting the boundaries + Allow different ghost zones at the lower and upper boundary */ @@ -155,6 +156,23 @@ MPI_Alltoallv (void * sendbuf, int * sendcnt, int * sendoff, int sendtype, +static MPI_Comm get_mpi_comm (cGH * restrict const cctkGH) +{ +#ifdef CCTK_MPI +# if defined CARPET_CARPET + return CarpetMPIComm (); +# elif defined CACTUSPUGH_PUGH + return PUGH_pGH(cctkGH)->PUGH_COMM_WORLD; +# else +# error "No supported driver thorn included" +# endif +#else + return 0; +#endif +} + + + struct bbox { int off, len, str; }; @@ -337,13 +355,13 @@ static void bbox_xform (struct bbox * restrict const ydst, -int Slab_Transfer (cGH * const cctkGH, - int const dim, - struct xferinfo const * const xferinfo, - int const srctype, - void const * const srcptr, - int const dsttype, - void * const dstptr) +int Slab_Transfer (cGH * restrict const cctkGH, + int const dim, + struct xferinfo const * const xferinfo, + int const srctype, + void const * const srcptr, + int const dsttype, + void * const dstptr) { struct info * restrict info; size_t srclentot, dstlentot; @@ -426,17 +444,7 @@ int Slab_Transfer (cGH * const cctkGH, -#ifdef CCTK_MPI -# if defined CARPET_CARPET - comm = CarpetMPIComm (); -# elif defined CACTUSPUGH_PUGH - comm = PUGH_pGH(cctkGH)->PUGH_COMM_WORLD; -# else -# error "No supported driver thorn included" -# endif -#else - comm = 0; -#endif + comm = get_mpi_comm (cctkGH); ifcheck { ifdebug fflush (stdout); diff --git a/src/slab.h b/src/slab.h index 4e1051b..b79af0a 100644 --- a/src/slab.h +++ b/src/slab.h @@ -83,12 +83,12 @@ struct xferinfo { The source and the destination arrays may be the same. */ -int Slab_Transfer (cGH * const cctkGH, - int const dim, - struct xferinfo const * const xferinfo, - int const srctype, - void const * const srcptr, - int const dsttype, - void * const dstptr); +int Slab_Transfer (cGH * restrict const cctkGH, + int const dim, + struct xferinfo const * const xferinfo, + int const srctype, + void const * const srcptr, + int const dsttype, + void * const dstptr); #endif /* defined SLAB_H */ -- cgit v1.2.3