Skip to content

Commit b13d306

Browse files
Refactor computation logic for cluster processing
1 parent c0265c3 commit b13d306

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ cid4 = addcluster(<IP4>, 64; access_node_args = <A4>, compute_node_args = <C4>)
3636
@everywhere workers() reduce1(x) = @spawnat role = :worker 1 reduce0(x)
3737

3838
# run the computation logic at each computing process
39-
@everywhere cids @everywhere workers() begin
40-
MPI.Init()
41-
size = MPI.Comm_size(MPI.COMM_WORLD)
42-
rank = MPI.Comm_rank(MPI.COMM_WORLD)
43-
@info "my info: rank=$rank, size=$size, cluster=$clusterid"
44-
X = rand(1:10)
45-
r = MPI.Reduce(X, (x, y) -> x + y, 0, MPI.COMM_WORLD)
46-
rank == 0 && @spawnat role = :worker 1 reduce1(r)
47-
MPI.Finalize()
39+
for cid in clusters()
40+
@cluster_everywhere cid begin
41+
MPI.Init()
42+
size = MPI.Comm_size(MPI.COMM_WORLD)
43+
rank = MPI.Comm_rank(MPI.COMM_WORLD)
44+
@info "my info: rank=$rank, size=$size, cluster=$clusterid"
45+
X = rand(1:10)
46+
r = MPI.Reduce(X, (x, y) -> x + y, 0, MPI.COMM_WORLD)
47+
rank == 0 && @spawnat role = :worker 1 reduce1(r)
48+
MPI.Finalize()
49+
end
4850
end
4951

5052
@info "The sum across all clusters is $(SUM[])"

0 commit comments

Comments
 (0)