I stumbled across something strage: the various ClusterManagers
functions and operations, such as workers()
, nworkers()
, procs()
, nprocs()
, etc. work fine when run a code, unless it's inside a module.
Here's the content of a basic test case JuliaTest.jl
:
using MPI
using ClusterManagers
println(workers()," ",nworkers()," ",procs()," ",nprocs())
with julia -p 3 JuliaTest.jl
I get correct results:
[2, 3, 4] 3 [1, 2, 3, 4] 4
However, when using the exact same code enclosed in a module:
module JuliaTest
using MPI
using ClusterManagers
println(workers()," ",nworkers()," ",procs()," ",nprocs())
end
I get errors:
ERROR: LoadError: UndefVarError: `workers` not defined
Stacktrace:
[1] top-level scope
@ ~/JuliaTest.jl:6
in expression starting at /home/JuliaTest.jl:1
Is there a reason for this? Is there a solution for this?
Apparently this is because the module is not exposed to the Distributed
package, and adding using Distributed
solved that.