Interpolations.jl icon indicating copy to clipboard operation
Interpolations.jl copied to clipboard

add multithreading support via Threads.@spawn?

Open floswald opened this issue 5 years ago • 7 comments

hi i was wondering whether there is any scope to add multithreading support to this library. i read this https://julialang.org/blog/2019/07/multithreading/ and i was hoping one could think about the interpolation loop here in the same way as in their psort! example? like thread number 1 interpolates the first half of points, thread 2 the second half?

floswald avatar Feb 10 '20 16:02 floswald

Which loop? Most of the package is devoted to supporting itp(x, y, ...), and there's no way threading will help that particular operation. Prefiltering might be one area where it would make sense, and perhaps there would be others.

A PR would certainly be evaluated, but it would have to include benchmarks.

timholy avatar Feb 10 '20 19:02 timholy

Oh. I was thinking if I want to evaluate an interpolation object at many points, it might make sense to split that operation amongst threads. I was king of assuming there is a loop somewhere involved - nevermind if that’s not the case.

On Mon 10 Feb 2020 at 20:14, Tim Holy [email protected] wrote:

Which loop? Most of the package is devoted to supporting itp(x, y, ...), and there's no way threading will help that particular operation. Prefiltering might be one area where it would make sense, and perhaps there would be others.

A PR would certainly be evaluated, but it would have to include benchmarks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/JuliaMath/Interpolations.jl/issues/356?email_source=notifications&email_token=AAHZM5X755GNCTOITCJH6OTRCGRPXA5CNFSM4KSQ2N4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELJ336Q#issuecomment-584302074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZM5R2YNHEQF3QGKJGDCDRCGRPXANCNFSM4KSQ2N4A .

floswald avatar Feb 10 '20 19:02 floswald

How are you evaluating it?

timholy avatar Feb 10 '20 19:02 timholy

I would do something like

out = interpolate((xvec,),yvec,Gridded(Linear()))(newx)

where newx has many values.

floswald avatar Feb 10 '20 19:02 floswald

Oh, I see, yes, if you're using vectorized evaluation then it would make sense. Want to try a PR?

timholy avatar Feb 10 '20 19:02 timholy

i can try. if you can point me to where I need to start digging 😃 . thanks!

floswald avatar Feb 10 '20 20:02 floswald

Just try @edit itp(newx) and see where it takes you. It will almost certain be the top-level function.

timholy avatar Feb 16 '20 07:02 timholy