-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
61 lines (47 loc) · 1.56 KB
/
main.cu
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
#include <iostream>
#include <argparse/argparse.hpp>
#include "graph/graph.h"
#include "tc/tc.cuh"
#include <loguru.hpp>
//#define LOGURU_WITH_STREAMS 1
int main(int argc, char* argv[]) {
loguru::init(argc, argv);
LOG_F(INFO, "Hello from main.cpp!");
LOG_F(INFO, "main function about to end!");
argparse::ArgumentParser parser("triangle counting");
parser.add_argument("--gpu")
.help("GPU Device ID (must be a positive integer)")
.default_value(0)
.action([](const std::string &value) { return std::stoi(value); });
parser.add_argument("--graph")
.help("Graph file path")
.default_value("/")
.action([](const std::string &value) { return value; });
try {
parser.parse_args(argc, argv);
} catch (const std::exception& err) {
std::cout << parser << std::endl;
exit(EXIT_FAILURE);
}
auto device_count = 0;
auto device_id = 0;
cudaGetDeviceCount(&device_count);
if (device_count == 0) {
std::cerr << "error: no gpu device found" << std::endl;
exit(EXIT_FAILURE);
}
if (parser.is_used("--gpu")) {
device_id = parser.get<int>("--gpu");
if (device_id >= device_count) {
std::cerr << "error: invalid gpu device id" << std::endl;
exit(EXIT_FAILURE);
}
cudaSetDevice(device_id);
}
if (parser.is_used("--graph")) {
auto dataset = parser.get<std::string>("--graph");
auto g = Graph(dataset);
// then aglorithm
tc(&g);
}
}