diff options
author | tradke <tradke@d60812e6-3970-4df4-986e-c251b06effeb> | 2003-03-10 13:10:47 +0000 |
---|---|---|
committer | tradke <tradke@d60812e6-3970-4df4-986e-c251b06effeb> | 2003-03-10 13:10:47 +0000 |
commit | f69684d7aba78edce0e0465e8ba338ae19a1e4b7 (patch) | |
tree | a1dcfc5e5c9db511b4129a7b637a5c8d2f2a419d | |
parent | 5a55318a46ef9e35ff93d0b36bd4053a1734c61a (diff) |
Almost forgot to commit this: added 'const' qualifiers to all the read-only
input arguments for the reduction API.
You also need an up-to-date flesh now in order to compile.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHReduce/trunk@35 d60812e6-3970-4df4-986e-c251b06effeb
-rw-r--r-- | src/Reduction.c | 169 | ||||
-rw-r--r-- | src/ReductionMax.c | 140 | ||||
-rw-r--r-- | src/ReductionMin.c | 140 | ||||
-rw-r--r-- | src/ReductionNorm1.c | 130 | ||||
-rw-r--r-- | src/ReductionNorm2.c | 128 | ||||
-rw-r--r-- | src/ReductionNormInf.c | 130 | ||||
-rw-r--r-- | src/ReductionSum.c | 152 | ||||
-rw-r--r-- | src/Startup.c | 2 | ||||
-rw-r--r-- | src/make.code.defn | 4 | ||||
-rw-r--r-- | src/pugh_reductions.h | 34 |
10 files changed, 513 insertions, 516 deletions
diff --git a/src/Reduction.c b/src/Reduction.c index 388fdd6..a088414 100644 --- a/src/Reduction.c +++ b/src/Reduction.c @@ -2,9 +2,9 @@ @file Reduction.c @date Thu Apr 3 11:54:53 1997 @author Thomas Radke, Paul Walker - @desc - Various MPI reduction operators. - @enddesc + @desc + Various MPI reduction operators. + @enddesc @version $Id$ @@*/ @@ -20,15 +20,15 @@ CCTK_FILEVERSION(CactusPUGH_PUGHReduce_Reduction_c) ********************* Local Routine Prototypes ********************* ********************************************************************/ -static int PUGH_ReductionGA (cGH *GH, - int vindex, - int proc, - CCTK_REAL *outval, - reduction_fn_t reduction_fn); +static int ReductionGA (const cGH *GH, + int vindex, + int proc, + CCTK_REAL *outval, + reduction_fn_t reduction_fn); -static int PUGH_ReductionScalar (cGH *GH, int vindex, int proc, - CCTK_REAL *outval, - reduction_fn_t reduction_fn); +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 */], @@ -44,16 +44,16 @@ static int copy_real_to_outtype (int num_elems, @routine PUGH_ReductionArrays @author Thomas Radke @date 19 Aug 1999 - @desc + @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 cGH * + @vtype const cGH * @vio in @endvar @var proc @@ -84,7 +84,7 @@ static int copy_real_to_outtype (int num_elems, @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const * @vio in @endvar @var outtype @@ -115,13 +115,13 @@ static int copy_real_to_outtype (int num_elems, -2 if <num_outvals> is invalid @endreturndesc @@*/ -int PUGH_ReductionArrays (cGH *GH, +int PUGH_ReductionArrays (const cGH *GH, int proc, int num_dims, - int dims[/* num_dims */], + const int dims[/* num_dims */], int intype, int num_inarrays, - void *inarrays[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int outtype, int num_outvals, void *outvals /* [num_outvals] */, @@ -167,35 +167,35 @@ int PUGH_ReductionArrays (cGH *GH, /* set the array types to intype */ /* FIXME: could allow to pass in arrays of different types now !!! */ - intypes = (int *) malloc (num_inarrays * sizeof (int)); + intypes = malloc (num_inarrays * sizeof (int)); for (i = 0; i < num_inarrays; i++) { intypes[i] = intype; } - buffer = (CCTK_REAL *) malloc (num_outvals * sizeof (CCTK_REAL)); + buffer = malloc (num_outvals * sizeof (CCTK_REAL)); /* do the reduction on the input arrays */ - retval = reduction_fn (GH, - proc, - num_dims, - from, - to, - iterator, + retval = reduction_fn (GH, + proc, + num_dims, + from, + to, + iterator, points_per_dim, - num_points, - num_inarrays, - intypes, + num_points, + num_inarrays, + intypes, inarrays, - num_outvals, + num_outvals, buffer); if (retval == 0 && (proc < 0 || proc == CCTK_MyProc (GH))) { /* type-cast the result to the requested datatype */ - retval = copy_real_to_outtype (num_inarrays * num_outvals, + retval = copy_real_to_outtype (num_inarrays * num_outvals, buffer, - outtype, + outtype, outvals); } @@ -210,20 +210,20 @@ int PUGH_ReductionArrays (cGH *GH, @routine PUGH_ReductionGVs @author Thomas Radke @date 19 Aug 1999 - @desc + @desc Wrapper to reduce a list of grid variables. Just calls the appropriate reduction operator and does the type conversion of the results. @enddesc @calls CCTK_VarTypeSize CCTK_GroupTypeFromVarI - PUGH_ReductionGA - PUGH_ReductionScalar + ReductionGA + ReductionScalar copy_real_to_outtype - + @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in @endvar @var proc @@ -237,9 +237,9 @@ int PUGH_ReductionArrays (cGH *GH, @vtype int @vio in @endvar - @var inarrays + @var invars @vdesc field of input arrays - @vtype void ** + @vtype const int * @vio in @endvar @var outtype @@ -268,10 +268,10 @@ int PUGH_ReductionArrays (cGH *GH, the return code of the reduction operator @endreturndesc @@*/ -int PUGH_ReductionGVs (cGH *GH, +int PUGH_ReductionGVs (const cGH *GH, int proc, int num_invars, - int invars[/* num_invars */], + const int invars[/* num_invars */], int outtype, int num_outvals, void *outvals /* [num_outvals] */, @@ -304,12 +304,12 @@ int PUGH_ReductionGVs (cGH *GH, { case CCTK_GF: case CCTK_ARRAY: - this_retval = PUGH_ReductionGA (GH, invars[i], proc, &result, + this_retval = ReductionGA (GH, invars[i], proc, &result, reduction_fn); break; case CCTK_SCALAR: - this_retval = PUGH_ReductionScalar (GH, invars[i], proc, &result, + this_retval = ReductionScalar (GH, invars[i], proc, &result, reduction_fn); break; @@ -337,69 +337,71 @@ int PUGH_ReductionGVs (cGH *GH, ********************************************************************/ /*@@ - @routine PUGH_ReductionGA + @routine ReductionGA @date Fri Jun 29 15:35:01 2001 @author Tom Goodale - @desc - Reduction of a grid array variable. - @enddesc - + @desc + Reduction of a grid array variable. + @enddesc + @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in - @endvar + @endvar @var vindex @vdesc The GV index @vtype int @vio in - @endvar + @endvar @var proc @vdesc The processor at which we desire the result @vtype int @vio in - @endvar + @endvar @var outval @vdesc buffer to store the reduction result in @vtype CCTK_REAL * @vio out - @endvar + @endvar @var reduction_fn @vdesc The function which does the actual reduction @vtype reduction_fn_t @vio in - @endvar + @endvar @returntype int @returndesc The return code of the reduction operator. @endreturndesc @@*/ -static int PUGH_ReductionGA (cGH *GH, int vindex, int proc, CCTK_REAL *outval, - reduction_fn_t reduction_fn) +static int ReductionGA (const cGH *GH, int vindex, int proc, CCTK_REAL *outval, + reduction_fn_t reduction_fn) { int i, stagger_index, num_points, dir_points, retval; pGA *GA; + const void *data; char *fullname; int *from, *to, *iterator, *points_per_dim; /* get the GA structure for the current timelevel */ GA = ((pGA ***) PUGH_pGH (GH)->variables)[vindex][0]; + data = GA->data; /* check for zero-sized arrays */ if (GA->extras->npoints <= 0) { fullname = CCTK_FullName (vindex); CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "PUGH_ReductionGA: Cannot reduce zero-sized grid array '%s'", + "ReductionGA: Cannot reduce zero-sized grid array '%s'", fullname); free (fullname); return (-1); } /* allocate temporary vectors */ - from = (int *) malloc (4 * GA->connectivity->dim * sizeof (int)); + from = malloc (4 * GA->connectivity->dim * sizeof (int)); to = from + 1*GA->connectivity->dim; iterator = from + 2*GA->connectivity->dim; points_per_dim = from + 3*GA->connectivity->dim; @@ -439,7 +441,7 @@ static int PUGH_ReductionGA (cGH *GH, int vindex, int proc, CCTK_REAL *outval, /* now do the reduction */ retval = reduction_fn (GH, proc, GA->connectivity->dim, from, to, iterator, - points_per_dim, num_points, 1, &GA->vtype, &GA->data, + points_per_dim, num_points, 1, &GA->vtype, &data, 1, outval); /* free temporary vectors */ @@ -450,59 +452,58 @@ static int PUGH_ReductionGA (cGH *GH, int vindex, int proc, CCTK_REAL *outval, /*@@ - @routine PUGH_ReductionScalar + @routine ReductionScalar @date Fri Jun 29 15:35:01 2001 @author Tom Goodale - @desc - Reduction of a scalar GV. - Basically a copy of PUGH_ReductionGA cut down to the scalar case. - @enddesc - + @desc + Reduction of a scalar GV. + Basically a copy of ReductionGA cut down to the scalar case. + @enddesc + @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH * + @vtype const cGH * @vio in - @endvar + @endvar @var vindex @vdesc The GV index @vtype int @vio in - @endvar + @endvar @var proc @vdesc The processor at which we desire the result @vtype int @vio in - @endvar + @endvar @var outval @vdesc buffer to store the reduction result in @vtype CCTK_REAL * @vio out - @endvar + @endvar @var reduction_fn @vdesc The function which does the actual reduction @vtype reduction_fn_t @vio in - @endvar + @endvar @returntype int @returndesc The return code of the reduction operator. @endreturndesc @@*/ -static int PUGH_ReductionScalar (cGH *GH, - int vindex, - int proc, - CCTK_REAL *outval, - reduction_fn_t reduction_fn) +static int ReductionScalar (const cGH *GH, + int vindex, + int proc, + CCTK_REAL *outval, + reduction_fn_t reduction_fn) { int retval; - int num_points, from, to, iterator, points_per_dim, type; - - void *data; + const void *data; + /* get the data for the current timelevel */ - data = ((void ***) PUGH_pGH (GH)->variables)[vindex][0]; + data = ((const void ***) PUGH_pGH (GH)->variables)[vindex][0]; from = 0; to = 1; @@ -525,16 +526,16 @@ static int PUGH_ReductionScalar (cGH *GH, @routine copy_real_to_outtype @author Thomas Radke @date 19 Aug 1999 - @desc + @desc Does the type conversion from CCTK_REAL into the requested datatype. @enddesc @calls CCTK_VarTypeSize CCTK_GroupTypeFromVarI - PUGH_ReductionGA - PUGH_ReductionScalar + ReductionGA + ReductionScalar copy_real_to_outtype - + @var num_elems @vdesc number of elements to convert @vtype int diff --git a/src/ReductionMax.c b/src/ReductionMax.c index e2f3eb2..06c28ab 100644 --- a/src/ReductionMax.c +++ b/src/ReductionMax.c @@ -2,11 +2,11 @@ @file ReductionMax.c @date Thu Apr 3 11:54:53 1997 @author Thomas Radke, Paul Walker - @desc + @desc Defines the PUGH reduction operator to get the maximum for a set of arbitrary arrays. - @enddesc - @version $Header$ + @enddesc + @version $Id$ @@*/ #include <stdlib.h> @@ -19,19 +19,19 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionMax_c) /* local function prototypes */ -static int PUGH_ReductionMaxVal (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -48,74 +48,74 @@ static int PUGH_ReductionMaxVal (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_dims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var num_inarrays @vdesc number of input arrays @vtype int @vio in - @endvar + @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const * @vio in - @endvar + @endvar @var intype @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionMaxValArrays (cGH *GH, - int proc, - int num_dims, - int dims[/* num_dims */], - int num_inarrays, - void *inarrays[/* num_inarrays */], +int PUGH_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, + int num_outvals, void *outvals /* [num_outvals] */, int outtype) { return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionMaxVal)); + ReductionMaxVal)); } @@ -133,55 +133,55 @@ int PUGH_ReductionMaxValArrays (cGH *GH, results of the local reductions. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_outvals @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionMaxValGVs (cGH *GH, - int proc, +int PUGH_ReductionMaxValGVs (const cGH *GH, + int proc, int num_outvals, - int outtype, + int outtype, void *outvals /* [num_outvals] */, - int num_invars, - int invars[/* num_invars */]) + int num_invars, + const int invars[/* num_invars */]) { - return (PUGH_ReductionGVs (GH, proc, num_invars, invars, + return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionMaxVal)); + ReductionMaxVal)); } @@ -189,7 +189,7 @@ int PUGH_ReductionMaxValGVs (cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionMaxVal + @routine ReductionMaxVal @date Aug 19 1999 @author Thomas Radke @desc Returns the maximum of a distributed array with @@ -197,19 +197,19 @@ int PUGH_ReductionMaxValGVs (cGH *GH, (num_outvals == 1) or on the results of the local reductions. @enddesc @@*/ -static int PUGH_ReductionMaxVal (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +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 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; #ifdef CCTK_MPI @@ -314,7 +314,7 @@ static int PUGH_ReductionMaxVal (cGH *GH, /* do the global reduction from the processors' local reduction results */ if (pughGH->nprocs > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local maximum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/ReductionMin.c b/src/ReductionMin.c index b1b9492..2d7d494 100644 --- a/src/ReductionMin.c +++ b/src/ReductionMin.c @@ -2,11 +2,11 @@ @file ReductionMin.c @date Thu Apr 3 11:54:53 1997 @author Thomas Radke, Paul Walker - @desc + @desc Defines the PUGH reduction operator to get the minimum for a set of arbitrary arrays. - @enddesc - @version $Header$ + @enddesc + @version $Id$ @@*/ #include <stdlib.h> @@ -19,19 +19,19 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionMin_c) /* local function prototypes */ -static int PUGH_ReductionMinVal (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -48,74 +48,74 @@ static int PUGH_ReductionMinVal (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_dims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var num_inarrays @vdesc number of input arrays @vtype int @vio in - @endvar + @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const * @vio in - @endvar + @endvar @var intype @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionMinValArrays (cGH *GH, - int proc, - int num_dims, - int dims[/* num_dims */], - int num_inarrays, - void *inarrays[/* num_inarrays */], +int PUGH_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, + int num_outvals, void *outvals /* [num_outvals] */, int outtype) { return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionMinVal)); + ReductionMinVal)); } @@ -133,55 +133,55 @@ int PUGH_ReductionMinValArrays (cGH *GH, results of the local reductions. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_outvals @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionMinValGVs (cGH *GH, - int proc, +int PUGH_ReductionMinValGVs (const cGH *GH, + int proc, int num_outvals, - int outtype, + int outtype, void *outvals /* [num_outvals] */, - int num_invars, - int invars[/* num_invars */]) + int num_invars, + const int invars[/* num_invars */]) { - return (PUGH_ReductionGVs (GH, proc, num_invars, invars, + return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionMinVal)); + ReductionMinVal)); } @@ -189,7 +189,7 @@ int PUGH_ReductionMinValGVs (cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionMinVal + @routine ReductionMinVal @date Aug 19 1999 @author Thomas Radke @desc Returns the minimum for a set of distributed array with @@ -198,19 +198,19 @@ int PUGH_ReductionMinValGVs (cGH *GH, or on the results of the local reductions. @enddesc @@*/ -static int PUGH_ReductionMinVal (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +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 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; #ifdef CCTK_MPI @@ -315,7 +315,7 @@ static int PUGH_ReductionMinVal (cGH *GH, /* do the global reduction from the processors' local reduction results */ if (pughGH->nprocs > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local minimum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/ReductionNorm1.c b/src/ReductionNorm1.c index 83e24b9..f621602 100644 --- a/src/ReductionNorm1.c +++ b/src/ReductionNorm1.c @@ -2,12 +2,12 @@ @file ReductionNorm1.c @date Thu Apr 3 11:54:53 1997 @author Thomas Radke, Paul Walker - @desc + @desc Defines the PUGH reduction operator to get the norm of an arbitrary array which is defined as: norm1 = $\Sigma |a_i| / np$ - @enddesc - @version $Header$ + @enddesc + @version $Id$ @@*/ #include <stdlib.h> @@ -20,19 +20,19 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionNorm1_c) /* local function prototypes */ -static int PUGH_ReductionNorm1 (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -52,65 +52,65 @@ static int PUGH_ReductionNorm1 (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_dims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var num_arrays @vdesc number of input arrays @vtype int @vio in - @endvar + @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const @vio in - @endvar + @endvar @var intype @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNorm1Arrays (cGH *GH, +int PUGH_ReductionNorm1Arrays (const cGH *GH, int proc, int num_dims, - int dims[/* num_dims */], + const int dims[/* num_dims */], int num_inarrays, - void *inarrays[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int intype, int num_outvals, void *outvals /* [num_outvals] */, @@ -119,7 +119,7 @@ int PUGH_ReductionNorm1Arrays (cGH *GH, return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionNorm1)); + ReductionNorm1)); } @@ -135,55 +135,55 @@ int PUGH_ReductionNorm1Arrays (cGH *GH, reductions, so num_outvals must be 1. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var nOutVars @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNorm1GVs (cGH *GH, - int proc, +int PUGH_ReductionNorm1GVs (const cGH *GH, + int proc, int num_outvals, - int outtype, + int outtype, void *outvals /* [num_outvals] */, int num_invars, - int invars[/* num_invars */]) + const int invars[/* num_invars */]) { return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionNorm1)); + ReductionNorm1)); } @@ -199,21 +199,21 @@ int PUGH_ReductionNorm1GVs (cGH *GH, (num_outvals == 1) or on the results of the local reductions. "norm1" is defined as $\Sigma |a_i| / np$. - @enddesc + @enddesc @@*/ -static int PUGH_ReductionNorm1 (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +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 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; pGH *pughGH; @@ -321,9 +321,9 @@ static int PUGH_ReductionNorm1 (cGH *GH, #ifdef CCTK_MPI /* do the global reduction from the processors' local reduction results */ - if (pughGH->nprocs > 1) + if (pughGH->nprocs > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local sum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/ReductionNorm2.c b/src/ReductionNorm2.c index 3108075..737a095 100644 --- a/src/ReductionNorm2.c +++ b/src/ReductionNorm2.c @@ -7,7 +7,7 @@ of an arbitrary array which is defined as: norm2 = $\sqrt{\Sigma (a_i * a_i) / np}$ @enddesc - @version $Header$ + @version $Id$ @@*/ #include <math.h> @@ -21,19 +21,19 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionNorm2_c) /* local function prototypes */ -static int PUGH_ReductionNorm2 (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -53,65 +53,65 @@ static int PUGH_ReductionNorm2 (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_dims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var num_arrays @vdesc number of input arrays @vtype int @vio in - @endvar + @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const @vio in - @endvar + @endvar @var intype @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNorm2Arrays (cGH *GH, +int PUGH_ReductionNorm2Arrays (const cGH *GH, int proc, int num_dims, - int dims[/* num_dims */], + const int dims[/* num_dims */], int num_inarrays, - void *inarrays[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int intype, int num_outvals, void *outvals /* [num_outvals] */, @@ -120,7 +120,7 @@ int PUGH_ReductionNorm2Arrays (cGH *GH, return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionNorm2)); + ReductionNorm2)); } @@ -136,55 +136,55 @@ int PUGH_ReductionNorm2Arrays (cGH *GH, reductions, so num_outvals must be 1. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var nOutVars @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNorm2GVs (cGH *GH, - int proc, +int PUGH_ReductionNorm2GVs (const cGH *GH, + int proc, int num_outvals, - int outtype, + int outtype, void *outvals /* [num_outvals] */, int num_invars, - int invars[/* num_invars */]) + const int invars[/* num_invars */]) { return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionNorm2)); + ReductionNorm2)); } @@ -192,7 +192,7 @@ int PUGH_ReductionNorm2GVs (cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionNorm2 + @routine ReductionNorm2 @date Aug 19 1999 @author Thomas Radke @desc Returns the "norm2" of a distributed array with @@ -200,21 +200,21 @@ int PUGH_ReductionNorm2GVs (cGH *GH, (num_outvals == 1) or on the results of the local reductions. "norm2" is defined as $\sqrt{\Sigma (a_i * a_i) / np}$. - @enddesc + @enddesc @@*/ -static int PUGH_ReductionNorm2 (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +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 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; pGH *pughGH; @@ -321,9 +321,9 @@ static int PUGH_ReductionNorm2 (cGH *GH, #ifdef CCTK_MPI /* do the global reduction from the processors' local reduction results */ - if (pughGH->nprocs > 1) + if (pughGH->nprocs > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local sum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/ReductionNormInf.c b/src/ReductionNormInf.c index 0feb79a..c304477 100644 --- a/src/ReductionNormInf.c +++ b/src/ReductionNormInf.c @@ -2,11 +2,11 @@ @file ReductionNormInf.c @date Sat Aug 25, 2001 @author Thomas Radke, Paul Walker, Erik Schnetter - @desc + @desc Defines the PUGH reduction operator to get the norm of an arbitrary array which is defined as: norm_inf = $\max |a_i| $ - @enddesc + @enddesc @version $Id$ @@*/ @@ -20,19 +20,19 @@ static const char *rcsid = "$Header$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionNormInf_c) /* local function prototypes */ -static int PUGH_ReductionNormInf (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -52,65 +52,65 @@ static int PUGH_ReductionNormInf (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_dims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var num_arrays @vdesc number of input arrays @vtype int @vio in - @endvar + @endvar @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const @vio in - @endvar + @endvar @var intype @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNormInfArrays (cGH *GH, +int PUGH_ReductionNormInfArrays (const cGH *GH, int proc, int num_dims, - int dims[/* num_dims */], + const int dims[/* num_dims */], int num_inarrays, - void *inarrays[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int intype, int num_outvals, void *outvals /* [num_outvals] */, @@ -119,7 +119,7 @@ int PUGH_ReductionNormInfArrays (cGH *GH, return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionNormInf)); + ReductionNormInf)); } @@ -135,55 +135,55 @@ int PUGH_ReductionNormInfArrays (cGH *GH, reductions, so num_outvals must be 1. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var nOutVars @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionNormInfGVs (cGH *GH, - int proc, +int PUGH_ReductionNormInfGVs (const cGH *GH, + int proc, int num_outvals, - int outtype, + int outtype, void *outvals /* [num_outvals] */, int num_invars, - int invars[/* num_invars */]) + const int invars[/* num_invars */]) { return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionNormInf)); + ReductionNormInf)); } @@ -191,7 +191,7 @@ int PUGH_ReductionNormInfGVs (cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionNormInf + @routine ReductionNormInf @date Aug 19 1999 @author Thomas Radke @desc Returns the "norm_inf" of a distributed array with @@ -199,21 +199,21 @@ int PUGH_ReductionNormInfGVs (cGH *GH, (num_outvals == 1) or on the results of the local reductions. "norm_inf" is defined as $\max |a_i|$. - @enddesc + @enddesc @@*/ -static int PUGH_ReductionNormInf (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +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 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; #ifdef CCTK_MPI @@ -330,9 +330,9 @@ static int PUGH_ReductionNormInf (cGH *GH, #ifdef CCTK_MPI /* do the global reduction from the processors' local reduction results */ - if (CCTK_nProcs (GH) > 1) + if (CCTK_nProcs (GH) > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local sum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/ReductionSum.c b/src/ReductionSum.c index 64ef497..ffeb39e 100644 --- a/src/ReductionSum.c +++ b/src/ReductionSum.c @@ -2,11 +2,11 @@ @file ReductionSum.c @date Thu Apr 3 11:54:53 1997 @author Thomas Radke, Paul Walker - @desc + @desc Defines the PUGH reduction operator to get the sum of an arbitrary array. - @enddesc - @version $Header$ + @enddesc + @version $Id$ @@*/ #include <stdlib.h> @@ -19,19 +19,19 @@ static const char *rcsid = "$Id$"; CCTK_FILEVERSION(CactusPUGH_PUGHReduce_ReductionSum_c) /* local function prototypes */ -static int PUGH_ReductionSum (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); +static int ReductionSum (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 num_inarrays, + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], + int num_outvals, + CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); /*@@ @@ -48,74 +48,74 @@ static int PUGH_ReductionSum (cGH *GH, is always computed as a CCTK_REAL value internally. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var nDims @vdesc number of dimensions of input arrays @vtype int @vio in - @endvar + @endvar @var dims @vdesc dimensions of input arrays - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @var nArrays @vdesc number of input arrays @vtype int @vio in - @endvar - @var inArrays + @endvar + @var inarrays @vdesc field of input arrays - @vtype void ** + @vtype const void *const @vio in - @endvar + @endvar @var inType @vdesc (common) variable type of input arrays @vtype int @vio in - @endvar + @endvar @var num_outvals @vdesc number of values per output array @vtype int @vio in - @endvar + @endvar @var outvals @vdesc pointer to buffer holding the output values @vtype void * @vio in - @endvar + @endvar @var outtype @vdesc (common) variable type of output arrays @vtype int @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionSumArrays (cGH *GH, - int proc, - int num_dims, - int dims[/* num_dims */], - int num_inarrays, - void *inarrays[/* num_inarrays */], - int intype, - int num_outvals, - void *outvals /* [num_outvals] */, - int outtype) +int PUGH_ReductionSumArrays (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) { return (PUGH_ReductionArrays (GH, proc, num_dims, dims, intype, num_inarrays, inarrays, outtype, num_outvals, outvals, - PUGH_ReductionSum)); + ReductionSum)); } @@ -133,55 +133,55 @@ int PUGH_ReductionSumArrays (cGH *GH, results of the local reductions. @enddesc @history - @endhistory + @endhistory @var GH @vdesc Pointer to CCTK grid hierarchy - @vtype cGH + @vtype const cGH * @vio in - @endvar + @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 + @endvar @var num_outvals @vdesc number of requested output elements @vtype int @vio in - @endvar + @endvar @var outtype @vdesc type of return value @vtype int @vio in - @endvar + @endvar @var outvals @vdesc array for the result values to be stored @vtype void * @vio in - @endvar + @endvar @var num_invars @vdesc number of variables in the list @vtype int @vio in - @endvar + @endvar @var invars @vdesc list of variables (given as their global indices) - @vtype int * + @vtype const int * @vio in - @endvar + @endvar @@*/ -int PUGH_ReductionSumGVs (cGH *GH, - int proc, - int num_outvals, - int outtype, - void *outvals /* [num_outvals] */, - int num_invars, - int invars[/* num_invars */]) +int PUGH_ReductionSumGVs (const cGH *GH, + int proc, + int num_outvals, + int outtype, + void *outvals /* [num_outvals] */, + int num_invars, + const int invars[/* num_invars */]) { - return (PUGH_ReductionGVs (GH, proc, num_invars, invars, + return (PUGH_ReductionGVs (GH, proc, num_invars, invars, outtype, num_outvals, outvals, - PUGH_ReductionSum)); + ReductionSum)); } @@ -189,7 +189,7 @@ int PUGH_ReductionSumGVs (cGH *GH, /* local functions */ /*****************************************************************************/ /*@@ - @routine PUGH_ReductionSum + @routine ReductionSum @date Aug 19 1999 @author Thomas Radke @desc Returns the sum of a distributed array with @@ -197,19 +197,19 @@ int PUGH_ReductionSumGVs (cGH *GH, (num_outvals == 1) or on the results of the local reductions. @enddesc @@*/ -static int PUGH_ReductionSum (cGH *GH, - int proc, - int num_dims, - int from[/* dim */], - int to[/* dim */], - int iterator[/* dim */], - int points_per_dim[/* dim */], - int num_points, - int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], - int num_outvals, - CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) +static int ReductionSum (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 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; #ifdef CCTK_MPI @@ -314,7 +314,7 @@ static int PUGH_ReductionSum (cGH *GH, /* do the global reduction from the processors' local reduction results */ if (pughGH->nprocs > 1) { - local_outvals = (CCTK_REAL *) malloc (total_outvals * sizeof (CCTK_REAL)); + local_outvals = malloc (total_outvals * sizeof (CCTK_REAL)); /* outvals[] contains now the local sum */ memcpy (local_outvals, outvals, total_outvals * sizeof (CCTK_REAL)); diff --git a/src/Startup.c b/src/Startup.c index 0a9e3ff..b069e3f 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -5,7 +5,7 @@ @desc Startup routines for PUGHReduce. @enddesc - @version $Header$ + @version $Id$ @@*/ #include "cctk.h" diff --git a/src/make.code.defn b/src/make.code.defn index ef01b8c..6094737 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -3,7 +3,3 @@ # Source files in this directory SRCS = ReductionMax.c ReductionMin.c ReductionNorm1.c ReductionNorm2.c ReductionNormInf.c ReductionSum.c Startup.c Reduction.c - -# Subdirectories containing source files -SUBDIRS = - diff --git a/src/pugh_reductions.h b/src/pugh_reductions.h index af7586a..88a52a4 100644 --- a/src/pugh_reductions.h +++ b/src/pugh_reductions.h @@ -1,11 +1,11 @@ /*@@ @header pugh_reductions.h @date April 29 1999 - @author Gabrielle - @desc - Prototypes for pugh reduction operators - @enddesc - @version $Header$ + @author Gabrielle Allen + @desc + Prototypes for pugh reduction operators + @enddesc + @version $Header$ @@*/ #ifndef _PUGH_REDUCTIONS_H_ @@ -63,7 +63,7 @@ outvals_type, outvals, num_outvals, total_outvals) \ { \ int _i, _j, _dim, _vindex; \ - cctk_type *typed_vdata = (cctk_type *) (vdata); \ + const cctk_type *typed_vdata = (vdata); \ outvals_type typed_outval; \ \ \ @@ -147,35 +147,35 @@ int PUGH_ReductionNorm1Arrays (REDUCTION_ARRAY_OPERATOR_REGISTER_ARGLIST); int PUGH_ReductionNorm2Arrays (REDUCTION_ARRAY_OPERATOR_REGISTER_ARGLIST); int PUGH_ReductionNormInfArrays (REDUCTION_ARRAY_OPERATOR_REGISTER_ARGLIST); -typedef int (*reduction_fn_t) (cGH *GH, +typedef int (*reduction_fn_t) (const cGH *GH, int proc, int num_dims, - int from[/* dim */], - int to[/* dim */], + const int from[/* dim */], + const int to[/* dim */], int iterator[/* dim */], - int points_per_dim[/* dim */], + const int points_per_dim[/* dim */], int num_points, int num_inarrays, - int intypes[/* num_inarrays */], - void *inarrays[/* num_inarrays */], + const int intypes[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int num_outvals, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]); -int PUGH_ReductionGVs (cGH *GH, +int PUGH_ReductionGVs (const cGH *GH, int proc, int num_invars, - int invars[/* num_invars */], + const int invars[/* num_invars */], int outtype, int num_outvals, void *outvals /* [num_outvals] */, reduction_fn_t reduction_fn); -int PUGH_ReductionArrays (cGH *GH, +int PUGH_ReductionArrays (const cGH *GH, int proc, int num_dims, - int dims[/* num_dims */], + const int dims[/* num_dims */], int intype, int num_inarrays, - void *inarrays[/* num_inarrays */], + const void *const inarrays[/* num_inarrays */], int outtype, int num_outvals, void *outvals /* [num_outvals] */, |