aboutsummaryrefslogtreecommitdiff
path: root/src/pugh_reductions.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pugh_reductions.h')
-rw-r--r--src/pugh_reductions.h98
1 files changed, 53 insertions, 45 deletions
diff --git a/src/pugh_reductions.h b/src/pugh_reductions.h
index b65cdfb..f11d012 100644
--- a/src/pugh_reductions.h
+++ b/src/pugh_reductions.h
@@ -67,65 +67,72 @@
outvals_type typed_outval; \
\
\
- for (_j = 0; _j < num_outvals; _j++, typed_vdata++) \
+ if (have_local_points) \
{ \
- /* get the linear index of the element to start with */ \
- _vindex = from[0]; \
- for (_i = 1; _i < vdim; _i++) \
- _vindex += from [_i] * points_per_dim [_i]; \
- typed_outval = INITIAL_REDUCTION_VALUE(typed_vdata + _vindex); \
- \
- /* set iterator to local startpoint */ \
- memcpy (iterator, from, vdim * sizeof (int)); \
- \
- /* do the nested loops starting with the second-innermost */ \
- _dim = 1; \
- while (1) \
+ for (_j = 0; _j < num_outvals; _j++, typed_vdata++) \
{ \
- /* get the linear index */ \
- _vindex = 0; \
+ /* get the linear index of the element to start with */ \
+ _vindex = from[0]; \
for (_i = 1; _i < vdim; _i++) \
- _vindex += iterator [_i] * points_per_dim [_i]; \
+ _vindex += from [_i] * points_per_dim [_i]; \
+ typed_outval = INITIAL_REDUCTION_VALUE(typed_vdata + _vindex); \
\
- /* do the reduction for the innermost loop (lowest dimension) */ \
- for (_i = from [0]; _i < to [0]; _i++) \
- { \
- REDUCTION_OPERATION (typed_outval, typed_vdata [_i + _vindex]); \
- } \
+ /* set iterator to local startpoint */ \
+ memcpy (iterator, from, vdim * sizeof (int)); \
\
- if (vdim > 1) \
+ /* do the nested loops starting with the second-innermost */ \
+ _dim = 1; \
+ while (1) \
{ \
- /* increment current looper and check for end */ \
- if (++iterator [_dim] >= to [_dim]) \
+ /* get the linear index */ \
+ _vindex = 0; \
+ for (_i = 1; _i < vdim; _i++) \
+ _vindex += iterator [_i] * points_per_dim [_i]; \
+ \
+ /* do the reduction for the innermost loop (lowest dimension) */ \
+ for (_i = from [0]; _i < to [0]; _i++) \
{ \
- /* increment outermost loopers */ \
- for (_dim++; _dim < vdim; _dim++) \
+ REDUCTION_OPERATION (typed_outval, typed_vdata [_i + _vindex]); \
+ } \
+ \
+ if (vdim > 1) \
+ { \
+ /* increment current looper and check for end */ \
+ if (++iterator [_dim] >= to [_dim]) \
{ \
- if (++iterator [_dim] < to [_dim]) \
- break; \
- } \
+ /* increment outermost loopers */ \
+ for (_dim++; _dim < vdim; _dim++) \
+ { \
+ if (++iterator [_dim] < to [_dim]) \
+ break; \
+ } \
\
- /* done if beyond outermost loop */ \
- if (_dim >= vdim) \
- break; \
+ /* done if beyond outermost loop */ \
+ if (_dim >= vdim) \
+ break; \
\
- /* reset innermost loopers */ \
- for (_dim--; _dim >= 0; _dim--) \
- iterator [_dim] = from [_dim]; \
- _dim = 1; \
+ /* reset innermost loopers */ \
+ for (_dim--; _dim >= 0; _dim--) \
+ iterator [_dim] = from [_dim]; \
+ _dim = 1; \
+ } \
+ } \
+ else \
+ { \
+ /* exit loop if array is one-dimensional */ \
+ break; \
} \
- } \
- else \
- { \
- /* exit loop if array is one-dimensional */ \
- break; \
- } \
\
- } /* end of nested loops over all dimensions */ \
+ } /* end of nested loops over all dimensions */ \
\
- outvals [total_outvals++] = (CCTK_REAL) typed_outval; \
+ outvals [total_outvals++] = (CCTK_REAL) typed_outval; \
\
- } /* end of loop over num_outvals */ \
+ } /* end of loop over num_outvals */ \
+ } \
+ else \
+ { \
+ total_outvals += num_outvals; \
+ } \
}
@@ -163,6 +170,7 @@ typedef int (*reduction_fn_t) (const cGH *GH,
int iterator[/* dim */],
const int points_per_dim[/* dim */],
int num_points,
+ int have_local_points,
int num_inarrays,
const int intypes[/* num_inarrays */],
const void *const inarrays[/* num_inarrays */],