diff options
-rw-r--r-- | Carpet/LoopControl/src/loopcontrol.c | 18 | ||||
-rw-r--r-- | Carpet/LoopControl/src/loopcontrol.h | 67 | ||||
-rw-r--r-- | Carpet/LoopControl/src/wavetoy-loopcontrol.c | 4 |
3 files changed, 27 insertions, 62 deletions
diff --git a/Carpet/LoopControl/src/loopcontrol.c b/Carpet/LoopControl/src/loopcontrol.c index a0bbe564b..fa2761717 100644 --- a/Carpet/LoopControl/src/loopcontrol.c +++ b/Carpet/LoopControl/src/loopcontrol.c @@ -1,3 +1,7 @@ +#include <cctk.h> +#include <cctk_Arguments.h> +#include <cctk_Parameters.h> + #include <assert.h> #include <errno.h> #include <float.h> @@ -12,9 +16,6 @@ # include <omp.h> #endif -#include <cctk.h> -#include <cctk_Parameters.h> - /* #ifdef HAVE_TGMATH_H */ /* # include <tgmath.h> */ /* #endif */ @@ -854,12 +855,6 @@ lc_control_init (lc_control_t * restrict const lc, lc->jjjstep = (lc->jjjmax - lc->jjjmin + lt->jnthreads-1) / lt->jnthreads; lc->kkkstep = (lc->kkkmax - lc->kkkmin + lt->knthreads-1) / lt->knthreads; -#if 0 - /* Correct threading for vectorisation (cache line size) */ - lc->iiistep = - (lc->iiistep + LC_VECTORSIZE - 1) / LC_VECTORSIZE * LC_VECTORSIZE; -#endif - /* Find location of current thread */ lc->thread_num = omp_get_thread_num(); int c = lc->thread_num; @@ -886,11 +881,6 @@ lc_control_init (lc_control_t * restrict const lc, lc->jjstep = lt->jnpoints; lc->kkstep = lt->knpoints; -#if 0 - /* Correct tiling for vectorisation (cache line size) */ - lc->iistep = (lc->iistep + LC_VECTORSIZE - 1) / LC_VECTORSIZE * LC_VECTORSIZE; -#endif - /*** Inner threads **********************************************************/ diff --git a/Carpet/LoopControl/src/loopcontrol.h b/Carpet/LoopControl/src/loopcontrol.h index e23806fcb..70d90ebb5 100644 --- a/Carpet/LoopControl/src/loopcontrol.h +++ b/Carpet/LoopControl/src/loopcontrol.h @@ -6,16 +6,14 @@ #include <cctk.h> -#ifdef CCODE -#include <cctk_Arguments.h> + +#ifdef CCODE #ifdef __cplusplus extern "C" { #endif - - #ifdef __cplusplus # ifdef CCTK_CXX_RESTRICT # define restrict CCTK_CXX_RESTRICT @@ -24,36 +22,6 @@ extern "C" { -#if 0 -/* The most simple implementation */ - -#define LC_LOOP3(name, i,j,k, imin,jmin,kmin, imax,jmax,kmax, ilsh,jlsh,klsh) \ - do { \ - int const lc_imin = (imin); \ - int const lc_jmin = (jmin); \ - int const lc_kmin = (kmin); \ - int const lc_imax = (imax); \ - int const lc_jmax = (jmax); \ - int const lc_kmax = (kmax); \ - for (int k = lc_kmin; k < lc_kmax; ++k) \ - for (int j = lc_jmin; j < lc_jmax; ++j) \ - for (int i = lc_imin; i < lc_imax; ++i) - -#define LC_ENDLOOP3(name) \ - } while (0) - -#endif - - - -#if 0 -/* Vector size */ -#define LC_VECTORSIZE 2 /* Correct for double precision on - Intel */ -#endif - - - /* A topology */ typedef struct lc_topology_t { int nthreads[2][3]; /* [0:outer|1:inner][ijk] */ @@ -319,6 +287,7 @@ lc_control_finish (lc_control_t * restrict lc); #define LC_LOOP3VEC(name, i,j,k, imin_,jmin_,kmin_, imax_,jmax_,kmax_, ilsh_,jlsh_,klsh_, di_) \ do { \ + typedef int lc_loop3vec_##name; \ static int lc_initialised = 0; \ static lc_statmap_t lc_lm; \ if (! lc_initialised) { \ @@ -364,16 +333,17 @@ lc_control_finish (lc_control_t * restrict lc); int const lc_ioffset = (lc_ipos & - lc_di) - lc_ipos; \ for (int i = lc_imin + lc_ioffset; i < lc_imax; i += lc_di) { -#define LC_ENDLOOP3VEC(name) \ - } \ - } \ - LC_POSTLOOP_STATEMENTS \ - } \ - } \ - } \ - } \ - } \ - lc_control_finish (& lc_lc); \ +#define LC_ENDLOOP3VEC(name) \ + } \ + } \ + LC_POSTLOOP_STATEMENTS \ + } \ + } \ + } \ + } \ + } \ + lc_control_finish (& lc_lc); \ + typedef lc_loop3vec_##name lc_ensure_proper_nesting; \ } while (0) /* Pre- and post loop statements are inserted around the innermost @@ -383,8 +353,13 @@ lc_control_finish (lc_control_t * restrict lc); -void -lc_printstats (CCTK_ARGUMENTS); +/* Replace CCTK_LOOP macros */ +#undef CCTK_LOOP3 +#undef CCTK_ENDLOOP3 +#define CCTK_LOOP3 LC_LOOP3 +#define CCTK_ENDLOOP3 LC_ENDLOOP3 + + #ifdef __cplusplus } diff --git a/Carpet/LoopControl/src/wavetoy-loopcontrol.c b/Carpet/LoopControl/src/wavetoy-loopcontrol.c index c5ea9fecb..cdf61d1f2 100644 --- a/Carpet/LoopControl/src/wavetoy-loopcontrol.c +++ b/Carpet/LoopControl/src/wavetoy-loopcontrol.c @@ -255,10 +255,10 @@ int lc_demo (void) double sum = 0.0; #pragma omp parallel reduction(+: sum) { - LC_LOOP3 (analysis, i,j,k, 1,1,1, NI-1,NJ-1,NK-1, NI,NJ,NK) { + CCTK_LOOP3 (analysis, i,j,k, 1,1,1, NI-1,NJ-1,NK-1, NI,NJ,NK) { int const ind = ind3d(i,j,k); sum += phi0[ind]; - } LC_ENDLOOP3 (analysis); + } CCTK_ENDLOOP3 (analysis); } double const avg = sum / ((NI-2)*(NJ-2)*(NK-2)); double const time_analysis_end = omp_get_wtime(); |