I have two files
test_file.jl
using Distributed
function inner_function(v)
v_2 = 2 * v
return v_2
end
function loop(N, v)
@sync @distributed for i in 1:N
v_3 = inner_function(v)
v_3[1] = i
println(i)
println(v_3)
end
end
test_file_call.jl
@everywhere include("test_file.jl")
v = [1 2 3 4]
loop(100,v_2)
When I run julia -p 2 test_file_call.jl
, I get an error saying that
ERROR: LoadError: UndefVarError: v_2 not defined
I'm not sure why. v_2
is a variable created in a function and I've already used @everywhere include("test_file.jl")
so Julia shouldn't say that the variable is undefined. Can I get a hint? Thank you!