-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cu
54 lines (40 loc) · 1.44 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
// Copyright (c) 2020, American University of Beirut
// See LICENSE.txt for copyright license
#include "config.h"
#include "graph.h"
#include "kernel.h"
#include "timer.h"
#include "verify.h"
#include <stdio.h>
int main(int argc, char** argv) {
cudaDeviceSynchronize();
Config config = parseArgs(argc, argv);
Timer timer = initTimer(config.verbosity >= 1);
// Allocate memory and initialize data
printAndStart(&timer, "Setting up\n");
COOGraph* graph = createCOOFromFile(config.graphFileName);
config.numNodes = graph->numNodes;
config.numEdges = graph->numEdges;
COOGraph* truss = createEmptyCOO(config.numNodes, config.numEdges);
stopAndPrintElapsed(&timer, " Set up time");
if(config.verbosity >= 1) printConfig(config);
// Compute
printAndStart(&timer, "Computing\n");
ktruss(graph, truss, config);
stopAndPrintElapsed(&timer, " Total time");
// Write result
if(config.outFileName != NULL) {
if(config.verbosity >= 1) printf("Writing result to file: %s\n", config.outFileName);
writeCOOGraphToFile(truss, config.outFileName);
}
// Verify result
printAndStart(&timer, "Verifying result\n");
verify(truss, config);
stopAndPrintElapsed(&timer, " Verification time");
// Free memory
printAndStart(&timer, "Cleaning up\n");
freeCOOGraph(graph);
freeCOOGraph(truss);
stopAndPrintElapsed(&timer, " Clean up time");
return 0;
}