Skip to content

Commit 4bc920c

Browse files
committed
Do not unconditionally load MKL_jll but match platforms
1 parent 453aa11 commit 4bc920c

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

src/FFTW.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ import AbstractFFTs: Plan, ScaledPlan,
1111
fftshift, ifftshift,
1212
rfft_output_size, brfft_output_size,
1313
plan_inv, normalization
14-
import FFTW_jll
15-
import MKL_jll
1614

1715
export dct, idct, dct!, idct!, plan_dct, plan_idct, plan_dct!, plan_idct!
1816

src/providers.jl

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
const valid_fftw_providers = if FFTW_jll.is_available() && MKL_jll.is_available()
2-
("fftw", "mkl")
3-
elseif FFTW_jll.is_available()
4-
("fftw",)
5-
elseif MKL_jll.is_available()
6-
("mkl",)
7-
else
1+
# Hardcoded list of supported platforms
2+
# In principle, we could check FFTW_jll.is_available() and MKL_jll.is_available()
3+
# but then we would have to load MKL_jll which we want to avoid (lazy artifacts!)
4+
const platforms_providers = Dict(
5+
Base.BinaryPlatforms.Platform("aarch64", "macos") => ("fftw",),
6+
Base.BinaryPlatforms.Platform("aarch64", "linux"; libc = "glibc") => ("fftw",),
7+
Base.BinaryPlatforms.Platform("aarch64", "linux"; libc = "musl") => ("fftw",),
8+
Base.BinaryPlatforms.Platform("armv7l", "linux"; libc = "glibc", call_abi = "eabihf") => ("fftw",),
9+
Base.BinaryPlatforms.Platform("armv7l", "linux"; libc = "musl", call_abi = "eabihf") => ("fftw",),
10+
Base.BinaryPlatforms.Platform("i686", "linux"; libc = "glibc") => ("fftw", "mkl"),
11+
Base.BinaryPlatforms.Platform("i686", "linux"; libc = "musl") => ("fftw",),
12+
Base.BinaryPlatforms.Platform("i686", "windows") => ("fftw", "mkl"),
13+
Base.BinaryPlatforms.Platform("powerpc64le", "linux"; libc = "glibc") => ("fftw",),
14+
Base.BinaryPlatforms.Platform("x86_64", "macos") => ("fftw", "mkl"),
15+
Base.BinaryPlatforms.Platform("x86_64", "linux"; libc = "glibc") => ("fftw",),
16+
Base.BinaryPlatforms.Platform("x86_64", "linux"; libc = "musl") => ("fftw",),
17+
Base.BinaryPlatforms.Platform("x86_64", "freebsd") => ("fftw",),
18+
Base.BinaryPlatforms.Platform("x86_64", "windows") => ("fftw", "mkl"),
19+
)
20+
const valid_fftw_providers = Base.BinaryPlatforms.select_platform(platforms_providers, Base.BinaryPlatforms.HostPlatform())
21+
if valid_fftw_providers === nothing
822
error("no valid FFTW library available")
923
end
1024

@@ -56,6 +70,12 @@ end
5670

5771
# If we're using fftw_jll, load it in
5872
@static if fftw_provider == "fftw"
73+
import FFTW_jll
74+
if !FFTW_jll.is_available()
75+
# more descriptive error message if FFTW is not available
76+
# (should not be possible to reach this)
77+
error("FFTW library cannot be loaded: please switch to the `mkl` provider for FFTW.jl")
78+
end
5979
libfftw3[] = FFTW_jll.libfftw3_path
6080
libfftw3f[] = FFTW_jll.libfftw3f_path
6181

@@ -90,6 +110,12 @@ end
90110

91111
# If we're using MKL, load it in and set library paths appropriately.
92112
@static if fftw_provider == "mkl"
113+
import MKL_jll
114+
if !MKL_jll.is_available()
115+
# more descriptive error message if MKL is not available
116+
# (should not be possible to reach this)
117+
error("MKL library cannot be loaded: please switch to the `fftw` provider for FFTW.jl")
118+
end
93119
libfftw3[] = MKL_jll.libmkl_rt_path
94120
libfftw3f[] = MKL_jll.libmkl_rt_path
95121
const _last_num_threads = Ref(Cint(1))

0 commit comments

Comments
 (0)