Skip to content

Commit 6860bde

Browse files
committed
ADIOS2 reader no longer uses MPI (it is not needed)
Modified code such that Chimbuko can now optionally be compiled entirely without MPI. User will have to feed the AD instance the appropriate rank idx (eg using environment variables). Most integration tests are broken with this option. Unit tests are fine. Added an example to benchmark_client/func_multimodal where the AD is used in non-MPI mode inside a wrapper script Improved ADThreadNetClient: Command to disconnect and command to terminate worker thread are now separate Connection and disconnection are now blocking operations such that we don't have situations where the main thread thinks the connection is ready when it is not Queueing actions now checks the worker thread is active
1 parent 6a46853 commit 6860bde

29 files changed

Lines changed: 431 additions & 115 deletions

app/bpfile_replay.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <mpi.h>
21
#include <adios2.h>
32
#include <string>
43
#include <cassert>
@@ -22,7 +21,6 @@ int main(int argc, char** argv){
2221
enableVerboseLogging() = true;
2322
}
2423

25-
MPI_Init(&argc, &argv);
2624
if(argc < 3){
2725
std::cout << "Usage: bpfile_replay <input BPfile filename> <output step freq (ms)> <options>\n"
2826
<< "Output will be on SST under the same filename ${input BPfile filename}. The temporary .sst file created will thus be ${input BPfile filename}.sst\n"
@@ -77,7 +75,7 @@ int main(int argc, char** argv){
7775
}
7876

7977

80-
adios2::ADIOS ad = adios2::ADIOS(MPI_COMM_SELF, adios2::DebugON);
78+
adios2::ADIOS ad = adios2::ADIOS(adios2::DebugON);
8179

8280
adios2::IO io_out = ad.DeclareIO("writer");
8381

@@ -217,6 +215,5 @@ int main(int argc, char** argv){
217215
std::cout << "Shutting down" << std::endl;
218216
wr.Close();
219217

220-
MPI_Finalize();
221218
return 0;
222219
};

app/driver.cpp

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#include<chimbuko_config.h>
2+
#ifdef USE_MPI
3+
#include<mpi.h>
4+
#endif
15
#include "chimbuko/chimbuko.hpp"
26
#include "chimbuko/verbose.hpp"
37
#include "chimbuko/util/string.hpp"
@@ -89,7 +93,15 @@ optionalArgsParser & getOptionalArgsParser(){
8993
addOptionalCommandLineArg(p, trace_connect_timeout, "(For SST mode) Set the timeout in seconds on the connection to the TAU-instrumented binary (default 60s)");
9094
addOptionalCommandLineArg(p, parser_beginstep_timeout, "Set the timeout in seconds on waiting for the next ADIOS2 timestep (default 30s)");
9195

92-
addOptionalCommandLineArg(p, rank, "Set the rank index of the trace data. Used for verification unless override_rank is set. A value < 0 signals the value to be equal to the MPI rank of Chimbuko driver (default)");
96+
addOptionalCommandLineArg(p, rank,
97+
#ifdef USE_MPI
98+
"Set the rank index of the trace data. Used for verification unless override_rank is set. A value < 0 signals the value to be equal to the MPI rank of Chimbuko driver (default)"
99+
#else
100+
"Set the rank index of the trace data (default 0)"
101+
#endif
102+
);
103+
104+
93105
p.addOptionalArg(new overrideRankArg); //-override_rank <idx>
94106
p.addOptionalArg(new setLoggingHeadRankArg); //-logging_head_rank <rank>
95107

@@ -110,7 +122,11 @@ void printHelp(){
110122
getOptionalArgsParser().help(std::cout);
111123
}
112124

113-
ChimbukoParams getParamsFromCommandLine(int argc, char** argv, const int mpi_world_rank){
125+
ChimbukoParams getParamsFromCommandLine(int argc, char** argv
126+
#ifdef USE_MPI
127+
, const int mpi_world_rank
128+
#endif
129+
){
114130
if(argc < 4){
115131
std::cerr << "Expected at least 4 arguments: <exe> <BPFile/SST> <.bp location> <bp file prefix>" << std::endl;
116132
exit(-1);
@@ -153,8 +169,13 @@ ChimbukoParams getParamsFromCommandLine(int argc, char** argv, const int mpi_wor
153169

154170
//By default assign the rank index of the trace data as the MPI rank of the AD process
155171
//Allow override by user
156-
if(params.rank < 0)
172+
if(params.rank < 0){
173+
#ifdef USE_MPI
157174
params.rank = mpi_world_rank;
175+
#else
176+
params.rank = 0; //default to 0 for non-MPI applications
177+
#endif
178+
}
158179

159180
params.verbose = params.rank == 0; //head node produces verbose output
160181

@@ -187,26 +208,35 @@ int main(int argc, char ** argv){
187208
return 0;
188209
}
189210

211+
#ifdef USE_MPI
190212
assert( MPI_Init(&argc, &argv) == MPI_SUCCESS );
191213

192214
int mpi_world_rank, mpi_world_size;
193215
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_world_rank);
194216
MPI_Comm_size(MPI_COMM_WORLD, &mpi_world_size);
217+
#endif
195218

196219
//Parse environment variables
197220
if(const char* env_p = std::getenv("CHIMBUKO_VERBOSE"))
198221
enableVerboseLogging() = true;
199222

200223
//Parse Chimbuko parameters
201-
ChimbukoParams params = getParamsFromCommandLine(argc, argv, mpi_world_rank);
224+
ChimbukoParams params = getParamsFromCommandLine(argc, argv
225+
#ifdef USE_MPI
226+
, mpi_world_rank
227+
#endif
228+
);
229+
202230
if(params.rank == progressHeadRank()) params.print();
203231

204232
if(enableVerboseLogging()){
205233
headProgressStream(params.rank) << "Driver rank " << params.rank << ": Enabling verbose debug output" << std::endl;
206234
}
207235

208236
verboseStream << "Driver rank " << params.rank << ": waiting at pre-run barrier" << std::endl;
237+
#ifdef USE_MPI
209238
MPI_Barrier(MPI_COMM_WORLD);
239+
#endif
210240

211241
bool error = false;
212242

@@ -248,6 +278,7 @@ int main(int argc, char ** argv){
248278
// -----------------------------------------------------------------------
249279
// Average analysis time and total number of outliers
250280
// -----------------------------------------------------------------------
281+
#ifdef USE_MPI
251282
verboseStream << "Driver rank " << params.rank << ": waiting at post-run barrier" << std::endl;
252283
MPI_Barrier(MPI_COMM_WORLD);
253284
processing_time = duration_cast<milliseconds>(t2 - t1).count();
@@ -274,6 +305,19 @@ int main(int argc, char ** argv){
274305
total_n_comm_events = global_measures[1];
275306
total_n_counter_events = global_measures[2];
276307
}
308+
#else
309+
//Without MPI only report local parameters. In principle we could aggregate using the Pserver if we really want the global information
310+
total_processing_time = processing_time;
311+
total_n_outliers = n_outliers;
312+
total_frames = frames;
313+
314+
total_n_func_events = n_func_events;
315+
total_n_comm_events = n_comm_events;
316+
total_n_counter_events = n_counter_events;
317+
318+
int mpi_world_size = 1;
319+
#endif
320+
277321

278322
headProgressStream(params.rank) << "Driver rank " << params.rank << ": Final report\n"
279323
<< "Avg. num. frames over MPI ranks : " << (double)total_frames/(double)mpi_world_size << "\n"
@@ -301,7 +345,9 @@ int main(int argc, char ** argv){
301345
error = true;
302346
}
303347

348+
#ifdef USE_MPI
304349
MPI_Finalize();
350+
#endif
305351
headProgressStream(params.rank) << "Driver is exiting" << std::endl;
306352
return error ? 1 : 0;
307353
}

app/hpserver.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ int main(void){
1313

1414
#include <chimbuko/pserver.hpp>
1515
#include <chimbuko/net/zmqme_net.hpp>
16+
#ifdef USE_MPI
1617
#include <mpi.h>
18+
#endif
1719
#include <chimbuko/param/sstd_param.hpp>
1820
#include <chimbuko/util/commandLineParser.hpp>
1921
#include <chimbuko/verbose.hpp>
@@ -104,7 +106,10 @@ int main (int argc, char ** argv){
104106
}
105107

106108
ZMQMENet net;
109+
#ifdef USE_MPI
107110
MPI_Init(&argc, &argv);
111+
#endif
112+
108113
PSstatSender stat_sender(args.stat_send_freq);
109114

110115
try {
@@ -170,7 +175,7 @@ int main (int argc, char ** argv){
170175

171176
std::cout << "HPserver finalizing the network" << std::endl;
172177
net.finalize();
173-
#ifdef _USE_ZMQNET
178+
#if defined(_USE_ZMQNET) && defined(USE_MPI)
174179
MPI_Finalize();
175180
#endif
176181

app/pclient.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//A test application that mocks part of the anomaly detection modules, acting as a client for the parameter server and sending it anomaly information
2+
#include <chimbuko_config.h>
23

34
#include "chimbuko/param/sstd_param.hpp"
45
#include "chimbuko/message.hpp"
@@ -7,6 +8,9 @@
78
#include "chimbuko/net/mpi_net.hpp"
89
#else
910
#include "chimbuko/net/zmq_net.hpp"
11+
#endif
12+
13+
#ifdef USE_MPI
1014
#include <mpi.h>
1115
#endif
1216

@@ -18,11 +22,13 @@ using namespace chimbuko;
1822

1923
int main (int argc, char** argv)
2024
{
21-
int size, rank;
25+
int size=1, rank=0;
2226

27+
#ifdef USE_MPI
2328
MPI_Init(&argc, &argv);
2429
MPI_Comm_size(MPI_COMM_WORLD, &size);
2530
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
31+
#endif
2632

2733
#ifdef _USE_MPINET
2834
int count;
@@ -114,7 +120,9 @@ s */
114120
//g_param.assign(msg.data_buffer());
115121
}
116122

123+
#ifdef USE_MPI
117124
MPI_Barrier(MPI_COMM_WORLD);
125+
#endif
118126

119127
#ifdef _USE_MPINET
120128
if (rank == 0) {
@@ -159,6 +167,8 @@ s */
159167
zmq_ctx_term(context);
160168
#endif
161169

170+
#ifdef USE_MPI
162171
MPI_Finalize();
172+
#endif
163173
return EXIT_SUCCESS;
164174
}

app/pclient_stats.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//A test application that mocks part of the anomaly detection modules, acting as a client for the parameter server and sending it function statistics information
2+
#include <chimbuko_config.h>
23

34
#include "chimbuko/param/sstd_param.hpp"
45
#include "chimbuko/message.hpp"
@@ -9,6 +10,9 @@
910
#include "chimbuko/net/mpi_net.hpp"
1011
#else
1112
#include "chimbuko/net/zmq_net.hpp"
13+
#endif
14+
15+
#ifdef USE_MPI
1216
#include <mpi.h>
1317
#endif
1418

@@ -21,8 +25,9 @@ using namespace chimbuko;
2125
int main (int argc, char** argv)
2226
{
2327
const int N_MPI_PROCESSORS = 10;
24-
int size, rank;
28+
int size=1, rank=0;
2529

30+
#ifdef USE_MPI
2631
MPI_Init(&argc, &argv);
2732
MPI_Comm_size(MPI_COMM_WORLD, &size);
2833
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -33,6 +38,7 @@ int main (int argc, char** argv)
3338
MPI_Finalize();
3439
return EXIT_SUCCESS;
3540
}
41+
#endif
3642

3743
#ifdef _USE_MPINET
3844
throw std::runtime_error("Not implemented yet.");
@@ -103,8 +109,10 @@ int main (int argc, char** argv)
103109
std::this_thread::sleep_for(std::chrono::milliseconds(10));
104110
}
105111

112+
#ifdef USE_MPI
106113
MPI_Barrier(MPI_COMM_WORLD);
107-
114+
#endif
115+
108116
// terminate parameter server
109117
#ifdef _USE_MPINET
110118
throw std::runtime_error("Not implemented yet.");
@@ -127,6 +135,8 @@ int main (int argc, char** argv)
127135
zmq_ctx_term(context);
128136
#endif
129137

138+
#ifdef USE_MPI
130139
MPI_Finalize();
140+
#endif
131141
return EXIT_SUCCESS;
132142
}

app/pserver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <chimbuko/pserver.hpp>
55

66
#ifdef _USE_MPINET
7-
#include <mpi.h>
87
#include <chimbuko/net/mpi_net.hpp>
98
#else
109
#include <chimbuko/net/zmq_net.hpp>

0 commit comments

Comments
 (0)