-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (47 loc) · 1.45 KB
/
main.cpp
File metadata and controls
57 lines (47 loc) · 1.45 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
#include "cpu.h"
#include "gpu.h"
#include "graph.h"
#include "timer.h"
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
int main(int argc, char *argv[]) {
if (argc != 2) {
cerr << "Usage: " << argv[0] << " FILE" << endl;
exit(1);
}
unique_ptr<Timer> t(Timer::NewTimer());
Edges edges = ReadEdgesFromFile(argv[1]);
t->Done("Read file");
// AdjList graph = EdgesToAdjList(edges);
// t->Done("Convert to adjacency lists");
int num_nodes = NumVertices(edges);
int num_edges = edges.size();
cerr << "Number of nodes: " << num_nodes
<< ", number of edges: " << num_edges << endl;
vector<uint64_t> results;
#define TEST_ALGORITHM(algorithm, ...) do { \
results.push_back(algorithm(__VA_ARGS__)); \
t->Done("ALGORITHM: "#algorithm); \
} while (false);
t->Reset();
// TEST_ALGORITHM(CpuForward, graph);
// TEST_ALGORITHM(CpuCompactForward, graph);
// TEST_ALGORITHM(CpuCompactForwardForEdgeArray, edges);
PreInitGpuContext(0);
t->Done("Preinitialize context for device 0");
TEST_ALGORITHM(GpuForward, edges);
// for (int i = 0; i < 4; ++i)
// PreInitGpuContext(i);
// t->Done("Preinitialize context for all four devices");
// TEST_ALGORITHM(MultiGpuForward, edges, 4);
for (uint64_t result : results)
cerr << result << " ";
cerr << endl;
if (results.size() > 0)
for (uint64_t result : results)
assert(result == results.front());
}