From 74d880e668e0ec091e3a5b1ef9c3271c0d9b5c78 Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 21 Mar 2002 17:38:38 +0000 Subject: Changed the new API according to the final hyperslabbing API spec. This does not affect any existing codes which should use only the current API so far. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@74 10716dce-81a3-4424-a2c8-48026a0d3035 --- src/GetHyperslab.c | 52 ++++++++++++++++++++++++++++++++++------------------ src/Hyperslab.c | 23 ++++++++++++----------- src/Mapping.c | 7 ------- src/PUGHSlab.h | 13 +++++++------ src/PUGHSlabi.h | 1 - 5 files changed, 53 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/GetHyperslab.c b/src/GetHyperslab.c index b1206e2..da835f4 100644 --- a/src/GetHyperslab.c +++ b/src/GetHyperslab.c @@ -29,18 +29,23 @@ CCTK_FILEVERSION(CactusPUGH_PUGHSlab_GetHyperslab_c) /* define this if you want debugging output */ /* #define DEBUG 1 */ +/* define some defaults for optional parameters */ +#define DEFAULT_PROCESSOR 0 +#define DEFAULT_TIMELEVEL 0 /******************************************************************** ******************** Internal Routines ************************ ********************************************************************/ static int GetLocalHyperslab (const cGH *GH, const hslab_mapping_t *mapping, + int proc, int vindex, int timelevel, int hdatatype, void *hdata); static int GetDiagonalFromFrom3D (const cGH *GH, const hslab_mapping_t *mapping, + int proc, int vindex, int timelevel, int hdatatype, @@ -49,6 +54,7 @@ static int GetDiagonalFromFrom3D (const cGH *GH, CCTK_INT Hyperslab_Get (const cGH *GH, CCTK_INT mapping_handle, + CCTK_INT proc, CCTK_INT vindex, CCTK_INT timelevel, CCTK_INT hdatatype, @@ -58,17 +64,23 @@ CCTK_INT Hyperslab_Get (const cGH *GH, hslab_mapping_t *mapping; + if (proc >= CCTK_nProcs (GH)) + { + return (-1); + } + mapping = PUGHSlabi_GetMapping (mapping_handle); if (mapping == NULL) { - return (-1); + return (-2); } /* check mapping consistency */ /*** FIXME ***/ /* get the processor-local hyperslab */ - retval = GetLocalHyperslab (GH, mapping, vindex, timelevel, hdatatype, hdata); + retval = GetLocalHyperslab (GH, mapping, proc, vindex, timelevel, + hdatatype, hdata); return (retval); } @@ -77,10 +89,11 @@ CCTK_INT Hyperslab_Get (const cGH *GH, CCTK_INT Hyperslab_GetList (const cGH *GH, CCTK_INT mapping_handle, CCTK_INT num_arrays, - const CCTK_INT *vindices /* num_arrays */, - const CCTK_INT *timelevels /* num_arrays */, - const CCTK_INT *hdatatypes /* num_arrays */, - void *const *hdata /* num_arrays */) + const CCTK_INT *procs /* num_arrays */, + const CCTK_INT *vindices /* num_arrays */, + const CCTK_INT *timelevels /* num_arrays */, + const CCTK_INT *hdatatypes /* num_arrays */, + void *const *hdata /* num_arrays */) { int i, retval; @@ -88,8 +101,10 @@ CCTK_INT Hyperslab_GetList (const cGH *GH, retval = 0; for (i = 0; i < num_arrays; i++) { - if (Hyperslab_Get (GH, mapping_handle, vindices[i], - timelevels ? timelevels[i] : 0, + if (Hyperslab_Get (GH, mapping_handle, + procs ? procs[i] : DEFAULT_PROCESSOR, + vindices[i], + timelevels ? timelevels[i] : DEFAULT_TIMELEVEL, hdatatypes ? hdatatypes[i] : -1, hdata[i]) == 0) { @@ -202,6 +217,7 @@ CCTK_INT Hyperslab_GetList (const cGH *GH, @@*/ static int GetLocalHyperslab (const cGH *GH, const hslab_mapping_t *mapping, + int proc, int vindex, int timelevel, int hdatatype, @@ -270,8 +286,8 @@ static int GetLocalHyperslab (const cGH *GH, /* diagonals from 3D variables are treated special */ if (mapping->is_diagonal_in_3D) { - retval = GetDiagonalFromFrom3D (GH, mapping, vindex, timelevel, hdatatype, - hdata); + retval = GetDiagonalFromFrom3D (GH, mapping, proc, vindex, timelevel, + hdatatype, hdata); return (retval); } @@ -470,6 +486,7 @@ fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vda static int GetDiagonalFromFrom3D (const cGH *GH, const hslab_mapping_t *mapping, + int proc, int vindex, int timelevel, int hdatatype, @@ -548,7 +565,7 @@ static int GetDiagonalFromFrom3D (const cGH *GH, { /* allocate communication buffers */ myproc = CCTK_MyProc (GH); - if (mapping->target_proc < 0 || mapping->target_proc == myproc) + if (proc < 0 || proc == myproc) { global_npoints = (CCTK_INT *) malloc (nprocs * sizeof (CCTK_INT)); recvcnts = (int *) malloc (2 * nprocs * sizeof (int)); @@ -560,7 +577,7 @@ static int GetDiagonalFromFrom3D (const cGH *GH, } /* gather the number of local points on each processor */ - if (mapping->target_proc < 0) + if (proc < 0) { CACTUS_MPI_ERROR (MPI_Allgather (&local_npoints, 1, PUGH_MPI_INT, global_npoints, 1, PUGH_MPI_INT, @@ -570,12 +587,11 @@ static int GetDiagonalFromFrom3D (const cGH *GH, { CACTUS_MPI_ERROR (MPI_Gather (&local_npoints, 1, PUGH_MPI_INT, global_npoints, 1, PUGH_MPI_INT, - mapping->target_proc, - pughGH->PUGH_COMM_WORLD)); + proc, pughGH->PUGH_COMM_WORLD)); } /* compute the receive count and displacement vectors */ - if (mapping->target_proc < 0 || mapping->target_proc == myproc) + if (proc < 0 || proc == myproc) { for (i = 0; i < nprocs; i++) { @@ -588,7 +604,7 @@ static int GetDiagonalFromFrom3D (const cGH *GH, mpidatatype = PUGH_MPIDataType (pughGH, hdatatype); /* gather the local hyperslab data from each processor */ - if (mapping->target_proc < 0) + if (proc < 0) { CACTUS_MPI_ERROR (MPI_Allgatherv (local_hdata, local_npoints, mpidatatype, hdata, recvcnts, displs, @@ -598,12 +614,12 @@ static int GetDiagonalFromFrom3D (const cGH *GH, { CACTUS_MPI_ERROR (MPI_Gatherv (local_hdata, local_npoints, mpidatatype, hdata, recvcnts, displs, - mpidatatype, mapping->target_proc, + mpidatatype, proc, pughGH->PUGH_COMM_WORLD)); } /* free communication buffers */ - if (mapping->target_proc < 0 || mapping->target_proc == myproc) + if (proc < 0 || proc == myproc) { free (global_npoints); free (recvcnts); diff --git a/src/Hyperslab.c b/src/Hyperslab.c index 5812c1a..040c9ab 100644 --- a/src/Hyperslab.c +++ b/src/Hyperslab.c @@ -702,7 +702,7 @@ int Hyperslab_GetLocalHyperslab (const cGH *GH, @endvar @@*/ int Hyperslab_GetHyperslab (const cGH *GH, - int target_proc, + int dst_proc, int vindex, int vtimelvl, int hdim, @@ -739,14 +739,14 @@ int Hyperslab_GetHyperslab (const cGH *GH, /* get processor information */ myproc = CCTK_MyProc (GH); nprocs = CCTK_nProcs (GH); - if (target_proc >= nprocs) + if (dst_proc >= nprocs) { - CCTK_WARN (1, "Invalid target processor ID"); + CCTK_WARN (1, "Invalid destination processor ID"); return (-1); } - /* target processors must pass pointers to where to store the results */ - if (target_proc < 0 || target_proc == myproc) + /* destination processors must pass pointers to where to store the results */ + if (dst_proc < 0 || dst_proc == myproc) { if (! hdata || ! hsize) { @@ -795,7 +795,7 @@ int Hyperslab_GetHyperslab (const cGH *GH, mapping = Hyperslab_DefineGlobalMappingByIndex (GH, vindex, 1,my_directions, my_global_origin,my_extents, my_downsample_, -1, - target_proc, NULL,my_hsize); + NULL, my_hsize); /* convert result back into int */ hsize[0] = my_hsize[0]; @@ -807,7 +807,8 @@ int Hyperslab_GetHyperslab (const cGH *GH, if (hsize[0] > 0) { *hdata = malloc (hsize[0] * CCTK_VarTypeSize (vinfo.vartype)); - retval = Hyperslab_Get (GH, mapping, vindex, 0, vinfo.vartype, *hdata); + retval = Hyperslab_Get (GH, mapping, dst_proc, vindex, 0, + vinfo.vartype, *hdata); } else { @@ -897,7 +898,7 @@ int Hyperslab_GetHyperslab (const cGH *GH, } vtypesize = CCTK_VarTypeSize (vinfo.vartype); - if (target_proc < 0 || target_proc == myproc) + if (dst_proc < 0 || dst_proc == myproc) { /* copy dimensions for the returned hyperslab */ memcpy (hsize, hsize_global, hdim * sizeof (int)); @@ -940,7 +941,7 @@ int Hyperslab_GetHyperslab (const cGH *GH, mpi_vtype = PUGH_MPIDataType (PUGH_pGH (GH), vinfo.vartype); /* collect the hyperslab chunks from all processors */ - if (target_proc < 0) + if (dst_proc < 0) { CACTUS_MPI_ERROR (MPI_Allgatherv (hdata_local, totals_local, mpi_vtype, chunked_hdata, recvcnts, displs, mpi_vtype, comm)); @@ -949,7 +950,7 @@ int Hyperslab_GetHyperslab (const cGH *GH, { CACTUS_MPI_ERROR (MPI_Gatherv (hdata_local, totals_local, mpi_vtype, chunked_hdata, recvcnts, displs, mpi_vtype, - target_proc, comm)); + dst_proc, comm)); } /* free the processor-local chunk */ @@ -960,7 +961,7 @@ int Hyperslab_GetHyperslab (const cGH *GH, /* Now we got the global hyperslab data in a chunked array. The user wants it unchunked, so let's sort it... */ - if (target_proc < 0 || target_proc == myproc) + if (dst_proc < 0 || dst_proc == myproc) { SortIntoUnchunked (hdim, hsize, totals_global, sizes_global, hdata, chunked_hdata, vtypesize, nprocs); diff --git a/src/Mapping.c b/src/Mapping.c index 8845f56..0a701c1 100644 --- a/src/Mapping.c +++ b/src/Mapping.c @@ -69,7 +69,6 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex ( const CCTK_INT *extent /* dim */, const CCTK_INT *downsample /* dim */, CCTK_INT table_handle, - CCTK_INT target_proc, t_hslabConversionFn conversion_fn, CCTK_INT *hsize /* dim */) { @@ -117,11 +116,6 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex ( "parameters"; retval = -3; } - else if (target_proc >= CCTK_nProcs (GH)) - { - error_msg = "invalid target procesor ID given"; - retval = -4; - } else if ((pughGH = (const pGH *) PUGH_pGH (GH)) == NULL) { error_msg = "no PUGH GH extension registered (PUGH not activated ??)"; @@ -175,7 +169,6 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex ( mapping->hdim = (unsigned int) dim; mapping->vinfo = vinfo; - mapping->target_proc = target_proc; mapping->conversion_fn = conversion_fn; /* assign memory for the other vectors */ diff --git a/src/PUGHSlab.h b/src/PUGHSlab.h index 718edc6..b5640b8 100644 --- a/src/PUGHSlab.h +++ b/src/PUGHSlab.h @@ -27,6 +27,7 @@ typedef void (*t_hslabConversionFn) (const void *src, /* function prototypes */ CCTK_INT Hyperslab_Get (const cGH *GH, CCTK_INT mapping_handle, + CCTK_INT proc, CCTK_INT vindex, CCTK_INT timelevel, CCTK_INT hdatatype, @@ -34,10 +35,11 @@ CCTK_INT Hyperslab_Get (const cGH *GH, CCTK_INT Hyperslab_GetList (const cGH *GH, CCTK_INT mapping_handle, CCTK_INT num_arrays, - const CCTK_INT *vindices /* num_arrays */, - const CCTK_INT *timelevels /* num_arrays */, - const CCTK_INT *hdatatypes /* num_arrays */, - void *const *hdata /* num_arrays */); + const CCTK_INT *procs /* num_arrays */, + const CCTK_INT *vindices /* num_arrays */, + const CCTK_INT *timelevels /* num_arrays */, + const CCTK_INT *hdatatypes /* num_arrays */, + void *const *hdata /* num_arrays */); CCTK_INT Hyperslab_DefineGlobalMappingByIndex ( const cGH *GH, CCTK_INT vindex, @@ -47,7 +49,6 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex ( const CCTK_INT *extent /* hdim */, const CCTK_INT *downsample /* hdim */, CCTK_INT table_handle, - CCTK_INT target_proc, t_hslabConversionFn conversion_fn, CCTK_INT *hsize /* hdim */); CCTK_INT Hyperslab_FreeMapping (CCTK_INT mapping_handle); @@ -65,7 +66,7 @@ int Hyperslab_GetLocalHyperslab (const cGH *GH, int hsize [/*hdim*/], int ghsize [/*hdim*/], int hoffset [/*hdim*/]); int Hyperslab_GetHyperslab (const cGH *GH, - int target_proc, + int proc, int vindex, int vtimelvl, int hdim, diff --git a/src/PUGHSlabi.h b/src/PUGHSlabi.h index 5788b6f..4a3c61c 100644 --- a/src/PUGHSlabi.h +++ b/src/PUGHSlabi.h @@ -24,7 +24,6 @@ extern "C" typedef struct hslab_mapping_t { int handle; - int target_proc; unsigned int hdim; unsigned int vdim; int *vectors; -- cgit v1.2.3