-
Notifications
You must be signed in to change notification settings - Fork 0
/
span.c
157 lines (131 loc) · 3.19 KB
/
span.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
#include <sys/types.h>
#include "simple.h"
#include "graph.h"
#include "lock.h"
V* G;
V* T,*T1,*T2;
E* El;
int n_edge,max_d_node;
#define NANO 1000000000
#define DEBUG_BICONN 0
#define DEBUG_VERIFY 0
void *SIMPLE_main(THREADED)
{
int i,t,j, n_vertices,N,k,max=0;
hrtime_t start,end;
double interval,total=0;
char * input_file;
int * D;
/*initialize graph from input file */
input_file = THARGV[0];
start = gethrtime();
on_one_thread{
t = initialize_graph(input_file,&G,&n_vertices);
if(t!=0) exit(0);
}
n_vertices=node_Bcast_i(n_vertices,TH);
end = gethrtime();
interval=end-start;
printf("Time for initialization is %f\n",interval/NANO);
node_Barrier();
on_one_thread{
max=0;
for(i=0; i<n_vertices; i++)
{
if(G[i].n_neighbors>max){
max=G[i].n_neighbors;
max_d_node=i;
}
}
}
node_Barrier();
#if 0
start = gethrtime();
initialize_graph_edgelist(G, n_vertices,&El,&n_edge, TH);
end = gethrtime();
interval=end-start;
printf("Time for initialization(graph edge list) is %f\n",interval/NANO);
node_Barrier();
node_Barrier();
start = gethrtime();
spanning_tree_CRCW(G,El,n_vertices,n_edge,TH);
end = gethrtime();
interval=end-start;
total+=interval;
printf("Time for spanning_tree_CRCW is %f\n",interval/NANO);
node_Barrier();
pardo(i,0,n_edge,1)
{
El[i].workspace=0;
}
node_Barrier();
start = gethrtime();
spanning_tree_random01(G,El,n_vertices,n_edge,TH);
end = gethrtime();
interval=end-start;
total+=interval;
printf("Time for spanning_tree_random01 is %f\n",interval/NANO);
node_Barrier();
#endif
on_one_thread printf("METRICS:%d THREADS, file %s\n", THREADS, input_file);
node_Barrier();
start = gethrtime();
spanning_tree_CREW(G,n_vertices,&T,TH);
end = gethrtime();
interval=end-start;
total+=interval;
node_Barrier();
on_one_thread printf("METRICS:Time for spanning_tree_CREW is %f\n",interval/NANO);
node_Barrier();
start = gethrtime();
spanning_tree_breadth(G,n_vertices,TH);
end = gethrtime();
interval=end-start;
total+=interval;
node_Barrier();
on_one_thread printf("METRICS:Time for spanning_tree_breadth is %f\n",interval/NANO);
node_Barrier();
start = gethrtime();
spanning_tree_breadth_B2(G,n_vertices,max_d_node,TH);
end = gethrtime();
interval=end-start;
total+=interval;
node_Barrier();
on_one_thread printf("METRICS:Time for spanning_tree_breadth_B2 is %f\n",interval/NANO);
node_Barrier();
start = gethrtime();
spanning_tree_e2d(G,n_vertices,TH);
end = gethrtime();
interval=end-start;
total+=interval;
node_Barrier();
on_one_thread printf("METRICS:Time for spanning_tree_e2d is %f\n",interval/NANO);
#if DEBUG_VERIFY
D=node_malloc(sizeof(int)*n_vertices,TH);
pardo(i,0,n_vertices,1) D[i]=G[i].parent;
node_Barrier();
pardo(i,0,n_vertices,1)
{
while(D[i]!=D[D[i]]){
D[i]=D[D[i]];
}
}
node_Barrier();
printf("pointer jumping done\n");
pardo(i,0,n_vertices,1)
{
if(D[i]!=D[0]) {
printf("error\n");
break;
}
}
printf("done verifying\n");
node_free(D,TH);
#endif
on_one_thread{
delete_graph(G,n_vertices);
if(El) free(El);
}
node_Barrier();
SIMPLE_done(TH);
}