Skip to content

Commit 58fdbdc

Browse files
committed
Avoid some more copies.
1 parent f0c3458 commit 58fdbdc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/test/bench/graph500-bfs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
199199
}
200200

201201
#[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 {
203203
// This works by doing functional updates of a color vector.
204204

205205
enum color {
@@ -210,7 +210,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
210210
black(node_id)
211211
};
212212

213-
let mut colors = vec::from_fn(graph.len()) {|i|
213+
let mut colors = vec::from_fn((*arc::get(&graph)).len()) {|i|
214214
if i as node_id == key {
215215
gray(key)
216216
}
@@ -227,8 +227,6 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
227227
}
228228
}
229229

230-
let graph = arc::arc(copy graph);
231-
232230
let mut i = 0u;
233231
while par::any(colors, is_gray) {
234232
// Do the BFS.
@@ -386,7 +384,7 @@ fn main(args: [str]) {
386384
let scale = uint::from_str(args[1]).get();
387385
let num_keys = uint::from_str(args[2]).get();
388386
let do_validate = false;
389-
let do_sequential = true;
387+
let do_sequential = false;
390388

391389
let start = time::precise_time_s();
392390
let edges = make_edges(scale, 16u);
@@ -409,6 +407,8 @@ fn main(args: [str]) {
409407
let mut total_seq = 0.0;
410408
let mut total_par = 0.0;
411409

410+
let graph_arc = arc::arc(copy graph);
411+
412412
gen_search_keys(graph, num_keys).map() {|root|
413413
io::stdout().write_line("");
414414
io::stdout().write_line(#fmt("Search key: %?", root));
@@ -456,7 +456,7 @@ fn main(args: [str]) {
456456
}
457457

458458
let start = time::precise_time_s();
459-
let bfs_tree = pbfs(graph, root);
459+
let bfs_tree = pbfs(graph_arc, root);
460460
let stop = time::precise_time_s();
461461

462462
total_par += stop - start;

0 commit comments

Comments
 (0)