(Parallel) Using pmap within modules

question

#1

I cannot figure out how to use pmap from within a module. For instance the following code works:

@everywhere module Work
  w(i) = myid()
end

module Sub

using Work

function go()
  p = pmap(Work.w, 1:10 )
  println(p)
end

go()

end

Scoping the the same code within a Top module, i.e.

module Top

@everywhere module Work
  w(i) = myid()
end

module Sub

using Work

function go()
  p = pmap(Work.w, 1:10 )
  println(p)
end

go()

end

end

errors with:

LoadError: On worker 2:
UndefVarError: Top not defined
in deserialize at ./serialize.jl:602

I’m using a deeply nested module hierarchy. In summary: I cannot see how to use the parallel functionality at any module level lower than the top level. Advice much appreciated!


#2

Not that I have an answer to your question, but this behavior is fixed on the current 0.6-dev:

julia> addprocs(3)
3-element Array{Int64,1}:
 2
 3
 4

julia> module Top

       @everywhere module Work
         w(i) = myid()
       end

       module Sub

       using Work

       function go()
         p = pmap(Work.w, 1:10 )
         println(p)
       end

       go()

       end

       end
[2, 3, 4, 2, 2, 2, 2, 2, 2, 2]
Top

julia> Top.Sub.go()
[2, 3, 4, 2, 3, 4, 2, 3, 4, 2]


#3

@dfdx Confirmed, seems to be an 0.5.0 issue. Thanks!


#4

The @everywhere will define Work as a top-level module on all processes (can be confirmed with whos() and remote_do(whos, 2)).