Reputation: 101
In the following files
test.jl
push!(LOAD_PATH, string(pwd(), "/lib/"))
@everywhere using Parent
addprocs(2)
Parent.Child.test()
lib/Parent.jl
@everywhere module Parent
struct INT
i::Int64
end
include("Child.jl")
end
lib/Child.jl
module Child
import Parent
function test()
a = [1, 2, 3, 4, 5]
@parallel (+) for x in a
i = Parent.INT(x)
println(x)
x
end
end
end
I am getting following errors:
% julia test.jl
ERROR: ERROR (unhandled task failure): On worker 3:
UndefVarError: Parent not defined
Using either @parallel for or pmap would get the same errors.
However, if I put everything outside any modules then the codes work fine.
Removing "addprocs(2)" then everything works fine too.
My project consists of many modules and submodules, and would love to retain the modular structure. However, I am very new to Julia and probably do not know how to it up correctly. What am I doing wrong here?
Upvotes: 0
Views: 179
Reputation: 101
I solved my problem!
addprocs(2)
needs to be first thing on test.jl
Upvotes: 1