aboutsummaryrefslogtreecommitdiff
path: root/src/NewHyperslab.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/NewHyperslab.c')
-rw-r--r--src/NewHyperslab.c153
1 files changed, 80 insertions, 73 deletions
diff --git a/src/NewHyperslab.c b/src/NewHyperslab.c
index 7e86a21..ecf6fba 100644
--- a/src/NewHyperslab.c
+++ b/src/NewHyperslab.c
@@ -46,14 +46,38 @@ CCTK_FILEVERSION(CactusPUGH_PUGHSlab_Hyperslab_c)
/*** prototypes of routines defined in this source file ***/
/* routine to check parameters passed to the Hyperslab routines */
+int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
+ int hdim, int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
+ void **hdata,
+ int hsize[/* hdim */],
+ int hsize_global[/* hdim */],
+ int hoffset_global[/* hdim */]);
+int NewHyperslab_GetHyperslab (cGH *GH,
+ int target_proc,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
+ void **hdata,
+ int hsize[/* hdim */]);
static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
int hdim,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/]);
+ int hsize[/* hdim */]);
/*** external routines ***/
/* Gerd's routine to get 1D lines from a 3D array */
@@ -111,12 +135,7 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl,
@endvar
@var directions
@vdesc directions which span the hyperslab
- This is the direction vector for 1D hyperslabs,
- or the normal vector of the 2 lowest dimensions
- for hyperslabs of higher dimensions.
- If the hyperslab is of same dimensionality as the variable
- the directions vector is ignored.
- @vtype const int[dimensions of vindex]
+ @vtype const int[hdim times dimensions of vindex]
@vio in
@endvar
@var extents
@@ -156,14 +175,14 @@ int Hyperslab_CollectData1D (cGH *GH, int vindex, int vtimelvl,
int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
int hdim, int htype,
PUGHSlab_conversion_fn conversion_fn,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/],
- int hsize_global[/*hdim*/],
- int hoffset_global[/*hdim*/])
+ int hsize[/* hdim */],
+ int hsize_global[/* hdim */],
+ int hoffset_global[/* hdim */])
{
int *point; /* looper over hyperslab dimensions */
int *startpoint, /* hyperslab's local start and endpoint */
@@ -245,26 +264,12 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
points_per_dim = point + 7*vinfo.dim;
/* get the actual directions in which to spawn the hyperslab */
- /* Note: hdim == 1 the normal vector is the directions vector itself
- hdim < vdim the normal vector is the negated directions vector
- hdim == vdim the normal vector is completely ignored,
- and all directions are selected */
- if (hdim == 1)
- {
- memcpy (do_dir, directions, vinfo.dim * sizeof (int));
- }
- else if (hdim < vinfo.dim)
- {
- for (vdim = 0; vdim < vinfo.dim; vdim++)
- {
- do_dir[vdim] = ! directions[vdim];
- }
- }
- else
+ memcpy (do_dir, directions, vinfo.dim * sizeof (int));
+ for (i = 1; i < hdim; i++)
{
for (vdim = 0; vdim < vinfo.dim; vdim++)
{
- do_dir[vdim] = 1;
+ do_dir[vdim] |= directions[i * vinfo.dim + vdim];
}
}
@@ -441,14 +446,17 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
hdata_size = CCTK_VarTypeSize (htype);
/* allocate the buffer for the hyperslab data */
- *hdata = malloc (totals * hdata_size);
- typed_hdata = (char *) (*hdata);
+ *hdata = malloc (totals * hdata_size);
+ typed_hdata = (char *) (*hdata);
- /* get the number of hyperslab points in lowest dimension,
- their size in bytes,
- and the byte offset between adjacent points in the source array */
- dim0_points = (endpoint[0] - startpoint[0]) / downsample[0];
- dim0_hsize = dim0_points * hdata_size;
+ /* get the number of hyperslab points in lowest dimension
+ and their size in bytes */
+ dim0_points = (endpoint[0] - startpoint[0]) / downsample[0];
+ if ((endpoint[0] - startpoint[0]) % downsample[0])
+ {
+ dim0_points++;
+ }
+ dim0_hsize = dim0_points * hdata_size;
/* transform the ranges into byte ranges */
for (i = 0; i < vinfo.dim; i++)
@@ -601,12 +609,7 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
@endvar
@var directions
@vdesc directions which span the hyperslab
- This is the direction vector for 1D hyperslabs,
- or the normal vector of the 2 lowest dimensions
- for hyperslabs of higher dimensions.
- If the hyperslab is of same dimensionality as the variable
- the directions vector is ignored.
- @vtype const int[dimensions of vindex]
+ @vtype const int[hdim times dimensions of vindex]
@vio in
@endvar
@var extents
@@ -632,14 +635,19 @@ int NewHyperslab_GetLocalHyperslab (cGH *GH, int vindex, int vtimelvl,
@vio out
@endvar
@@*/
-int NewHyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelvl,
- int hdim, int htype, PUGHSlab_conversion_fn conversion_fn,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+int NewHyperslab_GetHyperslab (cGH *GH,
+ int target_proc,
+ int vindex,
+ int vtimelvl,
+ int hdim,
+ int htype,
+ PUGHSlab_conversion_fn conversion_fn,
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/])
+ int hsize[/* hdim */])
{
int myproc, nprocs; /* processor identification */
int retval; /* the return value */
@@ -997,14 +1005,14 @@ int NewHyperslab_GetHyperslab (cGH *GH, int target_proc, int vindex, int vtimelv
/********************** local routines ************************************/
static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
int hdim,
- const int global_startpoint[/*vdim*/],
- const int directions[/*vdim*/],
- const int extents[/*hdim*/],
- const int downsample_[/*hdim*/],
+ const int global_startpoint[/* vdim */],
+ const int directions[/* hdim*vdim */],
+ const int extents[/* hdim */],
+ const int downsample_[/* hdim */],
void **hdata,
- int hsize[/*hdim*/])
+ int hsize[/* hdim */])
{
- int dim; /* looper */
+ int i, vdim; /* looper */
int num_directions; /* number of non-zero directions */
cGroup vinfo; /* variable's group info */
@@ -1027,13 +1035,13 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
}
/* check the extent and downsample parameters */
- for (dim = 0; dim < hdim; dim++)
+ for (vdim = 0; vdim < hdim; vdim++)
{
- if (extents[dim] == 0)
+ if (extents[vdim] == 0)
{
return ("Invalid hyperslab extent parameters");
}
- if (downsample_[dim] <= 0)
+ if (downsample_[vdim] <= 0)
{
return ( "Invalid hyperslab downsample parameters");
}
@@ -1052,29 +1060,28 @@ static const char *checkParameters (cGH *GH, int vindex, int vtimelvl,
}
/* check the hyperslab dimension */
- if (hdim < 0 || hdim > vinfo.dim)
+ if (hdim <= 0 || hdim > vinfo.dim)
{
return ("Invalid hyperslab dimension");
}
- /* check the direction(s) of the hyperslab
- if it is less-dimensional than the variable */
- if (hdim != vinfo.dim)
+ /* check the direction(s) of the hyperslab */
+ for (i = 0; i < hdim; i++)
{
- for (dim = 0, num_directions = 0; dim < vinfo.dim; dim++)
+ for (vdim = 0, num_directions = 0; vdim < vinfo.dim; vdim++)
{
- if (directions[dim])
+ if (directions[i * vinfo.dim + vdim])
{
num_directions++;
}
}
if (num_directions == 0)
{
- return ("Given normal vector is a null vector");
+ return ("Given direction vector is a null vector");
}
- if (num_directions > 1)
+ if (num_directions != 1)
{
- return ("Given normal vector isn't orthogonal");
+ return ("Given direction vector isn't orthogonal");
}
}