From 65abe2c6dc4720e0c357bbc083814fd040399ced Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 16 May 2012 15:54:50 -0700 Subject: [PATCH] Using libstd future instead. Turning off sequential versions for tracing. --- src/test/bench/graph500-bfs.rs | 112 +++++++++++---------------------- 1 file changed, 38 insertions(+), 74 deletions(-) diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 14a0ea9d87a..0f6b82c5d85 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -403,9 +403,10 @@ fn validate(edges: [(node_id, node_id)], } fn main() { - let scale = 15u; + let scale = 14u; let num_keys = 16u; let do_validate = false; + let do_sequential = true; let start = time::precise_time_s(); let edges = make_edges(scale, 16u); @@ -431,44 +432,49 @@ fn main() { gen_search_keys(graph, num_keys).map() {|root| io::stdout().write_line(""); io::stdout().write_line(#fmt("Search key: %?", root)); - - let start = time::precise_time_s(); - let bfs_tree = bfs(graph, root); - let stop = time::precise_time_s(); - total_seq += stop - start; - - io::stdout().write_line(#fmt("Sequential BFS completed in %? seconds.", - stop - start)); - - if do_validate { + if do_sequential { let start = time::precise_time_s(); - assert(validate(edges, root, bfs_tree)); + let bfs_tree = bfs(graph, root); let stop = time::precise_time_s(); - io::stdout().write_line(#fmt("Validation completed in %? seconds.", - stop - start)); - } + //total_seq += stop - start; - let start = time::precise_time_s(); - let bfs_tree = bfs2(graph, root); - let stop = time::precise_time_s(); - - //total_seq += stop - start; - - io::stdout().write_line( - #fmt("Slow Sequential BFS completed in %? seconds.", - stop - start)); - - if do_validate { + io::stdout().write_line( + #fmt("Sequential BFS completed in %? seconds.", + stop - start)); + + if do_validate { + let start = time::precise_time_s(); + assert(validate(edges, root, bfs_tree)); + let stop = time::precise_time_s(); + + io::stdout().write_line( + #fmt("Validation completed in %? seconds.", + stop - start)); + } + let start = time::precise_time_s(); - assert(validate(edges, root, bfs_tree)); + let bfs_tree = bfs2(graph, root); let stop = time::precise_time_s(); - io::stdout().write_line(#fmt("Validation completed in %? seconds.", - stop - start)); + total_seq += stop - start; + + io::stdout().write_line( + #fmt("Alternate Sequential BFS completed in %? seconds.", + stop - start)); + + if do_validate { + let start = time::precise_time_s(); + assert(validate(edges, root, bfs_tree)); + let stop = time::precise_time_s(); + + io::stdout().write_line( + #fmt("Validation completed in %? seconds.", + stop - start)); + } } - + let start = time::precise_time_s(); let bfs_tree = pbfs(graph, root); let stop = time::precise_time_s(); @@ -502,49 +508,7 @@ import comm::port; import comm::chan; import comm::send; import comm::recv; -import task::spawn; - -iface future { - fn get() -> T; -} - -type future_ = { - mut slot : option, - port : port, -}; - -impl of future for future_ { - fn get() -> T { - get(self) - } -} - -fn get(f: future_) -> T { - alt(f.slot) { - some(x) { x } - none { - let x = recv(f.port); - f.slot = some(x); - x - } - } -} - - -#[doc="Executes a bit of code asynchronously. - -Returns a handle that can be used to retrieve the result at your -leisure."] -fn future(thunk : fn~() -> T) -> future { - let p = port(); - let c = chan(p); - - spawn() {|| - send(c, thunk()); - } - - {mut slot: none::, port : p} as future:: -} +import future::future; #[doc="The maximum number of tasks this module will spawn for a single operationg."] @@ -576,7 +540,7 @@ fn map_slices(xs: [A], f: fn~(uint, [A]) -> B) -> [B] { while base < len { let slice = vec::slice(xs, base, uint::min(len, base + items_per_task)); - futures += [future() {|copy base| + futures += [future::spawn() {|copy base| f(base, slice) }]; base += items_per_task;