aboutsummaryrefslogtreecommitdiff
path: root/Carpet/LoopControl
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2011-11-14 15:15:45 -0500
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 19:54:55 +0000
commit5ff430c182026c42efaa290bf533e3486a4d8541 (patch)
tree2d457a20d54ce69bb2b10a422558954821464e70 /Carpet/LoopControl
parent3489a4f4a3af4cbad87d83b84a901ca9a9d488e5 (diff)
LoopControl: Add many asserts to check correctness at run time
Diffstat (limited to 'Carpet/LoopControl')
-rw-r--r--Carpet/LoopControl/src/loopcontrol.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/Carpet/LoopControl/src/loopcontrol.c b/Carpet/LoopControl/src/loopcontrol.c
index b4e4bf328..1331e6b35 100644
--- a/Carpet/LoopControl/src/loopcontrol.c
+++ b/Carpet/LoopControl/src/loopcontrol.c
@@ -123,6 +123,7 @@ find_thread_topologies (lc_topology_t * restrict const topologies,
}
+
#if 1
/* Find "good" tiling specifications */
@@ -191,9 +192,11 @@ find_tiling_specifications (lc_tiling_t * restrict const tilings,
/* step size should be at least 1, even if there are only 0
points */
- assert (* ntilings < maxntilings);
- tilings[* ntilings].npoints = lc_max (npoints, 1);
- ++ * ntilings;
+ if (* ntilings == 0) {
+ assert (* ntilings < maxntilings);
+ tilings[* ntilings].npoints = lc_max (npoints, 1);
+ ++ * ntilings;
+ }
assert (* ntilings >= 1);
}
@@ -226,11 +229,13 @@ find_tiling_specifications (lc_tiling_t * restrict const tilings,
}
}
- assert (* ntilings < maxntilings);
/* step size should be at least 1, even if there are only 0
points */
- tilings[* ntilings].npoints = lc_max (npoints, 1);
- ++ * ntilings;
+ if (* ntilings == 0 || tilings[* ntilings - 1].npoints != npoints) {
+ assert (* ntilings < maxntilings);
+ tilings[* ntilings].npoints = lc_max (npoints, 1);
+ ++ * ntilings;
+ }
}
#endif
@@ -437,7 +442,7 @@ lc_statset_init (lc_statset_t * restrict const ls,
}
// Reallocate memory in case we need more
if (num_threads > saved_maxthreads) {
- int old_saved_maxthreads = saved_maxthreads;
+ int const old_saved_maxthreads = saved_maxthreads;
saved_maxthreads = num_threads;
saved_topologies = realloc (saved_topologies, saved_maxthreads * sizeof * saved_topologies );
saved_ntopologies = realloc (saved_ntopologies, saved_maxthreads * sizeof * saved_ntopologies);
@@ -529,11 +534,6 @@ lc_statset_init (lc_statset_t * restrict const ls,
ls->topologies[n].nthreads[1][d] >
ls->npoints[d]);
}
- assert (tiling != 0); /* this can't be? */
- if (tiling == 0) {
- /* Always allow at least one tiling */
- tiling = 1;
- }
ls->topology_ntilings[d][n] = tiling;
}
if (debug) {
@@ -1074,12 +1074,9 @@ lc_control_finish (lc_control_t * restrict const lc)
/* Perform self-check */
if (do_selftest) {
- /* Ensure all threads have finished the loop */
-#pragma omp barrier
- ;
/* Assert that exactly the specified points have been set */
static int failure = 0;
-#pragma omp for reduction(+: failure)
+#pragma omp for
for (int k=0; k<lc->klsh; ++k) {
for (int j=0; j<lc->jlsh; ++j) {
for (int i=0; i<lc->ilsh; ++i) {
@@ -1089,9 +1086,9 @@ lc_control_finish (lc_control_t * restrict const lc)
(j >= lc->jmin && j < lc->jmax) &&
(k >= lc->kmin && k < lc->kmax);
if (lc->selftest_count[ind3d] != inside) {
- ++ failure;
#pragma omp critical
{
+ failure = 1;
fprintf (stderr, " i=[%d,%d,%d] count=%d expected=%d\n",
i, j, k,
(int) lc->selftest_count[ind3d], (int) inside);
@@ -1136,9 +1133,11 @@ lc_control_finish (lc_control_t * restrict const lc)
lc->statmap->name);
}
}
-#pragma omp single nowait
+ // xlC on VIP doesn't like this "nowait"
+#pragma omp single // nowait
{
free (lc->selftest_count);
+ lc->selftest_count = NULL;
}
}
}