@@ -199,7 +199,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
199
199
}
200
200
201
201
#[ doc="A parallel version of the bfs function." ]
202
- fn pbfs ( graph : graph , key : node_id ) -> bfs_result {
202
+ fn pbfs ( & & graph: arc :: arc < graph > , key : node_id ) -> bfs_result {
203
203
// This works by doing functional updates of a color vector.
204
204
205
205
enum color {
@@ -210,7 +210,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
210
210
black( node_id )
211
211
} ;
212
212
213
- let mut colors = vec:: from_fn ( graph. len ( ) ) { |i|
213
+ let mut colors = vec:: from_fn ( ( * arc :: get ( & graph) ) . len ( ) ) { |i|
214
214
if i as node_id == key {
215
215
gray ( key)
216
216
}
@@ -227,8 +227,6 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
227
227
}
228
228
}
229
229
230
- let graph = arc:: arc ( copy graph) ;
231
-
232
230
let mut i = 0 u;
233
231
while par:: any ( colors, is_gray) {
234
232
// Do the BFS.
@@ -386,7 +384,7 @@ fn main(args: [str]) {
386
384
let scale = uint:: from_str ( args[ 1 ] ) . get ( ) ;
387
385
let num_keys = uint:: from_str ( args[ 2 ] ) . get ( ) ;
388
386
let do_validate = false ;
389
- let do_sequential = true ;
387
+ let do_sequential = false ;
390
388
391
389
let start = time:: precise_time_s ( ) ;
392
390
let edges = make_edges ( scale, 16 u) ;
@@ -409,6 +407,8 @@ fn main(args: [str]) {
409
407
let mut total_seq = 0.0 ;
410
408
let mut total_par = 0.0 ;
411
409
410
+ let graph_arc = arc:: arc ( copy graph) ;
411
+
412
412
gen_search_keys ( graph, num_keys) . map ( ) { |root|
413
413
io:: stdout ( ) . write_line ( "" ) ;
414
414
io:: stdout ( ) . write_line ( #fmt ( "Search key: %?" , root) ) ;
@@ -456,7 +456,7 @@ fn main(args: [str]) {
456
456
}
457
457
458
458
let start = time:: precise_time_s ( ) ;
459
- let bfs_tree = pbfs ( graph , root) ;
459
+ let bfs_tree = pbfs ( graph_arc , root) ;
460
460
let stop = time:: precise_time_s ( ) ;
461
461
462
462
total_par += stop - start;
0 commit comments