aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2002-02-18 09:42:09 +0000
committertradke <tradke@10716dce-81a3-4424-a2c8-48026a0d3035>2002-02-18 09:42:09 +0000
commit85427e9d79b8f9b5815a2757ce822db9dfbb25cb (patch)
tree5eff73f97232c9fef3a72acdde53bb18cb489422
parentcab5e105cd238e4f7cf02512e33083d6c1c44075 (diff)
Bugfix for hyperslab extraction with data conversion and downsampling applied
in the lowest dimension. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHSlab/trunk@71 10716dce-81a3-4424-a2c8-48026a0d3035
-rw-r--r--src/NewHyperslab.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/src/NewHyperslab.c b/src/NewHyperslab.c
index 37aeeb0..d4854d1 100644
--- a/src/NewHyperslab.c
+++ b/src/NewHyperslab.c
@@ -222,6 +222,7 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
int *startpoint, /* hyperslab's local start and endpoint */
*endpoint; /* within the variable's grid dimensions */
int *downsample; /* the downsample_[] vector extended to vdim */
+ int *vdata_stride; /* strides into source data (in bytes) */
int *my_global_startpoint, /* hyperslab's global start and endpoint */
*global_endpoint;
int *points_per_dim; /* points per subvolume */
@@ -300,14 +301,15 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
retval = 0;
/* allocate the temporary arrays */
- point = (int *) malloc (8 * vinfo.dim * sizeof (int));
+ point = (int *) malloc (9 * vinfo.dim * sizeof (int));
startpoint = point + 1*vinfo.dim;
endpoint = point + 2*vinfo.dim;
my_global_startpoint = point + 3*vinfo.dim;
global_endpoint = point + 4*vinfo.dim;
downsample = point + 5*vinfo.dim;
- do_dir = point + 6*vinfo.dim;
- points_per_dim = point + 7*vinfo.dim;
+ vdata_stride = point + 6*vinfo.dim;
+ do_dir = point + 7*vinfo.dim;
+ points_per_dim = point + 8*vinfo.dim;
/* get the actual directions in which to spawn the hyperslab */
memcpy (do_dir, directions, vinfo.dim * sizeof (int));
@@ -538,9 +540,9 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
/* transform the ranges into byte ranges */
for (i = 0; i < vinfo.dim; i++)
{
- startpoint[i] *= vdata_size;
- endpoint[i] *= vdata_size;
- downsample[i] *= vdata_size;
+ startpoint[i] *= vdata_size;
+ endpoint[i] *= vdata_size;
+ vdata_stride[i] = downsample[i] * vdata_size;
}
/* initialize the index vector to the local startpoint */
@@ -556,7 +558,7 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
/* increment outermost loopers */
for (vdim++; vdim < vinfo.dim; vdim++)
{
- point[vdim] += downsample[vdim];
+ point[vdim] += vdata_stride[vdim];
if (point[vdim] < endpoint[vdim])
{
break;
@@ -584,34 +586,19 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
typed_vdata += point[i] * points_per_dim[i];
}
- /* copy the data in lowest dimension: if possible copy all data points
- in a row otherwise do it one by one */
- if (downsample[0] == vdata_size)
+ /* copy the data in lowest dimension */
+ if (conversion_fn)
{
- if (conversion_fn)
- {
- conversion_fn (typed_vdata, typed_hdata, dim0_points, 1, 1);
- }
- else
- {
- memcpy (typed_hdata, typed_vdata, dim0_hsize);
- }
+ conversion_fn (typed_vdata, typed_hdata, dim0_points,
+ downsample[0], 1);
+ typed_vdata += vdata_stride[0] * dim0_points;
}
else
{
- if (conversion_fn)
+ for (i = 0; i < dim0_hsize; i += hdata_size)
{
- conversion_fn (typed_vdata, typed_hdata, dim0_points,
- downsample[0], 1);
- typed_vdata += downsample[0] * dim0_points;
- }
- else
- {
- for (i = 0; i < dim0_hsize; i += hdata_size)
- {
- memcpy (typed_hdata + i, typed_vdata, vdata_size);
- typed_vdata += downsample[0];
- }
+ memcpy (typed_hdata + i, typed_vdata, vdata_size);
+ typed_vdata += vdata_stride[0];
}
}
typed_hdata += dim0_hsize;
@@ -619,7 +606,7 @@ int NewHyperslab_GetLocalHyperslab (const cGH *GH,
if (vinfo.dim > 1)
{
/* increment current looper */
- point[vdim] += downsample[vdim];
+ point[vdim] += vdata_stride[vdim];
}
else
{