summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/mpi/test/debugger.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/mpi/test/debugger.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/mpi/test/debugger.cpp')
-rw-r--r--src/boost/libs/mpi/test/debugger.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/boost/libs/mpi/test/debugger.cpp b/src/boost/libs/mpi/test/debugger.cpp
new file mode 100644
index 00000000..90093e79
--- /dev/null
+++ b/src/boost/libs/mpi/test/debugger.cpp
@@ -0,0 +1,48 @@
+// Copyright AlainMiniussi 20014 - 20015.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <cstdlib>
+
+#include "debugger.hpp"
+
+std::vector<int> extract_paused_ranks(int argc, char** argv) {
+ std::vector<int> paused;
+ for (int i=1; i < argc; ++i) {
+ paused.push_back(std::atoi(argv[i]));
+ }
+ return paused;
+}
+
+void wait_for_debugger(std::vector<int> const& processes, boost::mpi::communicator const& comm)
+{
+ int i = 1;
+ bool waiting = std::find(processes.begin(), processes.end(), comm.rank()) != processes.end();
+ for (int r = 0; r < comm.size(); ++r) {
+ if (comm.rank() == r) {
+ std::cout << "Rank " << comm.rank() << " has PID " << getpid();
+ if (waiting) {
+ std::cout << " and is waiting.";
+ }
+ std::cout << std::endl;
+ }
+ comm.barrier();
+ }
+ if (std::find(processes.begin(), processes.end(), comm.rank()) != processes.end()) {
+ while (i != 0) {
+ sleep(5);
+ }
+ }
+ std::cout << "Rank " << comm.rank() << " will proceed.\n";
+}
+
+void wait_for_debugger(boost::mpi::communicator const& comm)
+{
+ std::vector<int> all;
+ for (int r = 0; r < comm.size(); ++r) {
+ all.push_back(r);
+ }
+ wait_for_debugger(all, comm);
+}
+