-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.cpp
65 lines (55 loc) · 1.47 KB
/
Main.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
#include "InputFlags.h"
#include "OpenCLHelper.h"
#include "PCIeBandwidthTest.h"
#include <iostream>
#include <vector>
#include <cstdlib>
void ExtractGPUAndCPUList(std::vector<int> &num_gpu, std::vector<int> &cores, std::string gpu_list, std::string core_list)
{
int i = 0;
while(gpu_list[i] != '\0') {
std::string temp;
while(gpu_list[i] != ',' && gpu_list[i] != '\0') {
temp += gpu_list[i];
i++;
}
i++;
num_gpu.push_back(atoi(temp.c_str()));
}
i = 0;
while(core_list[i] != '\0') {
std::string temp;
while(core_list[i] != ',' && core_list[i] != '\0') {
temp += core_list[i];
i++;
}
i++;
cores.push_back(atoi(temp.c_str()));
}
if(num_gpu.size() != cores.size()) {
printf("Error: each GPU should be associated to a core !\n");
exit(1);
}
}
int main(int argc, char *argv[])
{
PCIeBandwidthTest pcie_obj;
InputFlags &in_flags = pcie_obj;
in_flags.AddDerivedInputFlags();
in_flags.Parse(argc, argv);
std::vector<int> num_gpu;
std::vector<int> core_list;
ExtractGPUAndCPUList(num_gpu, core_list, in_flags.GetValueStr("gpu_list"), in_flags.GetValueStr("cores"));
CLHelper CL;
if(CL.Init("", in_flags, num_gpu) == 1) {
printf("Error Initializing OpenCL Runtime\n");
exit(1);
}
pcie_obj.AllocateBuffers(CL, num_gpu.size(), core_list);
int nsizes = in_flags.GetValueInt("sizes");
int niters = in_flags.GetValueInt("iterations");
for(int i = 0; i < nsizes; i++) {
pcie_obj.RunTest(CL, niters, i, core_list);
}
pcie_obj.PrintResults();
}