-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMPI_ThreadingTest.cpp
47 lines (40 loc) · 1.23 KB
/
MPI_ThreadingTest.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
/* Requests the highest level of MPI thread safety (MPI_THREAD_MULTIPLE) and the one provided by the MPI implementation. */
#include <mpi.h>
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
if (argc == 1) {
cout << "Usage: " << argv[0] << " {init | query}" << endl;
return 0;
}
std::string arg = argv[1];
int provided = -1;
if (arg == "init") {
cout << "Trying to initialize for MPI_THREAD_MULTIPLE" << endl;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE , &provided);
cout << "provided = " << provided << endl;
}
if (arg == "query") {
MPI_Init(&argc, &argv);
cout << "Querying default thread level" << endl;
MPI_Query_thread(&provided);
}
switch (provided) {
case MPI_THREAD_SINGLE:
cout << "MPI_THREAD_SINGLE detected." << endl;
break;
case MPI_THREAD_FUNNELED:
cout << "MPI_THREAD_FUNNELED detected." << endl;
break;
case MPI_THREAD_SERIALIZED:
cout << "MPI_THREAD_SERIALIZED detected." << endl;
break;
case MPI_THREAD_MULTIPLE:
cout << "MPI_THREAD_MULTIPLE detected." << endl;
break;
}
MPI_Finalize();
cout << "Information see https://www.open-mpi.org/doc/v1.8/man3/MPI_Init_thread.3.php" << endl;
}