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/ReductionSum.c | |
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/ReductionSum.c')
-rw-r--r-- | src/ReductionSum.c | 179 |
1 files changed, 80 insertions, 99 deletions
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 " |