From 02fcfe17b895d0632b5f1a9ce218d013bb5964ff Mon Sep 17 00:00:00 2001 From: schnetter Date: Wed, 28 Feb 2007 22:11:46 +0000 Subject: Add restrict qualifiers git-svn-id: http://svn.cactuscode.org/arrangements/CactusNumerical/Slab/trunk@54 2e825fa2-fb71-486d-8b7f-a5ff3f0f6cb8 --- src/slab.c | 261 +++++++++++++++++++++++++++++++++++-------------------------- src/slab.h | 44 ++++++----- 2 files changed, 173 insertions(+), 132 deletions(-) diff --git a/src/slab.c b/src/slab.c index 72c0e5c..6d44489 100644 --- a/src/slab.c +++ b/src/slab.c @@ -78,7 +78,8 @@ static int timer_copy_in; static int timer_xfer; static int timer_copy_back; -int Slab_InitTimers (void) +int +Slab_InitTimers (void) { timer_init = CCTK_TimerCreate ("Slab/init"); timer_copy_in = CCTK_TimerCreate ("Slab/copy in"); @@ -87,7 +88,8 @@ int Slab_InitTimers (void) return 0; } -int Slab_PrintTimers (void) +int +Slab_PrintTimers (void) { CCTK_TimerPrintDataI (timer_init , -1); CCTK_TimerPrintDataI (timer_copy_in , -1); @@ -422,7 +424,8 @@ normal_type (int cactustype) /* Find the MPI datatype corresponding to a Cactus datatype */ -static MPI_Datatype mpi_type (int const cactustype) +static MPI_Datatype +mpi_type (int const cactustype) { int const normaltype = normal_type (cactustype); switch (normaltype) { @@ -479,7 +482,8 @@ struct info { -static inline int roundup (int const x, int const y) +static inline int +roundup (int const x, int const y) { assert (x >= 0); assert (y > 0); @@ -488,7 +492,8 @@ static inline int roundup (int const x, int const y) -static void bbox_print (struct bbox const * restrict const bbox) +static void +bbox_print (struct bbox const * restrict const bbox) { assert (bbox); printf @@ -496,15 +501,17 @@ static void bbox_print (struct bbox const * restrict const bbox) bbox->off, bbox->off + (bbox->len - 1) * bbox->str, bbox->str); } -static void bbox_check (struct bbox const * restrict const bbox) +static void +bbox_check (struct bbox const * restrict const bbox) { assert (bbox); assert (bbox->len >= 0); assert (bbox->str > 0); } -static void global2bbox (struct slabinfo const * restrict const slab, - struct bbox * restrict const bbox) +static void +global2bbox (struct slabinfo const * restrict const slab, + struct bbox * restrict const bbox) { assert (slab); assert (bbox); @@ -515,8 +522,9 @@ static void global2bbox (struct slabinfo const * restrict const slab, bbox_check (bbox); } -static void local2bbox (struct slabinfo const * restrict const slab, - struct bbox * restrict const bbox) +static void +local2bbox (struct slabinfo const * restrict const slab, + struct bbox * restrict const bbox) { assert (slab); assert (bbox); @@ -529,9 +537,10 @@ static void local2bbox (struct slabinfo const * restrict const slab, bbox_check (bbox); } -static void active2bbox (struct slabinfo const * restrict const slab, - struct bbox * restrict const bbox, - int const useghosts) +static void +active2bbox (struct slabinfo const * restrict const slab, + struct bbox * restrict const bbox, + int const useghosts) { int nlghostzones; int nughostzones; @@ -552,8 +561,9 @@ static void active2bbox (struct slabinfo const * restrict const slab, bbox_check (bbox); } -static void slab2bbox (struct slabinfo const * restrict const slab, - struct bbox * restrict const bbox) +static void +slab2bbox (struct slabinfo const * restrict const slab, + struct bbox * restrict const bbox) { assert (slab); assert (bbox); @@ -563,8 +573,9 @@ static void slab2bbox (struct slabinfo const * restrict const slab, bbox_check (bbox); } -static int bbox_iscontained (struct bbox const * restrict const inner, - struct bbox const * restrict const outer) +static int +bbox_iscontained (struct bbox const * restrict const inner, + struct bbox const * restrict const outer) { int inner_last; int outer_last; @@ -575,8 +586,9 @@ static int bbox_iscontained (struct bbox const * restrict const inner, return inner->off >= outer->off && inner_last <= outer_last; } -static void bbox_clip (struct bbox * restrict const inner, - struct bbox const * restrict const outer) +static void +bbox_clip (struct bbox * restrict const inner, + struct bbox const * restrict const outer) { int inner_last; int outer_last; @@ -599,11 +611,12 @@ static void bbox_clip (struct bbox * restrict const inner, bbox_check (inner); } -static void bbox_xform (struct bbox * restrict const ydst, - struct bbox const * restrict const ysrc, - struct bbox const * restrict const xdst, - struct bbox const * restrict const xsrc, - int const flip) +static void +bbox_xform (struct bbox * restrict const ydst, + struct bbox const * restrict const ysrc, + struct bbox const * restrict const xdst, + struct bbox const * restrict const xsrc, + int const flip) { int xsrc_last; int xdst_last; @@ -636,8 +649,8 @@ static void bbox_xform (struct bbox * restrict const ydst, void -print_slabinfo (FILE * const out, - struct slabinfo const * const slabinfo) +print_slabinfo (FILE * const out, + struct slabinfo const * restrict const slabinfo) { fprintf (out, " gsh: %d\n", slabinfo->gsh); fprintf (out, " lbnd: %d, lsh: %d\n", slabinfo->lbnd, slabinfo->lsh); @@ -648,8 +661,8 @@ print_slabinfo (FILE * const out, } void -print_xferinfo (FILE * const out, - struct xferinfo const * const xferinfo) +print_xferinfo (FILE * const out, + struct xferinfo const * restrict const xferinfo) { fprintf (out, " src:\n"); print_slabinfo (out, & xferinfo->src); @@ -661,15 +674,16 @@ print_xferinfo (FILE * const out, -int Slab_MultiTransfer (cGH const * const cctkGH, - int const dim, - struct xferinfo const * const xferinfo, - int const options, - int const nvars, - int const * const srctypes, - void const * const * const srcptrs, - int const * const dsttypes, - void * const * const dstptrs) +int +Slab_MultiTransfer (cGH const * restrict const cctkGH, + int const dim, + struct xferinfo const * restrict const xferinfo, + int const options, + int const nvars, + int const * restrict const srctypes, + void const * restrict const * restrict const srcptrs, + int const * restrict const dsttypes, + void * restrict const * restrict const dstptrs) { DECLARE_CCTK_PARAMETERS; @@ -1134,7 +1148,9 @@ int Slab_MultiTransfer (cGH const * const cctkGH, check (SLAB_MAXDIM == 3); if (info[0].xpose==0 && info[1].xpose==1 && info[2].xpose==2 - && srcdetail[n*SLAB_MAXDIM ].str==1 && srcdetail[n*SLAB_MAXDIM+1].str==1 && srcdetail[n*SLAB_MAXDIM+2].str==1 + && srcdetail[n*SLAB_MAXDIM ].str==1 + && srcdetail[n*SLAB_MAXDIM+1].str==1 + && srcdetail[n*SLAB_MAXDIM+2].str==1 && srctype == CCTK_VARIABLE_REAL) { /* Optimised version for a special case: no transposing */ @@ -1164,20 +1180,24 @@ int Slab_MultiTransfer (cGH const * const cctkGH, int const srcindi = srcdetailoffi + i - srcoffi; int const srcindj = srcdetailoffj + j - srcoffj; int const srcindk = srcdetailoffk + k - srcoffk; - size_t const srcind = srcindi + srcleni * (srcindj + srclenj * srcindk); + size_t const srcind + = srcindi + srcleni * (srcindj + srclenj * srcindk); size_t const bufind = i + srcdetailleni * (j + srcdetaillenj * k); ifcheck assert (srcindi>=0 && srcindi=0 && srcindj=0 && srcindk=0 && srcindi=0 && srcindj=0 && srcindk= allinfo[n*SLAB_MAXDIM+c].src.slab.off && srcipos[c] <= allinfo[n*SLAB_MAXDIM+c].src.slab.off + (allinfo[n*SLAB_MAXDIM+c].src.slab.len - 1)); bufipos[d] = ipos[d]; - assert (bufipos[d] >= 0 && bufipos[d] < srcdetail[n*SLAB_MAXDIM+c].len); + assert (bufipos[d] >= 0 + && bufipos[d] < srcdetail[n*SLAB_MAXDIM+c].len); } srcind = 0; bufind = 0; @@ -1254,8 +1279,8 @@ int Slab_MultiTransfer (cGH const * const cctkGH, assert (srcind < srclentot); assert (bufind < (size_t)srccount[n]); for (var=0; var=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk=0 && dstindi=0 && dstindj=0 && dstindk