Distributed Computing in Julia
Overview
In Julia, this introduces how to schedule computations across multiple devices1. Honestly, I’m not quite sure myself.
Code
using Distributed
ip_ = []
for last in [160,161,162,163,164,32,33,34,35,36,43,44,45,46,47]
push!(ip_, join([155,230,211,last],'.'))
end
sort!(ip_)
for ip in ip_
addprocs([("chaos@" * ip, 8)]; dir ="/home/chaos", exename = "julia") #add slave node\'s workers
println("ip $ip" * " passed")
end
nworkers()
@everywhere function f(n)
return n^2 - n
end
A = pmap(f,1:20000)
X = []
@async @distributed for i in 1:200
print(f(i))
push!(X, f(i))
end
pmap
works well, but @distributed
does not.
Environment
- OS: Windows
- julia: v1.7.0