Skip to content

Commit 5bff51c

Browse files
committed
---
yaml --- r: 12935 b: refs/heads/master c: 4312fa4 h: refs/heads/master i: 12933: 4d2dd17 12931: aef0743 12927: bc1d0bb v: v3
1 parent 0b5b9dc commit 5bff51c

File tree

2 files changed

+70
-19
lines changed

2 files changed

+70
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a79f5174ea1be8a90d7e02957ebbf7837916931b
2+
refs/heads/master: 4312fa44b9cab69aa08834016484cfec47f19843
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/test/bench/graph500-bfs.rs

Lines changed: 69 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,30 @@ fn make_graph(N: uint, edges: [(node_id, node_id)]) -> graph {
115115
}
116116

117117
graph.map() {|v|
118-
let mut neighbors = [];
119-
v.each_key() {|u|
120-
neighbors += [u];
121-
true
122-
};
118+
map::vec_from_set(v)
119+
}
120+
}
121+
122+
fn gen_search_keys(graph: graph, n: uint) -> [node_id] {
123+
let keys = map::int_hash();
124+
let r = rand::rng();
125+
126+
impl methods for rand::rng {
127+
fn r64() -> u64 {
128+
self.next() as u64 << 32u + self.next() as u64
129+
}
130+
}
123131

124-
neighbors
132+
while keys.size() < n {
133+
let k = r.r64() % graph.len() as node_id;
134+
135+
if graph[k].len() > 0u && vec::any(graph[k]) {|i|
136+
i != k
137+
} {
138+
map::set_add(keys, k);
139+
}
125140
}
141+
map::vec_from_set(keys)
126142
}
127143

128144
#[doc="Returns a vector of all the parents in the BFS tree rooted at key.
@@ -315,7 +331,9 @@ fn validate(edges: [(node_id, node_id)],
315331
}
316332

317333
fn main() {
318-
let scale = 14u;
334+
let scale = 15u;
335+
let num_keys = 16u;
336+
let do_validate = false;
319337

320338
let start = time::precise_time_s();
321339
let edges = make_edges(scale, 16u);
@@ -335,21 +353,54 @@ fn main() {
335353
total_edges / 2u,
336354
stop - start));
337355

338-
let root = 0;
356+
let mut total_seq = 0.0;
357+
let mut total_par = 0.0;
358+
359+
gen_search_keys(graph, num_keys).map() {|root|
360+
io::stdout().write_line("");
361+
io::stdout().write_line(#fmt("Search key: %?", root));
339362

340-
let start = time::precise_time_s();
341-
let bfs_tree = pbfs(graph, root);
342-
let stop = time::precise_time_s();
363+
let start = time::precise_time_s();
364+
let bfs_tree = bfs(graph, root);
365+
let stop = time::precise_time_s();
343366

344-
io::stdout().write_line(#fmt("BFS completed in %? seconds.",
345-
stop - start));
367+
total_seq += stop - start;
346368

347-
let start = time::precise_time_s();
348-
assert(validate(edges, root, bfs_tree));
349-
let stop = time::precise_time_s();
369+
io::stdout().write_line(#fmt("Sequential BFS completed in %? seconds.",
370+
stop - start));
350371

351-
io::stdout().write_line(#fmt("Validation completed in %? seconds.",
352-
stop - start));
372+
if do_validate {
373+
let start = time::precise_time_s();
374+
assert(validate(edges, root, bfs_tree));
375+
let stop = time::precise_time_s();
376+
377+
io::stdout().write_line(#fmt("Validation completed in %? seconds.",
378+
stop - start));
379+
}
380+
381+
let start = time::precise_time_s();
382+
let bfs_tree = pbfs(graph, root);
383+
let stop = time::precise_time_s();
384+
385+
total_par += stop - start;
386+
387+
io::stdout().write_line(#fmt("Parallel BFS completed in %? seconds.",
388+
stop - start));
389+
390+
if do_validate {
391+
let start = time::precise_time_s();
392+
assert(validate(edges, root, bfs_tree));
393+
let stop = time::precise_time_s();
394+
395+
io::stdout().write_line(#fmt("Validation completed in %? seconds.",
396+
stop - start));
397+
}
398+
};
399+
400+
io::stdout().write_line("");
401+
io::stdout().write_line(
402+
#fmt("Total sequential: %? \t Total Parallel: %? \t Speedup: %?x",
403+
total_seq, total_par, total_seq / total_par));
353404
}
354405

355406

0 commit comments

Comments
 (0)