Reputation: 3715
While learning Julia from the manual, I wanted to see if I could get Julia to run a hard computation on all four of my CPU's cores at once. I launched Julia with this command;
julia -p 4
Then I defined the following function, just for the purpose of doing a lot of arithmetic. The mod 13 is there so that it doesn't print a huge number in the end.
@everywhere function hard_computation()
bigexp = BigInt(999)^99999999
bigexp % 13
end
Then I tell Julia to do this in four separate processes.
for i in 1:4
push!(r, remotecall(i, hard_computation))
end
When I fetch
ed the values in r, I got [5, 6, 5, 5]
. I tried it several more times, and got; 5, 5, 5, 5, 5, 1, 5, 5, 5, 2, 0, 5, 5, 5, 5, 7
. The correct answer is 5
.
So... what's going wrong?
System info;
Upvotes: 9
Views: 227