Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Feb 1, 2024
1 parent 421fb96 commit 820d205
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/parallel/distributed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ iii = 50
@Distributed.everywhere import CSV
@Distributed.everywhere @show @isdefined CSV

@Distributed.everywhere f(x) = (sleep(2); println(x^2))
@Distributed.everywhere @show @isdefined f
@Distributed.everywhere function_test(x) = (sleep(1); y = x^2; println(y); return y)
@Distributed.everywhere @show @isdefined function_test

@time map(f, 1:4)
@time Distributed.pmap(f, 1:4)
@time map(function_test, 1:4)
@time Distributed.pmap(function_test, 1:4)
@time @sync @Distributed.distributed for i = 1:4
f(4)
function_test(4)
end
12 changes: 12 additions & 0 deletions examples/parallel/distributed_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Distributed.@everywhere md_pta = $md_pta
Distributed.@everywhere f = Mads.makearrayfunction(md_pta)
Distributed.@everywhere @show f(rand(23))

Distributed.@everywhere @show myid()
import SharedArrays
sa = SharedArrays.SharedArray{Float64}(23, 5)
sa = zeros(23, 5)

@sync @Distributed.distributed for i = 1:5
sa[:, i] .= rand(23) .+ 2
end

0 comments on commit 820d205

Please sign in to comment.