aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2001-12-05 18:21:05 +0000
committertradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2001-12-05 18:21:05 +0000
commitfbea6285fbd71db6049958f03861b6a9d76b9d93 (patch)
tree1663ccae062c98e6665ea155ed2b720fab4cfb85 /src
parent6c9ec7931a8cceb3b41ace899499f519702f0130 (diff)
Bug fixes and more error checking in the new hyperslab API routines.
Still single-processor only. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@65 10716dce-81a3-4424-a2c8-48026a0d3035
Diffstat (limited to 'src')
-rw-r--r--src/GetHyperslab.c134
-rw-r--r--src/Mapping.c373
-rw-r--r--src/PUGHSlabi.h11
3 files changed, 229 insertions, 289 deletions
diff --git a/src/GetHyperslab.c b/src/GetHyperslab.c
index 0c883cc..b6e0af0 100644
--- a/src/GetHyperslab.c
+++ b/src/GetHyperslab.c
@@ -39,11 +39,6 @@ static int GetLocalHyperslab (const cGH *GH,
int timelevel,
int hdatatype,
void *hdata);
-static const char *checkParameters (const cGH *GH,
- const hslab_mapping_t *mapping,
- int vindex,
- int timelevel,
- void *hdata);
/********************************************************************
******************** External Routines ************************
********************************************************************/
@@ -243,12 +238,33 @@ static int GetLocalHyperslab (const cGH *GH,
/* do some plausibility checks */
- errormsg = checkParameters (GH, mapping, vindex, timelevel, hdata);
+ errormsg = NULL;
+ if (! GH || ! mapping || (mapping->totals > 0 && ! hdata))
+ {
+ errormsg = "NULL pointer(s) passed for GH/mapping/hdata arguments";
+ }
+ else if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
+ {
+ errormsg = "Invalid variable index given";
+ }
+ else if (timelevel < 0 || timelevel >= vinfo.numtimelevels)
+ {
+ errormsg = "Invalid timelevel given";
+ }
+ else if (vinfo.grouptype != mapping->vinfo.grouptype ||
+ vinfo.disttype != mapping->vinfo.disttype ||
+ vinfo.dim != mapping->vinfo.dim ||
+ vinfo.stagtype != mapping->vinfo.stagtype)
+ {
+ errormsg = "Group data for template variable in mapping and given variable "
+ "don't match";
+ }
/* immediately return in case of errors */
if (errormsg)
{
- CCTK_WARN (1, errormsg);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "GetLocalHyperslab: %s", errormsg);
return (-1);
}
@@ -258,9 +274,6 @@ static int GetLocalHyperslab (const cGH *GH,
return (0);
}
- /* get the info on the variable to extract a hyperslab from */
- CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo);
-
/* FIXME: hack for getting diagonals from 3D variables
This is calling Gerd's CollectData1D() routine which can
extract non-axis-parallel lines too but is fixed to 3D data. */
@@ -338,7 +351,7 @@ static int GetLocalHyperslab (const cGH *GH,
/* NOTE: the following code assumes startpoint[vdim] < endpoint[vdim] */
vdata = CCTK_VarDataPtrI (GH, timelevel, vindex);
- if (mapping->full_hyperslab && conversion_fn == NULL)
+ if (mapping->is_full_hyperslab && conversion_fn == NULL)
{
memcpy (hdata, vdata, mapping->totals * CCTK_VarTypeSize (vinfo.vartype));
}
@@ -414,7 +427,7 @@ static int GetLocalHyperslab (const cGH *GH,
/* get the byte pointer into the source array */
typed_vdata = (const char *) vdata + point[0];
-#if 0
+#if 1
fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_FullName (vindex));
#endif
for (i = 1; i < vinfo.dim; i++)
@@ -432,7 +445,7 @@ fprintf (stderr, "***** base vdata %p offset %d '%s'\n", vdata, point[0], CCTK_F
}
else
{
-#if 0
+#if 1
fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vdata, typed_hdata);
#endif
memcpy (typed_hdata, typed_vdata, dim0_hsize);
@@ -476,98 +489,3 @@ fprintf (stderr, "***** copying %d bytes from %p tp %p\n", dim0_hsize, typed_vda
return (0);
}
-
-
-static const char *checkParameters (const cGH *GH,
- const hslab_mapping_t *mapping,
- int vindex,
- int timelevel,
- void *hdata)
-{
- cGroup vinfo; /* variable's group info */
-#if 0
- int i, vdim; /* looper */
- int num_directions; /* number of non-zero directions */
-#endif
-
-
- /* check the variable index and timelevel */
- if (vindex < 0 || vindex >= CCTK_NumVars ())
- {
- return ("Invalid variable index");
- }
- if (timelevel < 0 || timelevel >= CCTK_NumTimeLevelsFromVarI (vindex))
- {
- return ("Invalid timelevel");
- }
-
-#if 0
- /* check the passed pointers */
- if (! mapping->global_origin || ! directions || ! extents || ! mapping->downsample ||
- ! hdata || ! hsize)
- {
- return ("NULL pointer(s) passed as parameters");
- }
-
- /* check the extent and downsample parameters */
- for (vdim = 0; vdim < hdim; vdim++)
- {
- if (extents[vdim] == 0)
- {
- return ("Invalid hyperslab extent parameters");
- }
- if (mapping->downsample[vdim] <= 0)
- {
- return ( "Invalid hyperslab downsample parameters");
- }
- }
-#endif
-
- /* get the info on the variable to extract a hyperslab from */
- if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
- {
- return ("Couldn't get group info");
- }
-
- /* check the variable's grouptype */
- if (vinfo.grouptype != CCTK_GF && vinfo.grouptype != CCTK_ARRAY)
- {
- return ("Invalid variable group type");
- }
-
- /* check the hyperslab dimension */
- if (mapping->hdim <= 0 || mapping->hdim > vinfo.dim)
- {
- return ("Invalid hyperslab dimension");
- }
-
-#if 0
- /* check the direction(s) of the hyperslab */
- for (i = 0; i < mapping->hdim; i++)
- {
- for (vdim = 0, num_directions = 0; vdim < vinfo.dim; vdim++)
- {
- if (directions[i * vinfo.dim + vdim])
- {
- num_directions++;
- }
- }
- if (num_directions == 0)
- {
- return ("Given direction vector is a null vector");
- }
- if (num_directions != 1)
- {
- return ("Given direction vector isn't orthogonal");
- }
- }
-#endif
-
- /* check if PUGH is active */
- if (! PUGH_pGH (GH))
- {
- return ("No GH extension for PUGH found. Did you activate thorn PUGH ?");
- }
-
- return (NULL);
-}
diff --git a/src/Mapping.c b/src/Mapping.c
index b53b050..c74be93 100644
--- a/src/Mapping.c
+++ b/src/Mapping.c
@@ -54,32 +54,35 @@ CCTK_FILEVERSION(CactusPUGH_PUGHSlab_Mapping_c)
static int nmapping_list = 0;
static hslab_mapping_t *mapping_list = NULL;
-static int checkFullHyperslab (const pGA *GA,
- const CCTK_INT *origin,
- const CCTK_INT *extent,
- const hslab_mapping_t *mapping);
+static int IsFullHyperslab (const pGA *GA,
+ const CCTK_INT *origin,
+ const CCTK_INT *extent,
+ const hslab_mapping_t *mapping);
CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
const cGH *GH,
CCTK_INT vindex,
- CCTK_INT hdim,
- const CCTK_INT *direction /* vdim*hdim */,
+ CCTK_INT dim,
+ const CCTK_INT *direction /* vdim*dim */,
const CCTK_INT *origin /* vdim */,
- const CCTK_INT *extent /* vdim */,
- const CCTK_INT *downsample /* hdim */,
+ 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 /* hdim */)
+ CCTK_INT *hsize /* dim */)
{
- int i, j, vdim, num_dirs, stagger_type, retval;
+ unsigned int vdim, hdim, num_dirs;
+ int retval;
int stagger_index;
int myproc;
+ int npoints;
hslab_mapping_t *mapping;
const char *error_msg;
- pGH *pughGH; /* pointer to the current pGH */
- pGA *GA; /* the variable's GA structure from PUGH */
+ const pGH *pughGH; /* pointer to the current pGH */
+ const pGA *GA; /* the variable's GA structure from PUGH */
+ cGroup vinfo;
/* PUGHSlab doesn't use table information */
@@ -92,20 +95,26 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
/* check parameter consistency */
retval = 0;
error_msg = NULL;
- vdim = CCTK_GroupDimFromVarI (vindex);
- if (vdim <= 0)
+ if (CCTK_GroupData (CCTK_GroupIndexFromVarI (vindex), &vinfo) < 0)
{
error_msg = "invalid variable index given";
retval = -1;
}
- else if (hdim < 0 || hdim > vdim)
+ else if (vinfo.grouptype != CCTK_GF && vinfo.grouptype != CCTK_ARRAY)
+ {
+ error_msg = "invalid variable group type given "
+ "(not a CCTK_GF or CCTK_ARRAY type)";
+ retval = -2;
+ }
+ else if (dim < 0 || dim > vinfo.dim)
{
error_msg = "invalid hyperslab dimension given";
retval = -2;
}
- else if (hsize == NULL)
+ else if (! direction || ! origin || ! extent || ! hsize)
{
- error_msg = "NULL pointer passed for hyperslab size return parameter";
+ error_msg = "NULL pointer(s) passed for direction/origin/extent/hsize "
+ "parameters";
retval = -3;
}
else if (target_proc >= CCTK_nProcs (GH))
@@ -113,19 +122,28 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
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 ??)";
+ retval = -4;
+ }
else
{
- for (i = 0; i < vdim; i++)
+ for (vdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- retval |= origin[i] < 0 || extent[i] <= 0;
- if (downsample && i < hdim)
+ retval |= origin[vdim] < 0;
+ if (vdim < (unsigned int) dim)
{
- retval |= downsample[i] <= 0;
+ retval |= extent[vdim] <= 0;
+ if (downsample)
+ {
+ retval |= downsample[vdim] <= 0;
+ }
}
}
if (retval)
{
- error_msg = "invalid hyperslab origin/extent/downsample given";
+ error_msg = "invalid hyperslab origin/extent/downsample vectors given";
retval = -5;
}
}
@@ -134,7 +152,7 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
mapping = (hslab_mapping_t *) malloc (sizeof (hslab_mapping_t));
if (mapping)
{
- mapping->vectors = (int *) malloc ((6*vdim + (2+vdim)*hdim) * sizeof (int));
+ mapping->vectors = (int *) malloc ((6*vinfo.dim + 2*dim) * sizeof (int));
}
if (mapping == NULL || mapping->vectors == NULL)
{
@@ -155,54 +173,64 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
return (retval);
}
+ mapping->hdim = (unsigned int) dim;
+ mapping->vinfo = vinfo;
+ mapping->target_proc = target_proc;
+ mapping->conversion_fn = conversion_fn;
+
/* assign memory for the other vectors */
- mapping->local_startpoint = mapping->vectors + 0*vdim;
- mapping->local_endpoint = mapping->vectors + 1*vdim;
- mapping->global_startpoint = mapping->vectors + 2*vdim;
- mapping->global_endpoint = mapping->vectors + 3*vdim;
- mapping->do_dir = mapping->vectors + 4*vdim;
- mapping->downsample = mapping->vectors + 5*vdim;
- mapping->local_hsize = mapping->vectors + 6*vdim + 0*hdim;
- mapping->global_hsize = mapping->vectors + 6*vdim + 1*hdim;
- mapping->directions = mapping->vectors + 6*vdim + 2*hdim;
+ mapping->local_startpoint = mapping->vectors + 0*vinfo.dim;
+ mapping->local_endpoint = mapping->vectors + 1*vinfo.dim;
+ mapping->global_startpoint = mapping->vectors + 2*vinfo.dim;
+ mapping->global_endpoint = mapping->vectors + 3*vinfo.dim;
+ mapping->do_dir = mapping->vectors + 4*vinfo.dim;
+ mapping->downsample = mapping->vectors + 5*vinfo.dim;
+ mapping->local_hsize = mapping->vectors + 6*vinfo.dim + 0*dim;
+ mapping->global_hsize = mapping->vectors + 6*vinfo.dim + 1*dim;
/* check direction vectors */
- for (j = 0; j < hdim; j++)
+ for (hdim = 0; hdim < mapping->hdim; hdim++)
{
num_dirs = 0;
- for (i = 0; i < vdim; i++)
+ for (vdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- if (direction[j*vdim + i])
+ if (direction[hdim*vinfo.dim + vdim])
{
- mapping->directions[i] = 1;
num_dirs++;
}
}
- mapping->is_diagonal_in_3D = num_dirs == 3 && hdim == 1;
+ if (num_dirs == 0)
+ {
+ free (mapping->vectors); free (mapping);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Hyperslab_DefineGlobalMappingByIndex: %d-direction vector "
+ "is a null vector", hdim);
+ return (-7);
+ }
+
+ mapping->is_diagonal_in_3D = num_dirs == 3 && mapping->hdim == 1;
if (num_dirs != 1 && ! mapping->is_diagonal_in_3D)
{
- free (mapping->vectors);
- free (mapping);
+ free (mapping->vectors); free (mapping);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Hyperslab_DefineGlobalMappingByIndex: %d-direction vector "
- "isn't axis-orthogonal", j);
+ "isn't axis-orthogonal", hdim);
return (-7);
}
}
- for (i = 0; i < vdim; i++)
+ for (vdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- mapping->do_dir[i] = 0;
- for (j = 0; j < hdim; j++)
+ mapping->do_dir[vdim] = 0;
+ for (hdim = 0; hdim < mapping->hdim; hdim++)
{
- if (direction[j*vdim + i])
+ if (direction[hdim*vinfo.dim + vdim])
{
- mapping->do_dir[i]++;
+ mapping->do_dir[vdim]++;
}
}
- if (mapping->do_dir[i] > 1)
+ if (mapping->do_dir[vdim] > 1)
{
- free (mapping->vectors);
- free (mapping);
+ free (mapping->vectors); free (mapping);
CCTK_WARN (1, "Hyperslab_DefineGlobalMappingByIndex: duplicate direction "
"vectors given");
return (-8);
@@ -210,234 +238,229 @@ CCTK_INT Hyperslab_DefineGlobalMappingByIndex (
}
/* get the pGH pointer and the variable's GA structure */
- pughGH = PUGH_pGH (GH);
- GA = (pGA *) pughGH->variables[vindex][0];
+ GA = (const pGA *) pughGH->variables[vindex][0];
myproc = CCTK_MyProc (GH);
- stagger_type = CCTK_GroupStaggerIndexGI (CCTK_GroupIndexFromVarI (vindex));
/* check extent */
- for (i = j = 0; i < vdim; i++)
+ for (vdim = hdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- if (mapping->do_dir[i])
+ if (mapping->do_dir[vdim] && hdim < mapping->hdim)
{
- if (origin[i] + extent[j] > GA->extras->nsize[i])
+ if (origin[vdim] + extent[hdim] > GA->extras->nsize[vdim])
{
- free (mapping->vectors);
- free (mapping);
+ free (mapping->vectors); free (mapping);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Hyperslab_DefineGlobalMappingByIndex: extent in "
- "%d-direction exceeds grid size", j);
+ "%d-direction exceeds grid size", hdim);
return (-8);
}
- j++;
+ hdim++;
}
}
/* now fill out the hyperslab mapping structure */
- for (i = j = 0; i < vdim; i++)
+ for (vdim = hdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- mapping->downsample[i] = 1;
+ mapping->downsample[vdim] = 1;
- if (mapping->do_dir[i])
+ if (mapping->do_dir[vdim] && hdim < mapping->hdim)
{
if (downsample)
{
- mapping->downsample[i] = downsample[j];
+ mapping->downsample[vdim] = downsample[hdim];
}
- mapping->global_hsize[j] = extent[j] / mapping->downsample[i];
- if (extent[j] % mapping->downsample[i])
+ mapping->global_hsize[hdim] = extent[hdim] / mapping->downsample[vdim];
+ if (extent[hdim] % mapping->downsample[vdim])
{
- mapping->global_hsize[j]++;
+ mapping->global_hsize[hdim]++;
}
/* subtract ghostzones for periodic BC */
- if (GA->connectivity->perme[i])
+ if (GA->connectivity->perme[vdim])
{
- mapping->global_hsize[j] -= 2 * GA->extras->nghostzones[i];
+ mapping->global_hsize[hdim] -= 2 * GA->extras->nghostzones[vdim];
}
- j++;
+ hdim++;
}
}
/* check whether the full local data patch was requested as hyperslab */
- mapping->full_hyperslab = checkFullHyperslab (GA, origin, extent, mapping);
- if (mapping->full_hyperslab)
+ mapping->is_full_hyperslab = IsFullHyperslab (GA, origin, extent, mapping);
+ if (mapping->is_full_hyperslab)
{
- memset (mapping->local_startpoint, 0, vdim * sizeof (int));
- memcpy (mapping->local_endpoint, GA->extras->lnsize, vdim * sizeof (int));
+ memset (mapping->local_startpoint, 0, vinfo.dim * sizeof (int));
+ memcpy (mapping->local_endpoint, GA->extras->lnsize, vinfo.dim*sizeof(int));
mapping->totals = GA->extras->npoints;
}
+ else if (mapping->is_diagonal_in_3D)
+ {
+ /* diagonals in 3D are special: global_hsize is minimum of grid extents */
+ mapping->global_hsize[0] = GH->cctk_gsh[0];
+ if (mapping->global_hsize[0] > GH->cctk_gsh[1])
+ {
+ mapping->global_hsize[0] = GH->cctk_gsh[1];
+ }
+ if (mapping->global_hsize[0] > GH->cctk_gsh[2])
+ {
+ mapping->global_hsize[0] = GH->cctk_gsh[2];
+ }
+ mapping->totals = mapping->global_hsize[0];
+ }
else
{
/* compute the global endpoint */
- for (i = j = 0; i < vdim; i++)
+ for (vdim = hdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- mapping->global_endpoint[i] = origin[i] +
- mapping->do_dir[i] ? extent[j++] : 1;
+ mapping->global_endpoint[vdim] = origin[vdim] +
+ (mapping->do_dir[vdim] ? extent[hdim++] : 1);
}
/* compute this processor's global startpoint from the global ranges */
- for (i = 0; i < vdim; i++)
+ for (vdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- stagger_index = CCTK_StaggerDirIndex (i, stagger_type);
+ stagger_index = CCTK_StaggerDirIndex (vdim, vinfo.stagtype);
- if (origin[i] < MY_GLOBAL_EP (GA->extras, myproc, stagger_index, i))
+ if (origin[vdim] < MY_GLOBAL_EP (GA->extras, myproc, stagger_index, vdim))
{
- mapping->global_startpoint[i] = origin[i];
- if (origin[i] < MY_GLOBAL_SP (GA->extras, myproc, stagger_index, i))
+ mapping->global_startpoint[vdim] = origin[vdim];
+ if (origin[vdim] < MY_GLOBAL_SP (GA->extras, myproc,stagger_index,vdim))
{
- int npoints;
-
- npoints = (MY_GLOBAL_SP (GA->extras, myproc, stagger_index, i)
- - origin[i]) / mapping->downsample[i];
- if ((MY_GLOBAL_SP (GA->extras, myproc, stagger_index, i)
- - origin[i]) % mapping->downsample[i])
+ npoints = (MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim)
+ - origin[vdim]) / mapping->downsample[vdim];
+ if ((MY_GLOBAL_SP (GA->extras, myproc, stagger_index, vdim)
+ - origin[vdim]) % mapping->downsample[vdim])
{
npoints++;
}
- mapping->global_startpoint[i] += npoints * mapping->downsample[i];
+ mapping->global_startpoint[vdim] += npoints*mapping->downsample[vdim];
}
}
else
{
- mapping->global_startpoint[i] = -1;
+ mapping->global_startpoint[vdim] = -1;
}
}
/* compute the local start- and endpoint from the global ranges */
mapping->totals = 1;
- for (i = j = 0; i < vdim; i++)
+ for (vdim = hdim = 0; vdim < (unsigned int) vinfo.dim; vdim++)
{
- stagger_index = CCTK_StaggerDirIndex (i, stagger_type);
+ stagger_index = CCTK_StaggerDirIndex (vdim, vinfo.stagtype);
- if (mapping->global_startpoint[i] >= 0 &&
- mapping->global_startpoint[i] < MY_GLOBAL_EP (GA->extras, myproc,
- stagger_index, i))
+ if (mapping->global_startpoint[vdim] >= 0 &&
+ mapping->global_startpoint[vdim] < MY_GLOBAL_EP (GA->extras, myproc,
+ stagger_index,vdim))
{
- mapping->local_startpoint[i] = mapping->global_startpoint[i] -
- GA->extras->lb[myproc][i];
+ mapping->local_startpoint[vdim] = mapping->global_startpoint[vdim] -
+ GA->extras->lb[myproc][vdim];
}
else
{
- mapping->local_startpoint[i] = -1;
+ mapping->local_startpoint[vdim] = -1;
}
- if (mapping->global_endpoint[i] > MY_GLOBAL_SP (GA->extras, myproc,
- stagger_index, i))
+ if (mapping->global_endpoint[vdim] > MY_GLOBAL_SP (GA->extras, myproc,
+ stagger_index, vdim))
{
- mapping->local_endpoint[i] = MIN (MY_LOCAL_EP (GA->extras, stagger_index, i),
- mapping->global_endpoint[i] - GA->extras->lb[myproc][i]);
+ mapping->local_endpoint[vdim] =
+ MIN (MY_LOCAL_EP (GA->extras, stagger_index, vdim),
+ mapping->global_endpoint[vdim] -
+ GA->extras->lb[myproc][vdim]);
}
else
{
- mapping->local_endpoint[i] = -1;
+ mapping->local_endpoint[vdim] = -1;
}
+#define DEBUG 1
#ifdef DEBUG
- printf ("direction %d: local ranges[%d, %d)\n",
- i, mapping->local_startpoint[i], mapping->local_endpoint[i]);
+ printf ("direction %d: global ranges [%d, %d), local ranges[%d, %d)\n",
+ vdim,
+ mapping->global_startpoint[vdim], mapping->global_endpoint[vdim],
+ mapping->local_startpoint[vdim], mapping->local_endpoint[vdim]);
#endif
- if (mapping->local_endpoint[i] < 0 || mapping->local_startpoint[i] < 0)
+ if (mapping->local_endpoint[vdim] < 0 ||
+ mapping->local_startpoint[vdim] < 0)
{
mapping->totals = 0;
- mapping->local_endpoint[i] = mapping->local_startpoint[i];
+ mapping->local_endpoint[vdim] = mapping->local_startpoint[vdim];
}
- if (mapping->do_dir[i])
+ if (mapping->do_dir[vdim])
{
/* compute the local size in each hyperslab dimension */
- mapping->local_hsize[j] = (mapping->local_endpoint[i] -
- mapping->local_startpoint[i]) /
- mapping->downsample[i];
- if ((mapping->local_endpoint[i] - mapping->local_startpoint[i]) %
- mapping->downsample[i])
+ mapping->local_hsize[hdim] = (mapping->local_endpoint[vdim] -
+ mapping->local_startpoint[vdim]) /
+ mapping->downsample[vdim];
+ if ((mapping->local_endpoint[vdim] - mapping->local_startpoint[vdim]) %
+ mapping->downsample[vdim])
{
- mapping->local_hsize[j]++;
+ mapping->local_hsize[hdim]++;
}
- mapping->totals *= mapping->local_hsize[j];
- j++;
+ mapping->totals *= mapping->local_hsize[hdim];
+ hdim++;
}
}
- } /* end of else branch for 'if (mapping->full_hyperslab)' */
-
- /* diagonals in 3D are special: global_hsize is minimum of grid extents */
- if (mapping->is_diagonal_in_3D)
- {
- mapping->global_hsize[0] = GH->cctk_gsh[0];
- if (mapping->global_hsize[0] > GH->cctk_gsh[1])
- {
- mapping->global_hsize[0] = GH->cctk_gsh[1];
- }
- if (mapping->global_hsize[0] > GH->cctk_gsh[2])
- {
- mapping->global_hsize[0] = GH->cctk_gsh[2];
- }
- mapping->totals = mapping->global_hsize[0];
- }
+ } /* end of else branch for 'if (mapping->is_full_hyperslab)' */
#ifdef DEBUG
printf ("total number of hyperslab data points: %d\n", mapping->totals);
#endif
- mapping->hdim = hdim;
- mapping->vdim = vdim;
- mapping->target_proc = target_proc;
- mapping->conversion_fn = conversion_fn;
-
- /* add this mapping to the mapping list */
- if (mapping_list)
- {
- mapping_list->prev = mapping;
- }
- mapping->prev = NULL;
- mapping->next = mapping_list;
- mapping_list = mapping;
-
- mapping->handle = nmapping_list++;
-
- /* set the global hsize in the return arguments */
- if (hsize)
- {
- for (j = 0; j < hdim; j++)
- {
- hsize[j] = mapping->global_hsize[j];
- }
- }
-
#if 0
if (mapping->totals > 0)
{
/* if requested, compute the offsets into the global hyperslab */
if (hoffset_global)
{
- for (i = j = 0; i < vdim; i++)
+ for (i = hdim = 0; i < vinfo.dim; i++)
{
if (mapping->do_dir[i])
{
- if (mapping->full_hyperslab)
+ if (mapping->is_full_hyperslab)
{
- hoffset_global[j] = GA->extras->lb[myproc][i];
+ hoffset_global[hdim] = GA->extras->lb[myproc][i];
}
else
{
- hoffset_global[j] = (mapping->global_startpoint[i] -
+ hoffset_global[hdim] = (mapping->global_startpoint[i] -
origin[i]) / mapping->downsample[i];
if (GA->connectivity->perme[i])
{
- hoffset_global[j] -= GA->extras->nghostzones[i];
+ hoffset_global[hdim] -= GA->extras->nghostzones[i];
}
}
#ifdef DEBUG
printf ("hoffset_global, hsize in direction %d: %d, %d\n",
- j, hoffset_global[j], mapping->local_hsize[j]);
+ hdim, hoffset_global[hdim], mapping->local_hsize[hdim]);
#endif
- j++;
+ hdim++;
}
}
}
}
#endif
+ /* add this mapping to the mapping list */
+ if (mapping_list)
+ {
+ mapping_list->prev = mapping;
+ }
+ mapping->prev = NULL;
+ mapping->next = mapping_list;
+ mapping_list = mapping;
+
+ mapping->handle = nmapping_list++;
+
+ /* set the global hsize in the return arguments */
+ if (hsize)
+ {
+ for (hdim = 0; hdim < mapping->hdim; hdim++)
+ {
+ hsize[hdim] = mapping->global_hsize[hdim];
+ }
+ }
+
return (mapping->handle);
}
@@ -493,27 +516,25 @@ hslab_mapping_t *PUGHSlabi_GetMapping (int mapping_handle)
}
-static int checkFullHyperslab (const pGA *GA,
- const CCTK_INT *origin,
- const CCTK_INT *extent,
- const hslab_mapping_t *mapping)
+static int IsFullHyperslab (const pGA *GA,
+ const CCTK_INT *origin,
+ const CCTK_INT *extent,
+ const hslab_mapping_t *mapping)
{
- int i;
- int is_full_hyperslab;
+ int i, retval;
- is_full_hyperslab = mapping->hdim == GA->extras->dim;
-
- if (is_full_hyperslab)
+ retval = mapping->hdim == (unsigned int) GA->extras->dim;
+ if (retval)
{
for (i = 0; i < GA->extras->dim; i++)
{
- is_full_hyperslab &= (origin[i] == 0);
- is_full_hyperslab &= (extent[i] <= 0);
- is_full_hyperslab &= (mapping->downsample[i] <= 1);
- is_full_hyperslab &= (GA->connectivity->perme[i] == 0);
+ retval &= (origin[i] == 0);
+ retval &= (extent[i] <= 0);
+ retval &= (mapping->downsample[i] <= 1);
+ retval &= (GA->connectivity->perme[i] == 0);
}
}
- return (is_full_hyperslab);
+ return (retval);
}
diff --git a/src/PUGHSlabi.h b/src/PUGHSlabi.h
index 47f8907..5788b6f 100644
--- a/src/PUGHSlabi.h
+++ b/src/PUGHSlabi.h
@@ -12,6 +12,7 @@
#ifndef _PUGHSLAB_PUGHSLABI_H_
#define _PUGHSLAB_PUGHSLABI_H_
+#include "cctk_Groups.h"
#include "PUGHSlab.h"
#ifdef __cplusplus
@@ -24,8 +25,8 @@ typedef struct hslab_mapping_t
{
int handle;
int target_proc;
- int hdim;
- int vdim;
+ unsigned int hdim;
+ unsigned int vdim;
int *vectors;
int *local_startpoint; /* vdim */
int *local_endpoint; /* vdim */
@@ -35,12 +36,12 @@ typedef struct hslab_mapping_t
int *downsample; /* vdim */
int *global_hsize; /* hdim */
int *local_hsize; /* hdim */
- int *directions; /* hdim * vdim */
- int is_diagonal_in_3D;
unsigned int totals;
+ int is_full_hyperslab;
+ int is_diagonal_in_3D;
t_hslabConversionFn conversion_fn;
struct hslab_mapping_t *prev, *next;
- int full_hyperslab;
+ cGroup vinfo;
} hslab_mapping_t;