aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Haas <rhaas@tapir.caltech.edu>2013-09-05 22:40:00 -0700
committerRoland Haas <rhaas@tapir.caltech.edu>2013-09-27 10:41:39 -0700
commitd746b25592639a0f8eecab042553fe2a639be9d9 (patch)
tree583dd24f8bcbcece3e6c2600c118679541a75ff6
parent0e435fca01c0ce3356565c661afb0ff9d64880a1 (diff)
Carpet: use electric fence provided by CarpetLib
only active when CarpetLib's electric_fence parameter is set
-rw-r--r--Carpet/Carpet/src/CallFunction.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/Carpet/Carpet/src/CallFunction.cc b/Carpet/Carpet/src/CallFunction.cc
index 935fe2e4d..224a66346 100644
--- a/Carpet/Carpet/src/CallFunction.cc
+++ b/Carpet/Carpet/src/CallFunction.cc
@@ -39,6 +39,11 @@ namespace Carpet {
SyncGroupsInScheduleBlock (cFunctionData * attribute, cGH * cctkGH,
vector<int> const & sync_groups,
Timers::Timer & sync_timer);
+
+ // check if scheduled function overwrote any of the poison surrounding
+ // allocated memory
+ static void
+ CheckFence (cGH const * const cctkGH, cFunctionData * attribute);
/// Traverse one function on all components of one refinement level
/// of one multigrid level.
@@ -381,6 +386,7 @@ namespace Carpet {
post_timer.stop();
}
timer.stop();
+ CheckFence (cctkGH, attribute);
#ifdef REQUIREMENTS_HH
Requirements::AfterRoutine
(attribute,
@@ -464,5 +470,68 @@ namespace Carpet {
SyncProlongateGroups (cctkGH, sync_groups, attribute);
sync_timer.stop();
}
+
+ void CheckFence (cGH const * const cctkGH, cFunctionData * attribute)
+ {
+ if (is_meta_mode()) return; // meta mode has no accessible variables
+
+ Timers::Timer timer("FenceCheck");
+ timer.start();
+
+ for (int group=0; group<CCTK_NumGroups(); ++group) {
+ if (CCTK_QueryGroupStorageI(cctkGH, group)) {
+ int const nvar = CCTK_NumVarsInGroupI(group);
+ if (nvar == 0) continue;
+ int const n0 = CCTK_FirstVarIndexI(group);
+ assert (n0>=0);
+
+ int const num_tl = CCTK_ActiveTimeLevelsVI(cctkGH, n0);
+ if (num_tl == 0) continue;
+ int const min_tl = 0;
+ int const max_tl = num_tl-1;
+
+ int const grouptype = CCTK_GroupTypeI(group);
+ if (grouptype == CCTK_GF && not is_local_mode()) continue;
+ assert(not is_meta_mode());
+
+ // FIXME: query is_XXX() functions
+ const bool is_array = grouptype == CCTK_ARRAY or
+ grouptype == CCTK_SCALAR;
+ const int m = is_array ? 0 : map;
+ const int rl = is_array ? 0 : reflevel;
+ const int ml = is_array ? 0 : mglevel;
+ const int lc = is_array ? 0 : local_component;
+
+ {
+ char * const groupname = CCTK_GroupName(group);
+ Checkpoint ("FenceCheck \"%s\"", groupname);
+ free (groupname);
+ }
+
+ for (int var=0; var<nvar; ++var) {
+ assert (n0 + var<CCTK_NumVars());
+ for (int tl=min_tl; tl<=max_tl; ++tl) {
+ // TODO: turns this into a call of ggf taken a callback routine
+ ggf * const ff = arrdata.AT(group).AT(m).data.AT(var);
+ assert(ff);
+ gdata * const data =
+ ff->data_pointer (tl, rl, lc, ml);
+ for (int f=0; f<2; ++f) {
+ if (not data->check_fence(f)) {
+ char* fullname = CCTK_FullName(n0+var);
+ CCTK_VError(__LINE__, __FILE__, CCTK_THORNSTRING,
+ "At iteration %d: timelevel %d, component %d, map %d, refinement level %d of the variable \"%s\" contains was written to beyond to %s bound of the allocated memory by %s::%s at %s.",
+ cctkGH->cctk_iteration, tl, component, m,
+ rl, fullname, f ? "lower" : "upper",
+ attribute->thorn, attribute->routine, attribute->where);
+ free (fullname);
+ }
+ }// for f
+ } // for tl
+ } // for var
+ }
+ }
+ timer.stop();
+ }
} // namespace Carpet