addprocs(6)
6-element Array{Int64,1}: 18 19 20 21 22 23
# define a slow function
@everywhere slow(n) = (sleep(n); sum(rand(n)))
# should take ~2 seconds
@time pmap(slow, [2,2,2,2]);
# define a new function that run pmaps on the slow function
@everywhere pp(n) = (sleep(n); pmap(slow, [n for _ in 1:n]))
# single invocation: 2 + 2 => 4
@time pp(2);
2.016586 seconds (472 allocations: 69.656 KiB) 4.040289 seconds (10.48 k allocations: 614.708 KiB)
# if the nested pmap works properly then it should take ~4 seconds
# if the nested pmap works serially then it should take ~6 seconds
for i in 1:10
@time pmap(pp, [2,2]);
end
5.746599 seconds (1.53 k allocations: 98.156 KiB) 4.011430 seconds (2.15 k allocations: 298.641 KiB) 4.011655 seconds (2.15 k allocations: 287.922 KiB) 4.012401 seconds (2.14 k allocations: 169.906 KiB) 4.010906 seconds (2.14 k allocations: 152.672 KiB) 4.011669 seconds (2.15 k allocations: 163.359 KiB) 4.012294 seconds (2.15 k allocations: 292.188 KiB) 4.075743 seconds (2.15 k allocations: 159.281 KiB) 4.011138 seconds (2.15 k allocations: 153.328 KiB) 4.010753 seconds (2.14 k allocations: 148.438 KiB)