diff options
author | yye00 <yye00@7daa882c-dc44-4453-834e-278d26b18e6a> | 2004-07-14 19:03:29 +0000 |
---|---|---|
committer | yye00 <yye00@7daa882c-dc44-4453-834e-278d26b18e6a> | 2004-07-14 19:03:29 +0000 |
commit | 3c6cb4f892e4b0189a8ca878ec916593bd853575 (patch) | |
tree | f5833900226cb3a7aab567da5bdfeb79a3c07a55 /src | |
parent | ea59f209df814084ebaee63a8a34b868fd1cedb5 (diff) |
This commit was generated by cvs2svn to compensate for changes in r8, which
included commits to RCS files with non-trunk default branches.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalReduce/trunk@9 7daa882c-dc44-4453-834e-278d26b18e6a
Diffstat (limited to 'src')
-rw-r--r-- | src/Reduction.c | 185 | ||||
-rw-r--r-- | src/ReductionAvg.c | 117 | ||||
-rw-r--r-- | src/ReductionCount.c | 46 | ||||
-rw-r--r-- | src/ReductionMax.c | 158 | ||||
-rw-r--r-- | src/ReductionMin.c | 153 | ||||
-rw-r--r-- | src/ReductionNorm1.c | 151 | ||||
-rw-r--r-- | src/ReductionNorm2.c | 149 | ||||
-rw-r--r-- | src/ReductionNorm3.c | 149 | ||||
-rw-r--r-- | src/ReductionNorm4.c | 149 | ||||
-rw-r--r-- | src/ReductionNormInf.c | 153 | ||||
-rw-r--r-- | src/ReductionSum.c | 179 | ||||
-rw-r--r-- | src/Startup.c | 30 | ||||
-rw-r--r-- | src/local_reductions.h | 168 | ||||
-rw-r--r-- | src/make.code.defn | 2 |
14 files changed, 820 insertions, 969 deletions
diff --git a/src/Reduction.c b/src/Reduction.c index 656ae96..c97d078 100644 --- a/src/Reduction.c +++ b/src/Reduction.c @@ -20,10 +20,6 @@ CCTK_FILEVERSION(CCTDevelopment_LocalReduce_Reduction_c) ********************* Local Routine Prototypes ********************* ********************************************************************/ -static int ReductionScalar (const cGH *GH, int vindex, int proc, - CCTK_REAL *outval, - reduction_fn_t reduction_fn); - static int copy_real_to_outtype (int num_elems, CCTK_REAL inarray [/* num_elems */], int outtype, @@ -35,90 +31,75 @@ static int copy_real_to_outtype (int num_elems, ********************************************************************/ /*@@ - @routine PUGH_ReductionArrays - @author Thomas Radke - @date 19 Aug 1999 + @routine ReductionArrays + @author Thomas Radke, Yaakoub El Khamra + @date @desc Wrapper to reduce a list of arrays. Just calls the appropriate reduction operator and does the type conversion of the results. - @enddesc - @calls copy_real_to_outtype - - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * - @vio in - @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) - @vtype int - @vio in - @endvar - @var num_dims - @vdesc number of dimensions of input arrays - @vtype int - @vio in - @endvar - @var dims - @vdesc dimensions of input arrays - @vtype int * - @vio in - @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int - @vio in - @endvar - @var num_inarrays - @vdesc number of input arrays - @vtype int - @vio in - @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const * - @vio in - @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int - @vio in - @endvar - @var num_outvals - @vdesc number of values per output array - @vtype int - @vio in - @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * - @vio in - @endvar - @var reduction_fn - @vdesc reduction operator callback - @vtype reduction_fn_t - @vio in - @endvar - - @returntype int - @returndesc - the return code of the reduction operator, or<BR> - -1 if array size is zero<BR> - -2 if <num_outvals> is invalid - @endreturndesc + @enddesc + @history + @endhistory + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int + @vio in + @endvar + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform + @vtype int + @vio in + @endvar + @var param_table_handle + @vdesc handle to "parameter table", a key-value table + @vtype int + @vio in + @endvar + @var N_input_arrays + @vdesc number of input arrays + @vtype int + @vio in + @endvar + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT + @vio in + @endvar + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT + @vio in + @endvar + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const + @vio in + @endvar + @var M_output_numbers + @vdesc + @vtype int + @vio in + @endvar + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT + @vio in + @endvar + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const + @vio in + @endvar @@*/ -int ReductionArrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int intype, - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int outtype, - int num_outvals, - void *outvals /* [num_outvals] */, +int ReductionArrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[], reduction_fn_t reduction_fn) { int i, num_points, retval; @@ -129,56 +110,56 @@ int ReductionArrays (const cGH *GH, points_per_dim[0] = 1; from[0] = 0; - to[0] = dims[0]; + to[0] = input_array_dims[0]; /* get the total number of array elements */ - for (i = 1; i < num_dims; i++) + for (i = 1; i < N_dims; i++) { - to[0] *= dims[i]; + to[0] *= input_array_dims[i]; } /* check for zero-sized arrays */ if (to[0] <= 0) { - CCTK_WARN (2, "PUGH_ReductionArrays: Cannot reduce zero-sized arrays"); + CCTK_WARN (2, "ReductionArrays: Cannot reduce zero-sized arrays"); return (-1); } - if (num_outvals != 1) + if (M_output_numbers != 1) { - if (num_outvals != to[0]) + if (M_output_numbers != to[0]) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "PUGH_ReductionArrays: Don't know how to reduce " + "LocalReductionArrays: Don't know how to reduce " "a %d-dimensional array with %d elements " "to an output array of %d elements", - num_dims, to[0], num_outvals); + N_dims, to[0], M_output_numbers); return (-2); } to[0] = 1; } - num_points = to[0] * CCTK_nProcs (GH); + num_points = to[0]; /* set the array types to intype */ /* FIXME: could allow to pass in arrays of different types now !!! */ - intypes = malloc (num_inarrays * sizeof (int)); - for (i = 0; i < num_inarrays; i++) + intypes = malloc (N_input_arrays * sizeof (int)); + for (i = 0; i < N_input_arrays; i++) { - intypes[i] = intype; + intypes[i] = input_array_type_codes[i]; } - buffer = malloc (num_outvals * sizeof (CCTK_REAL)); + buffer = malloc (M_output_numbers * sizeof (CCTK_REAL)); /* do the reduction on the input arrays */ - retval = reduction_fn (GH, proc, num_dims, from, to, iterator, points_per_dim, - num_points, 1, num_inarrays, intypes, inarrays, - num_outvals, buffer); + retval = reduction_fn (N_dims, from, to, iterator, points_per_dim, + num_points, 1, N_input_arrays, intypes, input_arrays, + M_output_numbers, buffer); - if (retval == 0 && (proc < 0 || proc == CCTK_MyProc (GH))) + if (retval == 0 ) { /* type-cast the result to the requested datatype */ - retval = copy_real_to_outtype (num_inarrays * num_outvals, - buffer, outtype, outvals); +/* retval = copy_real_to_outtype (N_input_arrays * M_output_numbers, + buffer, output_number_type_codes, output_numbers);*/ } free (intypes); diff --git a/src/ReductionAvg.c b/src/ReductionAvg.c index 2f0c602..e08fdc2 100644 --- a/src/ReductionAvg.c +++ b/src/ReductionAvg.c @@ -19,14 +19,18 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionAvg_c) /* local function prototypes */ -static int ReductionAvg (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, - const CCTK_INT input_array_dims[], - const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], - int M_output_numbers, - const CCTK_INT output_number_type_codes[], - void *const output_numbers[]); +static int ReductionAvg (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -34,65 +38,57 @@ static int ReductionAvg (int N_dims, int operator_handle, @author Thomas Radke @date 19 Aug 1999 @desc - Registered PUGH reduction routine for computing the averages - of a set of arrays. - The arrays are described by their dimensions and variable type. - For the number of output values only 1 is accepted. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var nDims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var nArrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var inType - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ @@ -106,10 +102,11 @@ int ReductionAvgArrays (int N_dims, int operator_handle, void *const output_numbers[]) { return (ReductionArrays (N_dims, operator_handle, - param_table_handle, N_input_arrays, - input_array_dims, input_array_type_codes, - input_arrays, M_output_numbers, - output_number_type_codes, output_numbers)); + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionAvg)); } /*****************************************************************************/ @@ -124,22 +121,24 @@ int ReductionAvgArrays (int N_dims, int operator_handle, (num_outvals == 1) or on the results of the local reductions. @enddesc @@*/ -static int ReductionAvg (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, - const CCTK_INT input_array_dims[], - const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], - int M_output_numbers, - const CCTK_INT output_number_type_codes[], - void *const output_numbers[]) +static int ReductionAvg (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; const char *vtypename; /* avoid compiler warnings about unused parameters */ - (void) (GH + 0); - (void) (proc + 0); (void) (num_points + 0); /* macros to complete the ITERATE_ARRAY macro */ @@ -148,7 +147,7 @@ static int ReductionAvg (int N_dims, int operator_handle, for (i = total_outvals = 0; i < num_inarrays; i++) { - switch (input_array_type_codes[i]) + switch (intypes[i]) { case CCTK_VARIABLE_CHAR: ITERATE_ARRAY (CCTK_BYTE, num_dims, inarrays[i], @@ -225,7 +224,7 @@ static int ReductionAvg (int N_dims, int operator_handle, #endif default: - vtypename = CCTK_VarTypeName (input_array_type_codes[i]); + vtypename = CCTK_VarTypeName (intypes[i]); if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) { CCTK_WARN (1, "PUGH_ReductionAvg: Don't know how to compute " diff --git a/src/ReductionCount.c b/src/ReductionCount.c index 71b99b2..bdcc2ef 100644 --- a/src/ReductionCount.c +++ b/src/ReductionCount.c @@ -19,9 +19,7 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionCount_c) /* local function prototypes */ -static int ReductionCount (const cGH *GH, - int proc, - int num_dims, +static int ReductionCount (int num_dims, const int from[/* dim */], const int to[/* dim */], int iterator[/* dim */], @@ -100,21 +98,21 @@ static int ReductionCount (const cGH *GH, @vio in @endvar @@*/ -int ReductionCountArrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionCountArrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionCount)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionCount)); } /*****************************************************************************/ @@ -128,9 +126,7 @@ int ReductionCountArrays (const cGH *GH, Returns the number of grid points of a distributed array @enddesc @@*/ -static int ReductionCount (const cGH *GH, - int proc, - int num_dims, +static int ReductionCount (int num_dims, const int from[/* dim */], const int to[/* dim */], int iterator[/* dim */], @@ -145,10 +141,7 @@ static int ReductionCount (const cGH *GH, { int i; - /* avoid compiler warnings about unused parameters */ - (void) (GH + 0); - (void) (proc + 0); (void) (num_dims + 0); (void) (from + 0); (void) (to + 0); @@ -160,12 +153,9 @@ static int ReductionCount (const cGH *GH, (void) (num_outvals + 0); /* assign the return value */ - if (proc < 0 || proc == CCTK_MyProc (GH)) + for (i = 0; i < num_inarrays; i++) { - for (i = 0; i < num_inarrays; i++) - { - outvals[i] = num_points; - } + outvals[i] = num_points; } return (0); diff --git a/src/ReductionMax.c b/src/ReductionMax.c index fb2aae9..bb91efa 100644 --- a/src/ReductionMax.c +++ b/src/ReductionMax.c @@ -20,104 +20,94 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionMax_c) /* local function prototypes */ -static int ReductionMaxVal (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionMaxVal (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @routine PUGH_ReductionMaxValArrays @author Thomas Radke @date 19 Aug 1999 - @desc - Registered PUGH reduction routine for computing the maxima - for a set of arrays. - The arrays are described by their dimensions and variable type. - For the number of output values only 1 is accepted. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. - @enddesc + @desc @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_inarrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const * + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionMaxValArrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) + +int ReductionMaxValArrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionMaxVal)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionMaxVal)); } @@ -134,32 +124,24 @@ int ReductionMaxValArrays (const cGH *GH, (num_outvals == 1) or on the results of the local reductions. @enddesc @@*/ -static int ReductionMaxVal (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionMaxVal (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; const char *vtypename; -#ifdef CCTK_MPI - const pGH *pughGH; - CCTK_REAL *local_outvals; -#endif /* prevent compiler warnings about unused parameters */ - (void) (GH + 0); - (void) (proc + 0); (void) (num_points + 0); /* macros to complete the ITERATE_ARRAY macro */ @@ -215,6 +197,7 @@ static int ReductionMaxVal (const cGH *GH, #endif case CCTK_VARIABLE_REAL: + CCTK_VInfo(CCTK_THORNSTRING, "from and to are: %d ,%d ", from[0], to[0]); ITERATE_ARRAY (CCTK_REAL, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_REAL, outvals, num_outvals, total_outvals); @@ -246,14 +229,15 @@ static int ReductionMaxVal (const cGH *GH, default: vtypename = CCTK_VarTypeName (intypes[i]); + if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) { - CCTK_WARN (1, "PUGH_ReductionMaxVal: Don't know how to compute " + CCTK_WARN (1, "LocalReductionMaxVal: Don't know how to compute " "the maximum of complex variables !!!"); } else { - CCTK_WARN (1, "PUGH_ReductionMaxVal: Unknown variable type"); + CCTK_WARN (1, "LocalReductionMaxVal: Unknown variable type"); } return (-1); } diff --git a/src/ReductionMin.c b/src/ReductionMin.c index 8d73384..20c2712 100644 --- a/src/ReductionMin.c +++ b/src/ReductionMin.c @@ -20,20 +20,18 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionMin_c) /* local function prototypes */ -static int ReductionMinVal (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionMinVal (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -41,83 +39,75 @@ static int ReductionMinVal (const cGH *GH, @author Thomas Radke @date 19 Aug 1999 @desc - Registered PUGH reduction routine for computing the minima - for a set of arrays. - The arrays are described by their dimensions and variable type. - For the number of output values only 1 is accepted. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_inarrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const * + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionMinValArrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionMinValArrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionMinVal)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionMinVal)); } @@ -135,32 +125,23 @@ int ReductionMinValArrays (const cGH *GH, or on the results of the local reductions. @enddesc @@*/ -static int ReductionMinVal (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionMinVal (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; const char *vtypename; -#ifdef CCTK_MPI - const pGH *pughGH; - CCTK_REAL *local_outvals; -#endif - /* prevent compiler warnings about unused parameters */ - (void) (GH + 0); - (void) (proc + 0); (void) (num_points + 0); /* macros to complete the ITERATE_ARRAY macro */ @@ -249,12 +230,12 @@ static int ReductionMinVal (const cGH *GH, vtypename = CCTK_VarTypeName (intypes[i]); if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) { - CCTK_WARN (1, "PUGH_ReductionMinVal: Don't know how to compute " + CCTK_WARN (1, "LocalReductionMinVal: Don't know how to compute " "the minimum of complex variables !!!"); } else { - CCTK_WARN (1, "PUGH_ReductionMinVal: Unknown variable type"); + CCTK_WARN (1, "LocalReductionMinVal: Unknown variable type"); } return (-1); } diff --git a/src/ReductionNorm1.c b/src/ReductionNorm1.c index 81df22a..358b5cb 100644 --- a/src/ReductionNorm1.c +++ b/src/ReductionNorm1.c @@ -20,107 +20,94 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionNorm1_c) /* local function prototypes */ -static int ReductionNorm1 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionNorm1 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ - @routine PUGH_ReductionNorm1Arrays + @routine LocalReductionNorm1Arrays @author Thomas Radke @date 19 Aug 1999 @desc - Registered PUGH reduction routine for computing the "norm1" - of a set of arrays. - The arrays are described by their dimensions and variable type. - If the number of requested output values equals the number of - elements in an input array, global reduction is done element-wise. - Otherwise num_outvals must be 1, and global reduction is done on the - results of the local reductions. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_arrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionNorm1Arrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionNorm1Arrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionNorm1)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionNorm1)); } @@ -128,7 +115,7 @@ int ReductionNorm1Arrays (const cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionNorm1 + @routine LocalReductionNorm1 @date Aug 19 1999 @author Thomas Radke @desc Returns the "norm1" of a distributed array with @@ -138,20 +125,18 @@ int ReductionNorm1Arrays (const cGH *GH, "norm1" is defined as $\Sigma |a_i| / np$. @enddesc @@*/ -static int ReductionNorm1 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionNorm1 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; @@ -280,7 +265,7 @@ static int ReductionNorm1 (const cGH *GH, #endif default: - CCTK_WARN (1, "PUGH_ReductionNorm1: Unknown variable type"); + CCTK_WARN (1, "LocalReductionNorm1: Unknown variable type"); return (-1); } } diff --git a/src/ReductionNorm2.c b/src/ReductionNorm2.c index d2c2093..2df1480 100644 --- a/src/ReductionNorm2.c +++ b/src/ReductionNorm2.c @@ -21,107 +21,94 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionNorm2_c) /* local function prototypes */ -static int ReductionNorm2 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionNorm2 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ - @routine PUGH_ReductionNorm2Arrays + @routine LocalReductionNorm2Arrays @author Thomas Radke @date 19 Aug 1999 @desc - Registered PUGH reduction routine for computing the "norm2" - of a set of arrays. - The arrays are described by their dimensions and variable type. - If the number of requested output values equals the number of - elements in an input array, global reduction is done element-wise. - Otherwise num_outvals must be 1, and global reduction is done on the - results of the local reductions. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_arrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionNorm2Arrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionNorm2Arrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionNorm2)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionNorm2)); } @@ -140,20 +127,18 @@ int ReductionNorm2Arrays (const cGH *GH, "norm2" is defined as $\sqrt{\Sigma (a_i * a_i) / np}$. @enddesc @@*/ -static int ReductionNorm2 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionNorm2 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; @@ -275,7 +260,7 @@ static int ReductionNorm2 (const cGH *GH, #endif default: - CCTK_WARN (1, "PUGH_ReductionNorm2: Unknown variable type"); + CCTK_WARN (1, "LocalReductionNorm2: Unknown variable type"); return (-1); } } diff --git a/src/ReductionNorm3.c b/src/ReductionNorm3.c index 366bd61..9aa4cdc 100644 --- a/src/ReductionNorm3.c +++ b/src/ReductionNorm3.c @@ -21,107 +21,94 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionNorm3_c) /* local function prototypes */ -static int ReductionNorm3 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionNorm3 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ - @routine PUGH_ReductionNorm3Arrays + @routine LocalReductionNorm3Arrays @author Thomas Radke @date Tue Apr 15 2003 @desc - Registered PUGH reduction routine for computing the "norm3" - of a set of arrays. - The arrays are described by their dimensions and variable type. - If the number of requested output values equals the number of - elements in an input array, global reduction is done element-wise. - Otherwise num_outvals must be 1, and global reduction is done on the - results of the local reductions. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_arrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionNorm3Arrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionNorm3Arrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionNorm3)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionNorm3)); } @@ -139,20 +126,18 @@ int ReductionNorm3Arrays (const cGH *GH, "norm3" is defined as $\sqrt{\Sigma |a_i|^3 / np}$. @enddesc @@*/ -static int ReductionNorm3 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionNorm3 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; @@ -273,7 +258,7 @@ static int ReductionNorm3 (const cGH *GH, #endif default: - CCTK_WARN (1, "PUGH_ReductionNorm3: Unknown variable type"); + CCTK_WARN (1, "LocalReductionNorm3: Unknown variable type"); return (-1); } } diff --git a/src/ReductionNorm4.c b/src/ReductionNorm4.c index cf09f60..c60b69e 100644 --- a/src/ReductionNorm4.c +++ b/src/ReductionNorm4.c @@ -21,107 +21,94 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionNorm4_c) /* local function prototypes */ -static int ReductionNorm4 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionNorm4 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ - @routine PUGH_ReductionNorm4Arrays + @routine LocalReductionNorm4Arrays @author Thomas Radke @date Tue Apr 15 2003 @desc - Registered PUGH reduction routine for computing the "norm4" - of a set of arrays. - The arrays are described by their dimensions and variable type. - If the number of requested output values equals the number of - elements in an input array, global reduction is done element-wise. - Otherwise num_outvals must be 1, and global reduction is done on the - results of the local reductions. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_arrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionNorm4Arrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionNorm4Arrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionNorm4)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionNorm4)); } @@ -139,20 +126,18 @@ int ReductionNorm4Arrays (const cGH *GH, "norm4" is defined as $\sqrt{\Sigma (a_i^4) / np}$. @enddesc @@*/ -static int ReductionNorm4 (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionNorm4 (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; @@ -271,7 +256,7 @@ static int ReductionNorm4 (const cGH *GH, #endif default: - CCTK_WARN (1, "PUGH_ReductionNorm4: Unknown variable type"); + CCTK_WARN (1, "LocalReductionNorm4: Unknown variable type"); return (-1); } } diff --git a/src/ReductionNormInf.c b/src/ReductionNormInf.c index f3a473a..269c21a 100644 --- a/src/ReductionNormInf.c +++ b/src/ReductionNormInf.c @@ -21,107 +21,94 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionNormInf_c) /* local function prototypes */ -static int ReductionNormInf (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionNormInf (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ - @routine PUGH_ReductionNormInfArrays + @routine LocalReductionNormInfArrays @author Thomas Radke @date 19 Aug 1999 @desc - Registered PUGH reduction routine for computing the "norm_inf" - of a set of arrays. - The arrays are described by their dimensions and variable type. - If the number of requested output values equals the number of - elements in an input array, global reduction is done element-wise. - Otherwise num_outvals must be 1, and global reduction is done on the - results of the local reductions. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var num_dims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_input_arrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var num_arrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var inarrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var intype - @vdesc (common) variable type of input arrays - @vtype int + @var input_arrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ -int ReductionNormInfArrays (const cGH *GH, - int proc, - int num_dims, - const int dims[/* num_dims */], - int num_inarrays, - const void *const inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int ReductionNormInfArrays (int N_dims, int operator_handle, + int param_table_handle, int N_input_arrays, + const CCTK_INT input_array_dims[], + const CCTK_INT input_array_type_codes[], + const void *const input_arrays[], + int M_output_numbers, + const CCTK_INT output_number_type_codes[], + void *const output_numbers[]) { - return (ReductionArrays (GH, proc, num_dims, dims, - intype, num_inarrays, inarrays, - outtype, num_outvals, outvals, - ReductionNormInf)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_input_arrays, + input_array_dims, input_array_type_codes, + input_arrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionNormInf)); } @@ -139,20 +126,18 @@ int ReductionNormInfArrays (const cGH *GH, "norm_inf" is defined as $\max |a_i|$. @enddesc @@*/ -static int ReductionNormInf (const cGH *GH, - int proc, - int num_dims, - const int from[/* dim */], - const int to[/* dim */], - 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 */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionNormInf (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; @@ -169,10 +154,6 @@ static int ReductionNormInf (const cGH *GH, /* avoid compiler warnings about unused parameters */ -#ifndef CCTK_MPI - (void) (GH + 0); - (void) (proc + 0); -#endif (void) (num_points + 0); for (i = total_outvals = 0; i < num_inarrays; i++) @@ -292,7 +273,7 @@ static int ReductionNormInf (const cGH *GH, #endif default: - CCTK_WARN (1, "PUGH_ReductionNormInf: Unknown variable type"); + CCTK_WARN (1, "LocalReductionNormInf: Unknown variable type"); return (-1); } } diff --git a/src/ReductionSum.c b/src/ReductionSum.c index e04dc36..dad70d5 100644 --- a/src/ReductionSum.c +++ b/src/ReductionSum.c @@ -13,103 +13,102 @@ #include <string.h> #include "local_reductions.h" +#include "util_Table.h" static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CCTDevelopment_LocalReduce_ReductionSum_c) /* local function prototypes */ -static int ReductionSum (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, - const CCTK_INT input_array_dims[], - const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], - int M_output_numbers, - const CCTK_INT output_number_type_codes[], - void *const output_numbers[]); +static int ReductionSum (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @routine ReductionSumArrays - @author Thomas Radke - @date 19 Aug 1999 + @author Thomas Radke, Yaakoub El Khamra + @date @desc - Registered PUGH reduction routine for computing the sums - of a set of arrays. - The arrays are described by their dimensions and variable type. - For the number of output values only 1 is accepted. - Type casting of the result is provided by specifying the - requested output datatype. The intermediate reduction value - is always computed as a CCTK_REAL value internally. + This is the sum reduction routine using the new api @enddesc @history @endhistory - @var GH - @vdesc Pointer to CCTK grid hierarchy - @vtype const cGH * + @var N_dims + @vdesc number of dimensions in the *reduction* + @vtype int @vio in @endvar - @var proc - @vdesc processor that should receive the result of operation - (negative value means all processors receive the result) + @var operator_handle + @vdesc operator handle specificies the type of reduction we will perform @vtype int @vio in @endvar - @var nDims - @vdesc number of dimensions of input arrays + @var param_table_handle + @vdesc handle to "parameter table", a key-value table @vtype int @vio in @endvar - @var dims - @vdesc dimensions of input arrays - @vtype const int * + @var N_inarrays + @vdesc number of input arrays + @vtype int @vio in @endvar - @var nArrays - @vdesc number of input arrays - @vtype int + @var input_array_dims + @vdesc array of input array dimensions (common to all input arrays) + @vtype const CCTK_INT @vio in @endvar - @var input_arrays - @vdesc field of input arrays - @vtype const void *const + @var input_array_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of input arrays + @vtype const CCTK_INT @vio in @endvar - @var inType - @vdesc (common) variable type of input arrays - @vtype int + @var inarrays + @vdesc array of pointers to input arrays + @vtype const void *const @vio in @endvar - @var num_outvals - @vdesc number of values per output array + @var M_output_numbers + @vdesc @vtype int @vio in @endvar - @var outvals - @vdesc pointer to buffer holding the output values - @vtype void * + @var output_number_type_codes + @vdesc array of CCTK_VARIABLE_* codes giving data types of output numbers + @vtype const CCTK_INT @vio in @endvar - @var outtype - @vdesc (common) variable type of output arrays - @vtype int + @var output_numbers + @vdesc array[M_output_numbers] of pointers to output numbers[M_reduce_numbers] + @vtype void *const @vio in @endvar @@*/ int ReductionSumArrays (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, + int param_table_handle, int N_inarrays, const CCTK_INT input_array_dims[], const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], + const void *const inarrays[], int M_output_numbers, const CCTK_INT output_number_type_codes[], void *const output_numbers[]) { - return (ReductionSum (N_dims, operator_handle, - param_table_handle, N_input_arrays, - input_array_dims, input_array_type_codes, - input_arrays, M_output_numbers, - output_number_type_codes, output_numbers)); + return (ReductionArrays (N_dims, operator_handle, + param_table_handle, N_inarrays, + input_array_dims, input_array_type_codes, + inarrays, M_output_numbers, + output_number_type_codes, output_numbers, + ReductionSum)); } @@ -118,21 +117,25 @@ int ReductionSumArrays (int N_dims, int operator_handle, /*****************************************************************************/ /*@@ @routine ReductionSum - @date Aug 19 1999 - @author Thomas Radke + @date + @author Thomas Radke, Yaakoub El Khamra @desc Returns the sum of a distributed array with 'num_points' elements. Global reduction is done element-wise (num_outvals == 1) or on the results of the local reductions. @enddesc @@*/ -static int ReductionSum (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, - const CCTK_INT input_array_dims[], - const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], - int M_output_numbers, - const CCTK_INT output_number_type_codes[], - void *const output_numbers[]) +static int ReductionSum (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; const char *vtypename; @@ -142,47 +145,25 @@ static int ReductionSum (int N_dims, int operator_handle, #define INITIAL_REDUCTION_VALUE(array) 0 #define REDUCTION_OPERATION(sum, scalar) sum += scalar - int from3D[3], to3D[3]; - int from2D[2], to2D[2]; - int from1D[1], to1D[1]; - - from3D[0]=0; - from3D[1]=0; - from3D[2]=0; - - from2D[0]=0; - from2D[1]=0; - - from1D[0]=0; - - to3D[0]=10; - to3D[1]=10; - to3D[2]=10; - - to2D[0]=10; - to2D[1]=10; - - to31[0]=10; - - for (i = total_outvals = 0; i < N_input_arrays; i++) + for (i = total_outvals = 0; i < num_inarrays; i++) { - switch (input_array_type_codes[i]) + switch (intypes[i]) { case CCTK_VARIABLE_CHAR: - ITERATE_ARRAY (CCTK_BYTE, input_array_dims[i], input_arrays[i], - from3D, to3D, iterator, points_per_dim, - CCTK_BYTE, output_numbers, num_outvals, total_outvals); + ITERATE_ARRAY (CCTK_BYTE, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_BYTE, outvals, num_outvals, total_outvals); break; case CCTK_VARIABLE_INT: - ITERATE_ARRAY (CCTK_INT, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_INT, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_INT, outvals, num_outvals, total_outvals); break; #ifdef CCTK_INT1 case CCTK_VARIABLE_INT1: - ITERATE_ARRAY (CCTK_INT1, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_INT1, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_INT1, outvals, num_outvals, total_outvals); break; @@ -190,7 +171,7 @@ static int ReductionSum (int N_dims, int operator_handle, #ifdef CCTK_INT2 case CCTK_VARIABLE_INT2: - ITERATE_ARRAY (CCTK_INT2, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_INT2, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_INT2, outvals, num_outvals, total_outvals); break; @@ -198,7 +179,7 @@ static int ReductionSum (int N_dims, int operator_handle, #ifdef CCTK_INT4 case CCTK_VARIABLE_INT4: - ITERATE_ARRAY (CCTK_INT4, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_INT4, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_INT4, outvals, num_outvals, total_outvals); break; @@ -206,21 +187,21 @@ static int ReductionSum (int N_dims, int operator_handle, #ifdef CCTK_INT8 case CCTK_VARIABLE_INT8: - ITERATE_ARRAY (CCTK_INT8, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_INT8, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_INT8, outvals, num_outvals, total_outvals); break; #endif case CCTK_VARIABLE_REAL: - ITERATE_ARRAY (CCTK_REAL, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_REAL, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_REAL, outvals, num_outvals, total_outvals); break; #ifdef CCTK_REAL4 case CCTK_VARIABLE_REAL4: - ITERATE_ARRAY (CCTK_REAL4, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_REAL4, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_REAL4, outvals, num_outvals, total_outvals); break; @@ -228,7 +209,7 @@ static int ReductionSum (int N_dims, int operator_handle, #ifdef CCTK_REAL8 case CCTK_VARIABLE_REAL8: - ITERATE_ARRAY (CCTK_REAL8, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_REAL8, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_REAL8, outvals, num_outvals, total_outvals); break; @@ -236,14 +217,14 @@ static int ReductionSum (int N_dims, int operator_handle, #ifdef CCTK_REAL16 case CCTK_VARIABLE_REAL16: - ITERATE_ARRAY (CCTK_REAL16, num_dims, input_arrays[i], + ITERATE_ARRAY (CCTK_REAL16, num_dims, inarrays[i], from, to, iterator, points_per_dim, CCTK_REAL16, outvals, num_outvals, total_outvals); break; #endif default: - vtypename = CCTK_VarTypeName (input_array_type_codes[i]); + vtypename = CCTK_VarTypeName (intypes[i]); if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) { CCTK_WARN (1, "ReductionSum: Don't know how to compute " diff --git a/src/Startup.c b/src/Startup.c index 02188c9..225eea2 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -24,21 +24,21 @@ int LocalReduce_Startup (void) { /* Register the reduction operators */ -/* CCTK_RegisterReductionLocalArrayOperator (ReductionAvgArrays, "average"); - CCTK_RegisterReductionLocalArrayOperator (ReductionAvgArrays, "mean"); - CCTK_RegisterReductionLocalArrayOperator (ReductionCountArrays, "count"); - CCTK_RegisterReductionLocalArrayOperator (ReductionMaxValArrays, "maximum"); - CCTK_RegisterReductionLocalArrayOperator (ReductionMinValArrays, "minimum"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm1Arrays, "norm1"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm1Arrays, "L1Norm"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm2Arrays, "norm2"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm2Arrays, "L2Norm"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm3Arrays, "norm3"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm3Arrays, "L3Norm"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm4Arrays, "norm4"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNorm4Arrays, "L4Norm"); - CCTK_RegisterReductionLocalArrayOperator (ReductionNormInfArrays, "norm_inf");*/ - CCTK_RegisterReductionLocalArrayOperator (ReductionSumArrays, "sum"); + CCTK_RegisterLocalArrayReductionOperator (ReductionAvgArrays, "average"); + CCTK_RegisterLocalArrayReductionOperator (ReductionAvgArrays, "mean"); + CCTK_RegisterLocalArrayReductionOperator (ReductionCountArrays, "count"); + CCTK_RegisterLocalArrayReductionOperator (ReductionMaxValArrays, "maximum"); + CCTK_RegisterLocalArrayReductionOperator (ReductionMinValArrays, "minimum"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm1Arrays, "norm1"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm1Arrays, "L1Norm"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm2Arrays, "norm2"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm2Arrays, "L2Norm"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm3Arrays, "norm3"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm3Arrays, "L3Norm"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm4Arrays, "norm4"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNorm4Arrays, "L4Norm"); + CCTK_RegisterLocalArrayReductionOperator (ReductionNormInfArrays, "norm_inf"); + CCTK_RegisterLocalArrayReductionOperator (ReductionSumArrays, "sum"); printf("\n success\n"); return (0); } diff --git a/src/local_reductions.h b/src/local_reductions.h index 015dbc1..7a6f9a2 100644 --- a/src/local_reductions.h +++ b/src/local_reductions.h @@ -1,9 +1,9 @@ /*@@ - @header CCTK_reductions.h - @date April 29 1999 - @author Gabrielle Allen + @header local_reductions.h + @date + @author Gabrielle Allen, Yaakoub El Khamra @desc - Prototypes for pugh reduction operators + Prototypes for local reduction operators @enddesc @version $Header$ @@*/ @@ -14,7 +14,7 @@ #include "cctk.h" #include "cctk_Reduction.h" -/* #include "CactusPUGH/PUGH/src/include/pugh.h"*/ + /*** Macro to iterate over every element of an arbitrary sized array @@ -66,72 +66,82 @@ const cctk_type *typed_vdata = (vdata); \ outvals_type typed_outval; \ \ - for (_j = 0; _j < num_outvals; _j++, typed_vdata++) \ - { \ - /* 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) \ - { \ - /* 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++) \ - { \ - REDUCTION_OPERATION (typed_outval, typed_vdata [_i + _vindex]); \ - } \ - \ - if (vdim > 1) \ - { \ - /* increment current looper and check for end */ \ - if (++iterator [_dim] >= to [_dim]) \ - { \ - /* increment outermost loopers */ \ - for (_dim++; _dim < vdim; _dim++) \ - { \ - if (++iterator [_dim] < to [_dim]) \ - break; \ - } \ - \ - /* done if beyond outermost loop */ \ - if (_dim >= vdim) \ - break; \ - \ - /* reset innermost loopers */ \ - for (_dim--; _dim >= 0; _dim--) \ - iterator [_dim] = from [_dim]; \ - _dim = 1; \ - } \ - } \ - else \ - { \ - /* exit loop if array is one-dimensional */ \ - break; \ - } \ - \ - } /* end of nested loops over all dimensions */ \ - \ - outvals [total_outvals++] = (CCTK_REAL) typed_outval; \ - \ - } /* end of loop over num_outvals */ \ - } \ - } + if (have_local_points) \ + { \ + for (_j = 0; _j < num_outvals; _j++, typed_vdata++) \ + { \ + /* 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]; \ + CCTK_VInfo(CCTK_THORNSTRING, "initial reduction value from and to are: %d ,%d ", from[0], to[0]); \ + typed_outval = INITIAL_REDUCTION_VALUE(typed_vdata + _vindex); \ + CCTK_VInfo(CCTK_THORNSTRING, "initial reduction vars value are: %d ,%d ", 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) \ + { \ + /* 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++) \ + { \ + REDUCTION_OPERATION (typed_outval, typed_vdata [_i + _vindex]); \ + } \ + \ + if (vdim > 1) \ + { \ + /* increment current looper and check for end */ \ + if (++iterator [_dim] >= to [_dim]) \ + { \ + /* increment outermost loopers */ \ + for (_dim++; _dim < vdim; _dim++) \ + { \ + if (++iterator [_dim] < to [_dim]) \ + break; \ + } \ + \ + /* done if beyond outermost loop */ \ + if (_dim >= vdim) \ + break; \ + \ + /* reset innermost loopers */ \ + for (_dim--; _dim >= 0; _dim--) \ + iterator [_dim] = from [_dim]; \ + _dim = 1; \ + } \ + } \ + else \ + { \ + /* exit loop if array is one-dimensional */ \ + break; \ + } \ + \ + } /* end of nested loops over all dimensions */ \ + \ + outvals [total_outvals++] = (CCTK_REAL) typed_outval; \ + \ + } /* end of loop over num_outvals */ \ + } \ + else \ + { \ + total_outvals += num_outvals; \ + } \ + } + #ifdef __cplusplus extern "C" { #endif -/* + + int ReductionAvgArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionCountArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionMaxValArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); @@ -140,17 +150,21 @@ int ReductionNorm1Arrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionNorm2Arrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionNorm3Arrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionNorm4Arrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); -int ReductionNormInfArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST);*/ +int ReductionNormInfArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); int ReductionSumArrays (REDUCTION_LOCAL_ARRAY_OPERATOR_REGISTER_ARGLIST); -typedef int (*reduction_fn_t) (int N_dims, int operator_handle, - int param_table_handle, int N_input_arrays, - const CCTK_INT input_array_dims[], - const CCTK_INT input_array_type_codes[], - const void *const input_arrays[], - int M_output_numbers, - const CCTK_INT output_number_type_codes[], - void *const output_numbers[]); +typedef int (*reduction_fn_t) (int num_dims, + const int from[/* dim */], + const int to[/* dim */], + 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 */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); int ReductionArrays (int N_dims, int operator_handle, int param_table_handle, int N_input_arrays, @@ -159,7 +173,7 @@ int ReductionArrays (int N_dims, int operator_handle, const void *const input_arrays[], int M_output_numbers, const CCTK_INT output_number_type_codes[], - void *const output_numbers[]); + void *const output_numbers[],reduction_fn_t reduction_fn); #ifdef __cplusplus } diff --git a/src/make.code.defn b/src/make.code.defn index 5b65f84..591b0b3 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -2,7 +2,7 @@ # $Header$ # Source files in this directory -SRCS = ReductionSum.c Startup.c Reduction.c +SRCS = Reduction.c ReductionAvg.c ReductionCount.c ReductionMax.c ReductionMin.c ReductionNorm1.c ReductionNorm2.c ReductionNorm3.c ReductionNorm4.c ReductionNormInf.c ReductionSum.c Startup.c # Subdirectories containing source files SUBDIRS = |