-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
Is it possible that Dierckx.jl is not thread safe? evaluation is fine but derivatives seem to fail; see below for an explanation.
# file mtsplines.jl
using Dierckx, Random, .Threads
let
xdat = range(0, 1, length=100)
spl = Spline1D(xdat, exp.(xdat))
Random.seed!(0)
r = rand(10_000)
s = zeros(nthreads())
@threads for n = 1:length(r)
s[threadid()] += Dierckx.derivative(spl, r[n])
end
@show sum(s) / length(r)
endThis script yields the following output:
(base) Fuji-2:temp ortner$ j16 --threads=1 mtsplines.jl
sum(s) / length(r) = 1.7170295968665945
(base) Fuji-2:temp ortner$ j16 --threads=1 mtsplines.jl
sum(s) / length(r) = 1.7170295968665945
(base) Fuji-2:temp ortner$ j16 --threads=4 mtsplines.jl
sum(s) / length(r) = -792.7283310922177
(base) Fuji-2:temp ortner$ j16 --threads=4 mtsplines.jl
sum(s) / length(r) = -104735.52438361687Metadata
Metadata
Assignees
Labels
No labels