I’m running into an issue that I can’t wrap my head around. Here’s a MWE reduced from a more complex code:
i = 0
for j = 1:2
global i
i = j
@show :before, myid(), i
@everywhere i = remotecall_fetch(()->i, 1)
@show :after, myid(), i
end
@show i
Case 1: start julia with julia -p N
where N
is at least 1, the output is
(:before, myid(), i) = (:before, 1, 1)
(:after, myid(), i) = (:after, 1, 1)
(:before, myid(), i) = (:before, 1, 2)
(:after, myid(), i) = (:after, 1, 1)
i = 1
1
Case 2: start julia with julia
(i.e., without -p N
), the output is
(:before, myid(), i) = (:before, 1, 1)
(:after, myid(), i) = (:after, 1, 1)
(:before, myid(), i) = (:before, 1, 2)
(:after, myid(), i) = (:after, 1, 2)
i = 2
2
The case 2 output is what I would expect to happen regardless of the number of processors. I don’t understand those last two outputs where i=1
from case 1. Can anyone help me understand what is going on there? What am I missing? Is this a bug? Is this a feature?