aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2003-01-10 10:50:42 +0000
committertradke <tradke@b61c5cb5-eaca-4651-9a7a-d64986f99364>2003-01-10 10:50:42 +0000
commit7e8e1222ebdbd0ebed7a073e14c07b59aeb63e31 (patch)
tree0bab5e673e0650c908a525732a1091cb856c0bbe
parentfe9d700d7d983df4aca938ace5d7d7b8b1ff7bc3 (diff)
Reduce the local termination flag from all processors and have DoneMainLoop()
return this global value. This prevents potential deadlocks, especially with the max_runtime termination condition. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@402 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r--src/Evolve.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/Evolve.c b/src/Evolve.c
index 910ce43..d3b54f5 100644
--- a/src/Evolve.c
+++ b/src/Evolve.c
@@ -187,7 +187,7 @@ int PUGH_Evolve(tFleshConfig *config)
static int DoneMainLoop (const cGH *GH, CCTK_REAL simulation_time,int iteration)
{
int max_iteration_reached, max_simulation_time_reached, max_runtime_reached;
- int retval;
+ CCTK_INT local, global;
#ifdef HAVE_TIME_GETTIMEOFDAY
struct timeval runtime;
static struct timeval starttime = {0, 0};
@@ -203,8 +203,8 @@ static int DoneMainLoop (const cGH *GH, CCTK_REAL simulation_time,int iteration)
}
#endif
- retval = terminate_next || CCTK_TerminationReached (GH);
- if (! retval && ! CCTK_Equals (terminate, "never"))
+ local = terminate_next || CCTK_TerminationReached (GH);
+ if (! local && ! CCTK_Equals (terminate, "never"))
{
max_iteration_reached = iteration >= cctk_itlast;
@@ -231,38 +231,47 @@ static int DoneMainLoop (const cGH *GH, CCTK_REAL simulation_time,int iteration)
if (CCTK_Equals (terminate, "iteration"))
{
- retval = max_iteration_reached;
+ local = max_iteration_reached;
}
else if (CCTK_Equals (terminate, "time"))
{
- retval = max_simulation_time_reached;
+ local = max_simulation_time_reached;
}
else if (CCTK_Equals (terminate, "runtime"))
{
- retval = max_runtime_reached;
+ local = max_runtime_reached;
}
else if (CCTK_Equals (terminate, "any"))
{
- retval = max_iteration_reached || max_simulation_time_reached ||
+ local = max_iteration_reached || max_simulation_time_reached ||
max_runtime_reached;
}
else if (CCTK_Equals (terminate, "all"))
{
- retval = max_iteration_reached && max_simulation_time_reached &&
+ local = max_iteration_reached && max_simulation_time_reached &&
max_runtime_reached;
}
/* the following two conditions are deprecated in BETA14 */
else if (CCTK_Equals (terminate, "either"))
{
- retval = max_iteration_reached || max_simulation_time_reached;
+ local = max_iteration_reached || max_simulation_time_reached;
}
else /* if (CCTK_Equals (terminate, "both")) */
{
- retval = max_iteration_reached && max_simulation_time_reached;
+ local = max_iteration_reached && max_simulation_time_reached;
}
}
- return (retval);
+#ifdef CCTK_MPI
+ /* reduce the local flags from all processors
+ into a single global termination flag */
+ CACTUS_MPI_ERROR (MPI_Allreduce (&local, &global, 1, PUGH_MPI_INT, MPI_LAND,
+ PUGH_pGH (GH)->PUGH_COMM_WORLD));
+#else
+ global = local;
+#endif
+
+ return (global);
}