From 820d205415e7d159b2ac8d53af3c75a9117bb636 Mon Sep 17 00:00:00 2001 From: monty Date: Thu, 1 Feb 2024 16:06:03 -0700 Subject: [PATCH] tests --- examples/parallel/distributed.jl | 10 +++++----- examples/parallel/distributed_test.jl | 12 ++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 examples/parallel/distributed_test.jl diff --git a/examples/parallel/distributed.jl b/examples/parallel/distributed.jl index 06aaec52..645af89a 100644 --- a/examples/parallel/distributed.jl +++ b/examples/parallel/distributed.jl @@ -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 \ No newline at end of file diff --git a/examples/parallel/distributed_test.jl b/examples/parallel/distributed_test.jl new file mode 100644 index 00000000..3d29458f --- /dev/null +++ b/examples/parallel/distributed_test.jl @@ -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