I follow the docs for concurrent programming in julia, and for my mind, which thinks like openMP or MPI, I find the design choice pretty strange.
I have an application in which I want the data to be distributed between processes, and then I want to tell each process to apply some operation to any data that is assigned to it, but I donβt see a way to do this in Julia. Here is an example
julia> r = remotecall(2, rand, 2) RemoteRef{Channel{Any}}(2,1,30) julia> fetch(r) 2-element Array{Float64,1}: 0.733308 0.45227
so process 2 lives in a random array with 2 elements. I can apply some function to this array through
julia> remotecall_fetch(2, getindex, r, 1) 0.7333080770447185
but why it doesnβt work if I use a function that should change the vector, like
julia> remotecall_fetch(2, setindex!, r, 1,1) ERROR: On worker 2: MethodError: `setindex!` has no method matching setindex!(::RemoteRef{Channel{Any}}, ::Int64, ::Int64) in anonymous at multi.jl:892 in run_work_thunk at multi.jl:645 [inlined code] from multi.jl:892 in anonymous at task.jl:63 in remotecall_fetch at multi.jl:731 in remotecall_fetch at multi.jl:734
I donβt quite know how to describe it, but it seems that workers can only return βnewβ things. I do not see how I can send some variables and a function to the worker, and the function will change the variables in place. In the above example, I would like the array to work in one process, and ideally, I could say that this process performs some operations on this array. After completing all the operations, I could get the results, etc.
parallel-processing mpi julia-lang
Lindon
source share