diff options
author | rhaas <rhaas@ff385933-4943-42dc-877b-ffc776028de6> | 2012-03-27 03:16:10 +0000 |
---|---|---|
committer | rhaas <rhaas@ff385933-4943-42dc-877b-ffc776028de6> | 2012-03-27 03:16:10 +0000 |
commit | 6cacd197c40ad1694ad71045fa0724fd0dc783e2 (patch) | |
tree | 648262b156722a556ef3aab6cb4de107b287d7bc /src/NaNCheck.c | |
parent | 0a9e8ce2afba60eb0df693aa2cbe35c19d720244 (diff) |
reduce nan mask in level mode
The previous local reduction did not quite work if a process has more than one
component of the grid, and deadlocks if processes have different numbers of
components.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/NaNChecker/trunk@101 ff385933-4943-42dc-877b-ffc776028de6
Diffstat (limited to 'src/NaNCheck.c')
-rw-r--r-- | src/NaNCheck.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/src/NaNCheck.c b/src/NaNCheck.c index dfa59be..129a2e5 100644 --- a/src/NaNCheck.c +++ b/src/NaNCheck.c @@ -127,12 +127,12 @@ void NaNChecker_ResetCounter (CCTK_ARGUMENTS) @vio in @endvar @@*/ -void NaNChecker_NaNCheck (CCTK_ARGUMENTS) +static t_nanchecker_info info; +void NaNChecker_NaNCheck_Prepare (CCTK_ARGUMENTS) { DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; int i, nelems; - t_nanchecker_info info; if (cctk_iteration < check_after || cctk_iteration % check_every) @@ -179,17 +179,37 @@ void NaNChecker_NaNCheck (CCTK_ARGUMENTS) info.check_for = CHECK_FOR_BOTH; } #endif +} +void NaNChecker_NaNCheck_Check (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; + + if (cctk_iteration < check_after || cctk_iteration % check_every || + (info.NaNmask && cctk_iteration == last_iteration_output)) + { + return; + } CCTK_TraverseString (check_vars, CheckForNaN, &info, CCTK_GROUP_OR_VAR); +} +void NaNChecker_NaNCheck_Finish (CCTK_ARGUMENTS) +{ + DECLARE_CCTK_ARGUMENTS; + DECLARE_CCTK_PARAMETERS; - /* reduce the NaN counter globally and accumulate in NaNChecker::NaNsFound */ + if (cctk_iteration < check_after || cctk_iteration % check_every || + (info.NaNmask && cctk_iteration == last_iteration_output)) { - int sum_handle = CCTK_ReductionHandle ("sum"); - CCTK_INT count = 0; - CCTK_ReduceLocalScalar (cctkGH, -1, sum_handle, &info.count, &count, - CCTK_VARIABLE_INT); - *NaNsFound += count; + return; } + + /* reduce the NaN counter globally and accumulate in NaNChecker::NaNsFound */ + int sum_handle = CCTK_ReductionHandle ("sum"); + CCTK_INT count = 0; + CCTK_ReduceLocalScalar (cctkGH, -1, sum_handle, &info.count, &count, + CCTK_VARIABLE_INT); + *NaNsFound += count; } |