-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmpi_wrapper.cpp
48 lines (31 loc) · 1.06 KB
/
mpi_wrapper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
#include <stdlib.h>
#include <string>
#include <sstream>
// To compile: mpiCC -lmpi -o mpi_wrapper.exe mpi_wrapper.cpp
using namespace std;
#include "mpi.h"
int main (int argc, char * argv[]) {
if (argc != 3) { // we are expecting (i) base config file name and (ii) base task number
cout << "Incorrect number of arguments - " << argc << endl;
return 1;
}
int base_id = argc ? atoi( argv[2] ) : 0;
// cout << "Here we are!" << endl;
MPI_Init( &argc, &argv );
// cout << "Init'ed OK" << endl;
int id;
MPI_Comm_rank(MPI_COMM_WORLD,&id);
int size;
MPI_Comm_size(MPI_COMM_WORLD,&size);
cout << "I think the size is: " << size << endl;
// cout << "Got rank OK" << endl;
int final_id = id + base_id;
//cout << final_id << endl;
stringstream command2;
command2 << "bash run_model.sh " << argv[1] << " " << final_id;
cout << "About to run: " << command2.str() << endl;
int result = system(command2.str().c_str());
MPI_Finalize();
return result;
}