-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
212 lines (175 loc) · 6.44 KB
/
main.c
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*!
\file
\brief The entry point of the triangle counting code
\date Started 5/10/2017
\author George
\version\verbatim $Id: cmdline.c 20946 2017-05-10 23:12:48Z karypis $ \endverbatim
*/
#include "kt.h"
void cleanMem(vault_t *vault, params_t *params) {
gk_free((void **)¶ms->infile, LTERM);
gk_free((void **)¶ms->outfile, LTERM);
gk_free((void **)¶ms, LTERM);
gk_free((void **)&vault->graph->xadj, LTERM);
gk_free((void **)&vault->graph->adjncy, LTERM);
gk_free((void **)&vault->graph, LTERM);
gk_free((void **)&vault->ugraph->xadj, LTERM);
gk_free((void **)&vault->ugraph->adjncy, LTERM);
gk_free((void **)&vault->ugraph->iadjwgt, LTERM);
gk_free((void **)&vault->ugraph, LTERM);
gk_free((void **)&vault->lgraph->xadj, LTERM);
gk_free((void **)&vault->lgraph->adjncy, LTERM);
gk_free((void **)&vault->lgraph, LTERM);
gk_free((void **)&vault->perm, LTERM);
gk_free((void **)&vault->iperm, LTERM);
gk_free((void **)&vault->ktedges, LTERM);
gk_free((void **)&vault, LTERM);
}
/*************************************************************************
* The entry point
**************************************************************************/
int main(int argc, char *argv[])
{
int64_t ntriangles=0;
params_t *params;
vault_t *vault;
params = getcmdline_params(argc, argv);
double totalRuntime = 0.0;
setvbuf(stdout, NULL, _IOLBF, 0);
vault = loadData(params);
printf("\n-----------------\n");
printf("infile: %s\n", params->infile);
printf("outfile: %s\n", (params->outfile ? params->outfile : "NULL"));
printf("#nvtxs: %d\n", vault->graph->nvtxs);
printf("kttype: %s\n", kttypenames[params->kttype]);
printf("jbsize: %d, ibsize: %d\n", params->jbsize, params->ibsize);
printf("\n");
/* perform various initializations */
srand(params->seed);
gk_startwctimer(vault->timer_global);
/* perform the k-truss decomposition */
switch (params->kttype) {
case KTTYPE_BASELINE1:
ntriangles = kt_Baseline1(params, vault);
break;
case KTTYPE_BASELINE2:
ntriangles = kt_Baseline2(params, vault);
break;
case KTTYPE_BASELINE3:
ntriangles = kt_Baseline3(params, vault);
break;
case KTTYPE_BASELINE4:
ntriangles = kt_Baseline4(params, vault);
break;
case KTTYPE_BASELINE5:
ntriangles = kt_Baseline5(params, vault);
break;
case KTTYPE_BASELINE5b:
ntriangles = kt_Baseline5b(params, vault);
break;
case KTTYPE_BASELINE5c:
ntriangles = kt_Baseline5c(params, vault);
break;
case KTTYPE_BASELINE6:
ntriangles = kt_Baseline6(params, vault);
break;
case KTTYPE_BASELINE7:
ntriangles = kt_Baseline7(params, vault);
break;
case KTTYPE_BASELINE8:
ntriangles = kt_Baseline8(params, vault);
break;
#ifdef XXX
case KTTYPE_BASELINE9:
ntriangles = kt_Baseline9(params, vault);
break;
#endif
case KTTYPE_BASELINE10:
ntriangles = kt_Baseline10(params, vault);
break;
case KTTYPE_BASELINE10b:
ntriangles = kt_Baseline10b(params, vault);
break;
case KTTYPE_BASELINE10g:
ntriangles = kt_Baseline10g(params, vault);
break;
case KTTYPE_TWOPASS:
ntriangles = kt_twopass5b(params, vault);
break;
case KTTYPE_SND:
ntriangles = kt_snd(params, vault);
break;
case KTTYPE_AND:
ntriangles = kt_and(params, vault);
break;
default:
errexit("Unknown kttype of %d\n", params->kttype);
}
gk_stopwctimer(vault->timer_global);
#ifdef TEST_CORRECTNESS
if (vault->ktedges && params->dbglvl&8)
kt_CheckKTrussDecomposition(params, vault);
writeResults(params, vault);
#endif
printf("#triangles: %"PRId64"; rate: %.4lf MT/sec\n", ntriangles,
((double)ntriangles)/((double)1e6*gk_getwctimer(vault->timer_2)));
printf("ktmax (k-2): %d\n", vault->ktmax);
printf("----------------------------\n");
if (gk_getwctimer(vault->timer_1) > 0)
printf(" timer_1: %7.2lfs\n", gk_getwctimer(vault->timer_1));
if (gk_getwctimer(vault->timer_2) > 0)
printf(" timer_2: %7.2lfs\n", gk_getwctimer(vault->timer_2));
if (gk_getwctimer(vault->timer_3) > 0)
printf(" timer_3: %7.2lfs\n", gk_getwctimer(vault->timer_3));
if (gk_getwctimer(vault->timer_4) > 0)
printf(" timer_4: %7.2lfs\n", gk_getwctimer(vault->timer_4));
if (gk_getwctimer(vault->timer_5) > 0)
printf(" timer_5: %7.2lfs\n", gk_getwctimer(vault->timer_5));
if (gk_getwctimer(vault->timer_6) > 0)
printf(" timer_6: %7.2lfs\n", gk_getwctimer(vault->timer_6));
printf("----------------------------\n");
printf(" i/o: %7.2lfs\n", gk_getwctimer(vault->timer_io));
printf(" tcsetup: %7.2lfs\n", gk_getwctimer(vault->timer_tcsetup));
printf(" esupport: %7.2lfs\n", gk_getwctimer(vault->timer_esupport));
printf(" ktsetup: %7.2lfs\n", gk_getwctimer(vault->timer_ktsetup));
printf(" ktpeeling: %7.2lfs\n", gk_getwctimer(vault->timer_ktpeeling));
printf(" wclock: %7.2lfs\n", gk_getwctimer(vault->timer_global));
printf("----------------------------\n");
printf("RUNRESULT: %s %s %"PRId64" %.2lf %.2lf %.2lf %.2lf %.2lf\n",
params->infile,
kttypenames[params->kttype],
ntriangles,
gk_getwctimer(vault->timer_tcsetup),
gk_getwctimer(vault->timer_esupport),
gk_getwctimer(vault->timer_ktsetup),
gk_getwctimer(vault->timer_ktpeeling),
gk_getwctimer(vault->timer_global)
);
if(params->stream) {
printf("Now Streaming....\n\n\n");
char* newEdgesFile = strdup(params->infile);
char* outputLocation = strdup(params->infile);
char *ptr = strrchr(newEdgesFile, '/');
strcpy(ptr, "/newEdges.edges");
ptr = strrchr(outputLocation, '/');
strcpy(ptr, "/");
printf("Edges file location : %s, Output Location : %s",
newEdgesFile, outputLocation);
stream_v2(params, vault, newEdgesFile, outputLocation);
}
else {
FILE *fpout, *fpout1;
char* baselineTimingsFile = strdup(params->infile);
char* baselineOpsFile = strdup(params->infile);
char *ptr = strrchr(baselineTimingsFile, '/');
strcpy(ptr, "/baselineTimings.txt");
fpout = gk_fopen(baselineTimingsFile, "a", "fpout");
fprintf(fpout, "%.6lf\n", gk_getwctimer(vault->timer_global));
gk_fclose(fpout);
ptr = strrchr(baselineOpsFile, '/');
strcpy(ptr, "/baselineOps.txt");
fpout1 = gk_fopen(baselineOpsFile, "a", "fpout1");
fprintf(fpout1, "%"PRId64"\n", gk_getwctimer(ntriangles));
gk_fclose(fpout1);
}
}