-
Notifications
You must be signed in to change notification settings - Fork 10
/
tntblast.cpp
79 lines (58 loc) · 1.47 KB
/
tntblast.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifdef USE_MPI
#include <mpi.h>
#endif // USE_MPI
#include "tntblast.h"
#include <stdlib.h>
#include <iostream>
#ifdef _OPENMP
// Under windows, we need to include omp.h to load
// vcomp.dll (which is required for openMP on windows)
#include <omp.h>
#endif // _OPENMP
using namespace std;
// Global variables
int mpi_numtasks;
int mpi_rank;
#ifdef PROFILE
unsigned int num_plus_tm_eval = 0;
unsigned int num_minus_tm_eval = 0;
#endif // PROFILE
int main(int argc, char *argv[])
{
int ret_value = EXIT_FAILURE;
// Initialize for the case when we are not using MPI
mpi_numtasks = 1;
mpi_rank = 0;
#ifdef USE_MPI
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_numtasks);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
if(mpi_numtasks < 2){
// Shut down MPI right away
MPI_Finalize();
#ifdef _OPENMP
cout << "Running on local machine [" << omp_get_max_threads() << " thread(s)]" << endl;
#else
cout << "Running on local machine (1 thread)" << endl;
#endif // _OPENMP
ret_value = local_main(argc, argv);
}
else{
if(mpi_rank == 0){ // Master
ret_value = master(argc, argv);
}
else{ // Worker
ret_value = worker(argc, argv);
}
MPI_Finalize();
}
#else // USE_MPI not defined
#ifdef _OPENMP
cout << "Running on local machine [" << omp_get_max_threads() << " thread(s)]" << endl;
#else
cout << "Running on local machine (1 thread)" << endl;
#endif // _OPENMP
ret_value = local_main(argc, argv);
#endif //USE_MPI
return ret_value;
}