-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cu
More file actions
108 lines (83 loc) · 2.25 KB
/
Copy pathmain.cu
File metadata and controls
108 lines (83 loc) · 2.25 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include "./include/gpu_memory_allocation.h"
#include "./src/AdaptiveCore.cc"
int rep = 1;
int cmp(const void *a, const void *b)
{
return *(unsigned int *)a - *(unsigned int *)b;
}
void PrintMax(uint *result, uint n)
{
uint max = 0;
uint min = 10;
uint id = 0;
for (int i = 0; i < n; i++)
{
if (max < result[i])
{
max = result[i];
id = i;
}
if (min > result[i])
min = result[i];
}
cout << " Maxdegree = " << max << endl;
cout << " Id = " << id << endl;
// cout << " Min K = " << min << endl;
}
template <class T>
void repSimulation(int (*kern)(T), Graph &g)
{
float sum = 0;
// int rep = 10; // number of iterations...
uint max_time = 0;
for (int i = 0; i < rep; i++)
{
// cout <<" !!! " << i << "ms "<<endl;
int t = (*kern)(g);
// cout <<"??1??" << t<< endl;
// cudaDeviceSynchronize();
// cout <<"??2??" << t << endl;
cout << t << "ms ";
if (max_time < t)
max_time = t;
sum += t;
}
sum = sum - max_time;
cout << RED << endl
<< "Ave: " << sum * 1.0 / (rep - 1) << " ms" << RESET << endl;
}
void STDdegrees(Graph &g)
{
double sum = std::accumulate(g.degrees, g.degrees + g.V, 0.0);
double mean = sum / g.V;
std::vector<double> diff(g.V);
std::transform(g.degrees, g.degrees + g.V, diff.begin(),
std::bind2nd(std::minus<double>(), mean));
double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
double stdev = std::sqrt(sq_sum / g.V);
#ifdef HELLO
cout << "STD: " << stdev;
#endif
}
int main(int argc, char *argv[])
{
if (argc < 4)
{
cout << "./kcore file deviceID Repeattime" << endl;
exit(-1);
}
std::string ds = argv[1];
cudaSetDevice(std::atoi(argv[2]));
rep = std::atoi(argv[3]);
cudaFree(0);
cout << "Graph loading Started... " << endl;
Graph g(ds);
cout << endl << "Grapg Name: " << ds << "V: " << g.V << " undirected E: " << g.E << endl;
cout << "AdaptiveCore: ";
repSimulation(AdaptiveCore, g);
cout << "Kmax: " << g.kmax << endl;
return 0;
}