Skip to content

Commit

Permalink
More unsafe pointers to share immutable structures between tasks. Thi…
Browse files Browse the repository at this point in the history
…s version has a 2.8 to 3x speedup!
  • Loading branch information
eholk committed May 22, 2012
1 parent 7f05f08 commit 5a4e2ae
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions src/test/bench/graph500-bfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
}
};

#[inline(always)]
fn is_gray(c: color) -> bool {
alt c {
gray(_) { true }
Expand All @@ -274,25 +275,28 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
log(info, #fmt("PBFS iteration %?", i));
i += 1u;
let old_len = colors.len();
colors = par::mapi(colors) {|i, c, copy colors|
let pc = ptr::addr_of(colors);
let pg = ptr::addr_of(graph);
colors = par::mapi(colors) {|i, c|
let c : color = c;
alt c {
white {
let i = i as node_id;

let neighbors = graph[i];

let mut color = white;

neighbors.each() {|k|
if is_gray(colors[k]) {
color = gray(k);
false
}
else { true }
};

color
unsafe {
let i = i as node_id;

let neighbors = &(*pg)[i];

let mut color = white;

(*neighbors).each() {|k|
if is_gray((*pc)[k]) {
color = gray(k);
false
}
else { true }
};
color
}
}
gray(parent) { black(parent) }
black(parent) { black(parent) }
Expand Down

0 comments on commit 5a4e2ae

Please sign in to comment.