Skip to content

Commit 0cf4768

Browse files
committed
---
yaml --- r: 12937 b: refs/heads/master c: 65abe2c h: refs/heads/master i: 12935: 5bff51c v: v3
1 parent fd604b9 commit 0cf4768

File tree

2 files changed

+39
-75
lines changed

2 files changed

+39
-75
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: cba2761cc4b0c1a8600928828f980bfb4466472d
2+
refs/heads/master: 65abe2c6dc4720e0c357bbc083814fd040399ced
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: 38 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,10 @@ fn validate(edges: [(node_id, node_id)],
403403
}
404404

405405
fn main() {
406-
let scale = 15u;
406+
let scale = 14u;
407407
let num_keys = 16u;
408408
let do_validate = false;
409+
let do_sequential = true;
409410

410411
let start = time::precise_time_s();
411412
let edges = make_edges(scale, 16u);
@@ -431,44 +432,49 @@ fn main() {
431432
gen_search_keys(graph, num_keys).map() {|root|
432433
io::stdout().write_line("");
433434
io::stdout().write_line(#fmt("Search key: %?", root));
434-
435-
let start = time::precise_time_s();
436-
let bfs_tree = bfs(graph, root);
437-
let stop = time::precise_time_s();
438-
439-
total_seq += stop - start;
440-
441-
io::stdout().write_line(#fmt("Sequential BFS completed in %? seconds.",
442-
stop - start));
443435

444-
if do_validate {
436+
if do_sequential {
445437
let start = time::precise_time_s();
446-
assert(validate(edges, root, bfs_tree));
438+
let bfs_tree = bfs(graph, root);
447439
let stop = time::precise_time_s();
448440

449-
io::stdout().write_line(#fmt("Validation completed in %? seconds.",
450-
stop - start));
451-
}
452-
453-
let start = time::precise_time_s();
454-
let bfs_tree = bfs2(graph, root);
455-
let stop = time::precise_time_s();
456-
457-
//total_seq += stop - start;
441+
//total_seq += stop - start;
458442

459-
io::stdout().write_line(
460-
#fmt("Slow Sequential BFS completed in %? seconds.",
461-
stop - start));
462-
463-
if do_validate {
443+
io::stdout().write_line(
444+
#fmt("Sequential BFS completed in %? seconds.",
445+
stop - start));
446+
447+
if do_validate {
448+
let start = time::precise_time_s();
449+
assert(validate(edges, root, bfs_tree));
450+
let stop = time::precise_time_s();
451+
452+
io::stdout().write_line(
453+
#fmt("Validation completed in %? seconds.",
454+
stop - start));
455+
}
456+
464457
let start = time::precise_time_s();
465-
assert(validate(edges, root, bfs_tree));
458+
let bfs_tree = bfs2(graph, root);
466459
let stop = time::precise_time_s();
467460

468-
io::stdout().write_line(#fmt("Validation completed in %? seconds.",
469-
stop - start));
461+
total_seq += stop - start;
462+
463+
io::stdout().write_line(
464+
#fmt("Alternate Sequential BFS completed in %? seconds.",
465+
stop - start));
466+
467+
if do_validate {
468+
let start = time::precise_time_s();
469+
assert(validate(edges, root, bfs_tree));
470+
let stop = time::precise_time_s();
471+
472+
io::stdout().write_line(
473+
#fmt("Validation completed in %? seconds.",
474+
stop - start));
475+
}
470476
}
471-
477+
472478
let start = time::precise_time_s();
473479
let bfs_tree = pbfs(graph, root);
474480
let stop = time::precise_time_s();
@@ -502,49 +508,7 @@ import comm::port;
502508
import comm::chan;
503509
import comm::send;
504510
import comm::recv;
505-
import task::spawn;
506-
507-
iface future<T: send> {
508-
fn get() -> T;
509-
}
510-
511-
type future_<T: send> = {
512-
mut slot : option<T>,
513-
port : port<T>,
514-
};
515-
516-
impl<T: send> of future<T> for future_<T> {
517-
fn get() -> T {
518-
get(self)
519-
}
520-
}
521-
522-
fn get<T: send>(f: future_<T>) -> T {
523-
alt(f.slot) {
524-
some(x) { x }
525-
none {
526-
let x = recv(f.port);
527-
f.slot = some(x);
528-
x
529-
}
530-
}
531-
}
532-
533-
534-
#[doc="Executes a bit of code asynchronously.
535-
536-
Returns a handle that can be used to retrieve the result at your
537-
leisure."]
538-
fn future<T: send>(thunk : fn~() -> T) -> future<T> {
539-
let p = port();
540-
let c = chan(p);
541-
542-
spawn() {||
543-
send(c, thunk());
544-
}
545-
546-
{mut slot: none::<T>, port : p} as future::<T>
547-
}
511+
import future::future;
548512

549513
#[doc="The maximum number of tasks this module will spawn for a single
550514
operationg."]
@@ -576,7 +540,7 @@ fn map_slices<A: send, B: send>(xs: [A], f: fn~(uint, [A]) -> B) -> [B] {
576540
while base < len {
577541
let slice = vec::slice(xs, base,
578542
uint::min(len, base + items_per_task));
579-
futures += [future() {|copy base|
543+
futures += [future::spawn() {|copy base|
580544
f(base, slice)
581545
}];
582546
base += items_per_task;

0 commit comments

Comments
 (0)