From 04fd2f2a90ca60443ebae5085781098fd58146db Mon Sep 17 00:00:00 2001 From: Jonas Krimmer <30567171+jkrimmer@users.noreply.github.com> Date: Tue, 10 Sep 2024 08:53:09 +0200 Subject: [PATCH] Temporarily use safe FFTW planning (#66) * fix: make fftw planner threadsafe (quick n dirty) * fix: ccall signature * comment on workaround --------- Co-authored-by: Jonas Krimmer --- Project.toml | 1 + src/FINUFFT.jl | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Project.toml b/Project.toml index 67dafd3..f8ae7ec 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "3.2.0" Requires = "ae029012-a4dd-5104-9daa-d747884805df" cufinufft_jll = "d94e68af-94a2-5465-a03a-ccb69bb7181e" finufft_jll = "c41cd5a2-72a3-5203-9076-a500b088fc82" +FFTW_jll = "f5851436-0d7a-5f13-b9de-f02708fd171a" [compat] Requires = "1.3" diff --git a/src/FINUFFT.jl b/src/FINUFFT.jl index dcce07b..806a3ab 100644 --- a/src/FINUFFT.jl +++ b/src/FINUFFT.jl @@ -27,6 +27,10 @@ export finufftReal # By default we depend on our precompiled generic binary package... using finufft_jll const libfinufft = finufft_jll.libfinufft +# part of the thread-safety workaround +using FFTW_jll +const libfftw3 = FFTW_jll.libfftw3 +const libfftw3f = FFTW_jll.libfftw3f # # If instead you want to use your locally-compiled FINUFFT library for more # performance, comment out the above two code lines, uncomment the upcoming @@ -45,6 +49,12 @@ include("simple.jl") # Only load cuFINUFFT interface if CUDA is present (via `using CUDA`) and functional function __init__() + + # quick and dirty: make fftw thread safe + # get rid of this workaround as soon as https://github.com/flatironinstitute/finufft/pull/548 has been merged and deployed to finufft_jll + ccall((:fftw_make_planner_thread_safe, libfftw3), Cvoid, ()) + ccall((:fftwf_make_planner_thread_safe, libfftw3f), Cvoid, ()) + @require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" begin using .CUDA include("cufinufft.jl")