aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/dist.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2011-11-29 19:02:14 -0500
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 19:55:02 +0000
commite5a4072babaaeaccfd96d9857d433deaa417503f (patch)
tree5cbf71b49cf3c993153a5c81b7046cf3c4813461 /Carpet/CarpetLib/src/dist.cc
parent01b7b58d2ba75324fadebba2cdd41b0c8ff77227 (diff)
Improve named barriers
Introduce dist::barrier as low-level implementation of a named barrier. Use it in Carpet::NamedBarrier. Use the above in almost all barrier calls.
Diffstat (limited to 'Carpet/CarpetLib/src/dist.cc')
-rw-r--r--Carpet/CarpetLib/src/dist.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/dist.cc b/Carpet/CarpetLib/src/dist.cc
index 6f8b759d3..dee79d5bf 100644
--- a/Carpet/CarpetLib/src/dist.cc
+++ b/Carpet/CarpetLib/src/dist.cc
@@ -237,6 +237,19 @@ namespace dist {
MPI_Finalize ();
}
+ void barrier (MPI_Comm const c, int const id, char const *const name)
+ {
+ int const root = 0;
+ unsigned int my_id = dist::rank()==root ? id : id+1;
+ MPI_Bcast (&my_id, 1, MPI_INT, root, c);
+ if (my_id != id) {
+ CCTK_VWarn (CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Wrong id for Barrier \"%s\": expected %ud, found %ud",
+ name, id, my_id);
+ }
+ MPI_Barrier (c);
+ }
+
// Create an MPI datatype from a C datatype description
@@ -412,7 +425,7 @@ namespace dist {
rank, file, line);
}
if (barriers) {
- MPI_Barrier (comm());
+ dist::barrier (comm(), 506877899+line, "CarpetLib::dist::checkpoint");
}
}