generated from puzzlef/louvain-communities-openmp-dynamic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cxx
72 lines (63 loc) · 1.61 KB
/
main.cxx
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
#include <cstdint>
#include <cstdio>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <omp.h>
#include "inc/main.hxx"
using namespace std;
#pragma region CONFIGURATION
#ifndef TYPE
/** Type of edge weights. */
#define TYPE float
#endif
#ifndef MAX_THREADS
/** Maximum number of threads to use. */
#define MAX_THREADS 64
#endif
#ifndef REPEAT_BATCH
/** Number of times to repeat each batch. */
#define REPEAT_BATCH 5
#endif
#ifndef REPEAT_METHOD
/** Number of times to repeat each method. */
#define REPEAT_METHOD 5
#endif
#pragma endregion
#pragma region METHODS
#pragma region PERFORM EXPERIMENT
int main(int argc, char **argv) {
using K = uint32_t;
using V = None;
using E = TYPE;
char *file = argv[1];
bool symmetric = argc>2? atoi(argv[2]) : false;
bool weighted = argc>3? atoi(argv[3]) : false;
omp_set_num_threads(MAX_THREADS);
LOG("OMP_NUM_THREADS=%d\n", MAX_THREADS);
LOG("Loading graph %s ...\n", file);
// Read graph as CSR.
{
DiGraphCsr<K, V, E> xc;
MappedFile mf(file);
size_t size = mf.size();
string_view data((const char*) mf.data(), mf.size());
double tr = measureDuration([&]() {
if (weighted) readMtxFormatToCsrOmpW<true> (xc, data);
else readMtxFormatToCsrOmpW<false>(xc, data);
});
LOG(""); println(xc);
printf("{%09.1fms} %s\n", tr, "readMtxFormatToCsrOmpW");
DiGraph<K, V, E> x;
double ts = measureDuration([&]() {
duplicateOmpW(x, xc);
});
LOG(""); println(x);
printf("{%09.1fms} %s\n", ts, "duplicateOmpW");
}
printf("\n");
return 0;
}
#pragma endregion
#pragma endregion