-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.C
63 lines (45 loc) · 1.13 KB
/
main.C
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
#include <cstdlib>
#include <iostream>
using namespace std;
#include "timer.h"
#include "fort.h"
void calculate_pi_with_device(const int block_dim, const int grid_dim);
void pi_with_openmp();
void gpu_test();
void print_GPU_information();
extern "C" void FORT(fortrantest)(const int &block_dim, const int &grid_dim);
int main(int argc, const char * argv[])
{
gpu_test();
print_GPU_information();
int block_dim = 512;
int grid_dim = 512;
int n = 1;
int op = 0;
if(argc > 1)
block_dim = atoi(argv[1]);
if(argc > 2)
grid_dim = atoi(argv[2]);
if(argc > 3)
n = atoi(argv[3]);
if(argc > 4)
op = atoi(argv[4]);
Timer timer;
Timer::print_time(timer.time());
for(int i = 0; i < n; i++) {
cout << "\n *** " << i << " ***" << endl;
if(op == 0 || op == 1) {
timer.reset();
FORT(fortrantest)(block_dim, grid_dim);
cout << " Wall time for GPU: ";
Timer::print_time(timer.time());
}
if(op == 0 || op == 2) {
timer.reset();
pi_with_openmp();
cout << " Wall time for OpenMP: ";
Timer::print_time(timer.time());
}
}
return 0;
}