False alarm, everyone; turns out my RAM was corrupted.
Julia `remotecall` threads giving different results
-
19-07-2023 - |
Question
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;
- Julia 0.2.1
- Linux 3.5.0-17-generic (x86_64)
- Intel Core i5-2430M
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow