-
Notifications
You must be signed in to change notification settings - Fork 2
/
main_helper.h
94 lines (76 loc) · 2.5 KB
/
main_helper.h
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#pragma once
#include <climits>
#include <cassert>
#include <chrono>
#include <sstream>
#include <fstream>
#include <omp.h>
#include "util/graph.h"
#include "util/log.h"
#include "util/pretty_print.h"
#include "util/timer.h"
#include "util/md5.h"
#include "util/cuda/cuda_util.h"
#include "host/histogram.h"
#include "reordering_utils/reorder_utils.h"
#include "main_helper.h"
#define MAX_LEVEL (20000)
inline void CheckLevelOff(eid_t *level_start_pos) {
auto last = MAX_LEVEL - 1;
while (level_start_pos[last] == 0)last--;
vector<int32_t> histogram;
for (auto i = 1; i < last + 1; i++) {
histogram.emplace_back(level_start_pos[i] - level_start_pos[i - 1]);
}
#ifdef YCHE_DEBUG
log_info("Levels: %zu", histogram.size());
#endif
stringstream ss;
ss << histogram;
#ifdef YCHE_DEBUG
log_info("Histogram: %s", ss.str().c_str());
#endif
stringstream ss2;
ss2 << ss.str() << "\n";
log_info("Checking Level Off, Md5sum of histogram: %s", md5(ss2.str()).c_str());
}
inline void read_env() {
extern int NUM_THREADS;
NUM_THREADS = omp_get_max_threads();
log_info("NUM_PROCS: %d", omp_get_num_procs());
log_info("NUM_THREADS: %d", NUM_THREADS);
}
inline void display_stats(int *EdgeSupport, long numEdges, string output_folder) {
auto res = core_val_histogram(numEdges, EdgeSupport, true);
ofstream ofs(output_folder);
ofs << res << endl;
{
stringstream ss;
ss << res << "\n";
log_info("Md5sum of histogram: %s", md5(ss.str()).c_str());
}
int minSup = INT_MAX;
int maxSup = 0;
for (long i = 0; i < numEdges; i++) {
if (minSup > EdgeSupport[i]) {
minSup = EdgeSupport[i];
}
if (maxSup < EdgeSupport[i]) {
maxSup = EdgeSupport[i];
}
}
long numEdgesWithMinSup = 0, numEdgesWithMaxSup = 0;
for (long i = 0; i < numEdges; i++) {
if (EdgeSupport[i] == minSup) {
numEdgesWithMinSup++;
}
if (EdgeSupport[i] == maxSup) {
numEdgesWithMaxSup++;
}
}
log_info("Total #Edges: %'lld", numEdges);
log_info("Min-truss: %d; #Edges in Min-truss: %'lld", minSup + 2, numEdgesWithMinSup);
log_info("Max-truss: %d; #Edges in Max-truss: %'lld", maxSup + 2, numEdgesWithMaxSup);
}
void PKT_cuda(graph_t *g, eid_t *edge_off_origin_cpu, int *&EdgeSupport, Edge *edgeIdToEdge, int shrink_factor,
int *output, eid_t *level_start_pos, ZLCUDAMemStat *mem_stat, ZLCUDATimer *time_stat, int level);