-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathreporting_environments.c
More file actions
140 lines (93 loc) · 2.52 KB
/
reporting_environments.c
File metadata and controls
140 lines (93 loc) · 2.52 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/** @file
* Examples of using reportQuESTEnv() in C11. This example
* is most interesting when compiling to simultaneously
* enable multithreaded, GPU-accelerated and distributed
* deployments. When launching, pass an integer 1-6 as a
* command-line argument to choose a deployment.
*
* @author Tyson Jones
*/
#include "quest.h"
#include <stdio.h>
#include <stdlib.h>
/*
* environment deployments
*/
void demo_serial() {
int useDistrib = 0;
int useGpuAccel = 0;
int useMultithread = 0;
initCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread);
reportStr("serial");
reportQuESTEnv();
}
void demo_multithreaded() {
int useDistrib = 0;
int useGpuAccel = 0;
int useMultithread = 1;
initCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread);
reportStr("multithreaded");
reportQuESTEnv();
}
void demo_gpuAccelerated() {
int useDistrib = 0;
int useGpuAccel = 1;
int useMultithread = 0;
initCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread);
reportStr("GPU-accelerated");
reportQuESTEnv();
}
void demo_distributed() {
int useDistrib = 1;
int useGpuAccel = 0;
int useMultithread = 0;
initCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread);
reportStr("distributed");
reportQuESTEnv();
}
void demo_all() {
int useDistrib = 1;
int useGpuAccel = 1;
int useMultithread = 1;
initCustomQuESTEnv(useDistrib, useGpuAccel, useMultithread);
reportStr("all");
reportQuESTEnv();
}
void demo_auto() {
initQuESTEnv();
reportStr("auto");
reportQuESTEnv();
}
/*
* main
*/
int printCmdArgInfo() {
// we can only initialise the QuEST environment once, so
// we accept command-line arg 1-6 to choose the deployment
// all nodes must print because we've not yet setup MPI
printf(
"Must pass single cmd-line argument:\n"
" 1 = serial\n"
" 2 = multithreaded\n"
" 3 = GPU-accelerated\n"
" 4 = distributed\n"
" 5 = all\n"
" 6 = auto\n");
// process return code, indicate error
return 1;
}
int main(int argc, char* argv[]) {
if (argc != 2)
return printCmdArgInfo();
int opt = atoi(argv[1]);
if (opt < 1 || opt > 6)
return printCmdArgInfo();
if (opt == 1) demo_serial();
if (opt == 2) demo_multithreaded();
if (opt == 3) demo_gpuAccelerated();
if (opt == 4) demo_distributed();
if (opt == 5) demo_all();
if (opt == 6) demo_auto();
finalizeQuESTEnv();
return 0;
}