I previously created a post where I described issues of my algorithm running on multi threading.
I think I finally found the issue:
I am using the default sin / cos functions and this post:
led me to the idea that the sin / cos could cause the issue.
When I temporarly removed the sin / cos functions (but they are definitely required for the algorithm), the algorithm performed well on multi threading.
Thats why I did a few testings with the sample code
function test() setprecision(1024) Threads.@threads for i=1:10000000 sin(BigFloat(i))^2+cos(BigFloat(i))^2 end end
It confirmed that this function is not threadsafe:
1 Threads: 347.428779 seconds (552.06 M allocations: 48.274 GiB, 0.93% gc time)
4 Threads: 118.963835 seconds (525.86 M allocations: 43.746 GiB, 4.19% gc time)
28 Threads: 137.302679 seconds (211.11 M allocations: 10.939 GiB, 8.41% gc time)
40 Threads: 125.110352 seconds (201.09 M allocations: 10.696 GiB, 10.58% gc time)
56 Threads: 119.466149 seconds (195.01 M allocations: 10.744 GiB, 11.99% gc time)
So at first, it would be nice if you could fix this, or at least give a warning because I had to spent quite some time finding this issue.
I saw a workaround at the previous post:
Which does indeed seem to be thread safe.
However, I cannot apply this workaround since I have to work with multiprecision and when I change Float64 -> BigFloat at the code, Julia just crashes.
My question would now be if someone knows another workaround that works with multiprecision as well.
Thanks in advance