-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLP.h
More file actions
132 lines (111 loc) · 3.77 KB
/
Copy pathLP.h
File metadata and controls
132 lines (111 loc) · 3.77 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#ifndef __LP_DEFINED
#define __LP_DEFINED
#include "common.h"
#include "kernel.h"
#include "sample.h"
template <find_fun UDF, apply_fun UDF2>
__device__ inline bool lp (uintT vstat, uintT idx, uintT src0, uintT dst0, struct graph_data d_input)
{
bool active = (idx < d_input.E);
bool flag = false;
if(active) {
uintT src = PARENT(src0);
uintT dst = PARENT(dst0);
if(PARENT(src0) < PARENT(dst0)) {
if(PARENT(dst0) == atomicMin(&PARENTW(dst0), PARENT(src0))) {
flag = true;
}
}
else if(PARENT(src0) > PARENT(dst0)) {
if(PARENT(src0) == atomicMin(&PARENTW(src0), PARENT(dst0))) {
flag = true;
}
}
}
return flag;
}
template <STR_fun UDF, STR_fun UDF2, int Vfront_active, int Efront_active, int alter_active, int Rfront_active, int sample_active>
void union_find_lp(uintT f_size, struct graph_data d_input)
{
uintT V_bitsize = CEIL(d_input.V, 32);
uintT E_bitsize = CEIL(d_input.E, 32);
uintT Vflag, Eflag;
intT V_frontsize = d_input.V;
uintT E_frontsize = f_size;
if(E_frontsize == V_frontsize) E_frontsize *= 4;
if(Efront_active) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
cudaMemset(d_input._Efront, -1, sizeof(uintT)*E_bitsize);
}
if(Rfront_active) {
cudaMemset(d_input._Rfront, -1, sizeof(uintT)*V_bitsize);
}
while(1) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
UDF<<<CEIL(E_frontsize, SBSIZE), SBSIZE>>>(f_size, d_input);
if(sample_active && d_input.is_sym == 0) {
UDF2<<<CEIL(E_frontsize, SBSIZE), SBSIZE>>>(f_size, d_input);
}
cudaMemcpy(&Eflag, d_input._Eflag, sizeof(uintT), cudaMemcpyDeviceToHost);
if(Eflag == 0) break;
}
}
template <STR_fun UDF, STR_fun UDF2, int Vfront_active, int Efront_active, int alter_active, int Rfront_active, int sample_active>
void union_find_lp_CHUNK(uintT f_size, struct graph_data d_input)
{
uintT V_bitsize = CEIL(d_input.V, 32);
uintT E_bitsize = CEIL(f_size, 32);
uintT Vflag, Eflag;
uintT V_frontsize = d_input.V;
uintT E_frontsize = f_size;
if(Efront_active) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
cudaMemset(d_input._Efront, -1, sizeof(uintT)*E_bitsize);
}
if(Rfront_active) {
cudaMemset(d_input._Rfront, -1, sizeof(uintT)*V_bitsize);
}
while(1) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
UDF<<<CEIL(E_frontsize, SBSIZE), SBSIZE>>>(f_size, d_input);
if(sample_active && d_input.is_sym == 0) {
UDF2<<<CEIL(E_frontsize, SBSIZE), SBSIZE>>>(f_size, d_input);
}
cudaMemcpy(&Eflag, d_input._Eflag, sizeof(uintT), cudaMemcpyDeviceToHost);
if(Eflag == 0) break;
}
}
template <STR_fun UDF, STR_fun UDF2, int Vfront_active, int Efront_active, int alter_active, int Rfront_active, int sample_active>
void union_find_lp_COO_SAMPLE(uintT f_size, struct graph_data d_input)
{
uintT V_bitsize = CEIL(d_input.V, 32);
uintT E_bitsize = CEIL(d_input.E, 32);
uintT Vflag, Eflag;
uintT V_frontsize = d_input.V;
uintT E_frontsize = f_size;
if(E_frontsize == V_frontsize) E_frontsize *= 4;
bool init = false;
if(Efront_active) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
cudaMemset(d_input._Efront, -1, sizeof(uintT)*E_bitsize);
}
if(Rfront_active) {
cudaMemset(d_input._Rfront, -1, sizeof(uintT)*V_bitsize);
}
while(1) {
cudaMemset(d_input._Eflag, 0, sizeof(uintT));
for(uintT gran = 0; gran < d_input.E; gran += d_input.coo_sample_size) {
d_input.offset = gran;
d_input.size = MIN(d_input.E, gran + d_input.coo_sample_size) - gran;
if(init) edge_relabeling<0><<<CEIL(d_input.size, SBSIZE), SBSIZE>>>(d_input.E, d_input);
init = true;
UDF<<<CEIL(d_input.size, SBSIZE), SBSIZE>>>(f_size, d_input);
if(sample_active && d_input.is_sym == 0) {
UDF2<<<CEIL(d_input.size, SBSIZE), SBSIZE>>>(f_size, d_input);
}
}
cudaMemcpy(&Eflag, d_input._Eflag, sizeof(uintT), cudaMemcpyDeviceToHost);
if(Eflag == 0) break;
}
}
#endif