]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright AlainMiniussi 20014 - 20015. |
2 | // Distributed under the Boost Software License, Version 1.0. | |
3 | // (See accompanying file LICENSE_1_0.txt or copy at | |
4 | // http://www.boost.org/LICENSE_1_0.txt) | |
5 | ||
6 | #include <cstdlib> | |
7 | ||
8 | #include "debugger.hpp" | |
9 | ||
10 | std::vector<int> extract_paused_ranks(int argc, char** argv) { | |
11 | std::vector<int> paused; | |
12 | for (int i=1; i < argc; ++i) { | |
13 | paused.push_back(std::atoi(argv[i])); | |
14 | } | |
15 | return paused; | |
16 | } | |
17 | ||
18 | void wait_for_debugger(std::vector<int> const& processes, boost::mpi::communicator const& comm) | |
19 | { | |
20 | int i = 1; | |
92f5a8d4 | 21 | bool waiting = std::find(processes.begin(), processes.end(), comm.rank()) != processes.end(); |
7c673cae FG |
22 | for (int r = 0; r < comm.size(); ++r) { |
23 | if (comm.rank() == r) { | |
92f5a8d4 TL |
24 | std::cout << "Rank " << comm.rank() << " has PID " << getpid(); |
25 | if (waiting) { | |
26 | std::cout << " and is waiting."; | |
27 | } | |
28 | std::cout << std::endl; | |
7c673cae FG |
29 | } |
30 | comm.barrier(); | |
31 | } | |
7c673cae | 32 | if (std::find(processes.begin(), processes.end(), comm.rank()) != processes.end()) { |
92f5a8d4 TL |
33 | while (i != 0) { |
34 | sleep(5); | |
7c673cae FG |
35 | } |
36 | } | |
92f5a8d4 TL |
37 | std::cout << "Rank " << comm.rank() << " will proceed.\n"; |
38 | } | |
39 | ||
40 | void wait_for_debugger(boost::mpi::communicator const& comm) | |
41 | { | |
42 | std::vector<int> all; | |
43 | for (int r = 0; r < comm.size(); ++r) { | |
44 | all.push_back(r); | |
45 | } | |
46 | wait_for_debugger(all, comm); | |
7c673cae FG |
47 | } |
48 |