0
votes

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?

1
I also found that putting function test() in Parent Module and removing the Child Module altogether gives the same error. - Atip Asvanund

1 Answers

1
votes

I solved my problem!

addprocs(2)

needs to be first thing on test.jl