Skip to content

Commit 1848425

Browse files
committed
---
yaml --- r: 15950 b: refs/heads/try c: b62d92c h: refs/heads/master v: v3
1 parent 0976d73 commit 1848425

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 44bea036147debabe22d148a55cb2ca6280e350e
5+
refs/heads/try: b62d92c993b9206b05be30ae7722adc6bdf91946
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/test/bench/graph500-bfs.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ fn make_edges(scale: uint, edgefactor: uint) -> [(node_id, node_id)] {
7171
(i, j)
7272
}
7373
else {
74-
let i = i * 2;
75-
let j = j * 2;
74+
let i = i * 2i64;
75+
let j = j * 2i64;
7676
let scale = scale - 1u;
7777

7878
let x = r.gen_float();
@@ -83,28 +83,30 @@ fn make_edges(scale: uint, edgefactor: uint) -> [(node_id, node_id)] {
8383
else {
8484
let x = x - A;
8585
if x < B {
86-
choose_edge(i + 1, j, scale, r)
86+
choose_edge(i + 1i64, j, scale, r)
8787
}
8888
else {
8989
let x = x - B;
9090
if x < C {
91-
choose_edge(i, j + 1, scale, r)
91+
choose_edge(i, j + 1i64, scale, r)
9292
}
9393
else {
94-
choose_edge(i + 1, j + 1, scale, r)
94+
choose_edge(i + 1i64, j + 1i64, scale, r)
9595
}
9696
}
9797
}
9898
}
9999
}
100100

101101
vec::from_fn((1u << scale) * edgefactor) {|_i|
102-
choose_edge(0, 0, scale, r)
102+
choose_edge(0i64, 0i64, scale, r)
103103
}
104104
}
105105

106106
fn make_graph(N: uint, edges: [(node_id, node_id)]) -> graph {
107-
let graph = vec::from_fn(N) {|_i| map::int_hash() };
107+
let graph = vec::from_fn(N) {|_i|
108+
map::hashmap::<node_id, ()>({|x| x as uint }, {|x, y| x == y })
109+
};
108110

109111
vec::each(edges) {|e|
110112
let (i, j) = e;
@@ -119,16 +121,16 @@ fn make_graph(N: uint, edges: [(node_id, node_id)]) -> graph {
119121
}
120122

121123
fn gen_search_keys(graph: graph, n: uint) -> [node_id] {
122-
let keys = map::int_hash();
124+
let keys = map::hashmap::<node_id, ()>({|x| x as uint }, {|x, y| x == y });
123125
let r = rand::rng();
124126

125127
while keys.size() < n {
126-
let k = r.gen_u64() % graph.len() as node_id;
128+
let k = r.gen_uint_range(0u, graph.len());
127129

128130
if graph[k].len() > 0u && vec::any(graph[k]) {|i|
129-
i != k
131+
i != k as node_id
130132
} {
131-
map::set_add(keys, k);
133+
map::set_add(keys, k as node_id);
132134
}
133135
}
134136
map::vec_from_set(keys)
@@ -139,7 +141,7 @@ fn gen_search_keys(graph: graph, n: uint) -> [node_id] {
139141
Nodes that are unreachable have a parent of -1."]
140142
fn bfs(graph: graph, key: node_id) -> bfs_result {
141143
let marks : [mut node_id]
142-
= vec::to_mut(vec::from_elem(vec::len(graph), -1));
144+
= vec::to_mut(vec::from_elem(vec::len(graph), -1i64));
143145

144146
let Q = create_queue();
145147

@@ -150,7 +152,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
150152
let t = Q.pop_front();
151153

152154
graph[t].each() {|k|
153-
if marks[k] == -1 {
155+
if marks[k] == -1i64 {
154156
marks[k] = t;
155157
Q.add_back(k);
156158
}
@@ -226,7 +228,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
226228
// Convert the results.
227229
vec::map(colors) {|c|
228230
alt c {
229-
white { -1 }
231+
white { -1i64 }
230232
black(parent) { parent }
231233
_ { fail "Found remaining gray nodes in BFS" }
232234
}
@@ -301,7 +303,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
301303
// Convert the results.
302304
par::map(colors) {|c|
303305
alt c {
304-
white { -1 }
306+
white { -1i64 }
305307
black(parent) { parent }
306308
_ { fail "Found remaining gray nodes in BFS" }
307309
}
@@ -326,7 +328,7 @@ fn validate(edges: [(node_id, node_id)],
326328
let mut parent = parent;
327329
let mut path = [];
328330

329-
if parent == -1 {
331+
if parent == -1i64 {
330332
// This node was not in the tree.
331333
-1
332334
}
@@ -354,7 +356,7 @@ fn validate(edges: [(node_id, node_id)],
354356
log(info, "Verifying tree edges...");
355357

356358
let status = tree.alli() {|k, parent|
357-
if parent != root && parent != -1 {
359+
if parent != root && parent != -1i64 {
358360
level[parent] == level[k] - 1
359361
}
360362
else {
@@ -387,11 +389,12 @@ fn validate(edges: [(node_id, node_id)],
387389
log(info, "Verifying tree and graph edges...");
388390

389391
let status = par::alli(tree) {|u, v|
390-
if v == -1 || u as int == root {
392+
let u = u as node_id;
393+
if v == -1i64 || u == root {
391394
true
392395
}
393396
else {
394-
edges.contains((u as int, v)) || edges.contains((v, u as int))
397+
edges.contains((u, v)) || edges.contains((v, u))
395398
}
396399
};
397400

0 commit comments

Comments
 (0)