forked from makortel/pixel-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_kokkos.cc
77 lines (66 loc) · 2.28 KB
/
main_kokkos.cc
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
#include <chrono>
#include <cstring>
#include <iostream>
#include <memory>
#include "analyzer_kokkos.h"
#include "input.h"
#include "kokkosConfig.h"
#include "modules.h"
#include "output.h"
namespace {
void print_help(std::string const& name) {
std::cout << name << ": [--numberOfThreads NT]"
<< "\n\n"
<< "Options\n"
<< " --numberOfThreads Number of threads to use (default -1 for all cores(?)1)\n"
<< std::endl;
}
} // namespace
int main(int argc, char** argv) {
std::vector<std::string> args(argv, argv + argc);
int numberOfThreads = -1;
for (auto i = args.begin() + 1, e = args.end(); i != e; ++i) {
if (*i == "-h" or *i == "--help") {
print_help(args.front());
return EXIT_SUCCESS;
} else if (*i == "--numberOfThreads") {
++i;
numberOfThreads = std::stoi(*i);
}
}
{
Kokkos::InitArguments arguments;
arguments.num_threads = numberOfThreads;
kokkos_common::initialize(arguments);
}
Input input = read_input();
std::cout << "Got " << input.cablingMap.size << " for cabling, wordCounter " << input.wordCounter << std::endl;
std::unique_ptr<Output> output;
double totaltime = 0;
#ifdef DIGI_KOKKOS_SERIAL
totaltime = 0;
output = std::make_unique<Output>();
std::cout << "\nRunning with the serial CPU backend..." << std::endl;
kokkos_serial::analyze(input, *output, totaltime);
std::cout << "Output: " << countModules(output->moduleInd, input.wordCounter) << " modules in " << totaltime << " us"
<< std::endl;
#endif
#ifdef DIGI_KOKKOS_OPENMP
totaltime = 0;
output = std::make_unique<Output>();
std::cout << "\nRunning with the OpenMP backend..." << std::endl;
kokkos_openmp::analyze(input, *output, totaltime);
std::cout << "Output: " << countModules(output->moduleInd, input.wordCounter) << " modules in " << totaltime << " us"
<< std::endl;
#endif
#ifdef DIGI_KOKKOS_CUDA
totaltime = 0;
output = std::make_unique<Output>();
std::cout << "\nRunning with the CUDA backend..." << std::endl;
kokkos_cuda::analyze(input, *output, totaltime);
std::cout << "Output: " << countModules(output->moduleInd, input.wordCounter) << " modules in " << totaltime << " us"
<< std::endl;
#endif
kokkos_common::finalize();
return 0;
}