Skip to content

Commit 9a3850b

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

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-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: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
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("armv6l", "linux"; libc = "glibc", call_abi = "eabihf") => ("fftw",),
9+
Base.BinaryPlatforms.Platform("armv6l", "linux"; libc = "musl", call_abi = "eabihf") => ("fftw",),
10+
Base.BinaryPlatforms.Platform("armv7l", "linux"; libc = "glibc", call_abi = "eabihf") => ("fftw",),
11+
Base.BinaryPlatforms.Platform("armv7l", "linux"; libc = "musl", call_abi = "eabihf") => ("fftw",),
12+
Base.BinaryPlatforms.Platform("i686", "linux"; libc = "glibc") => ("fftw", "mkl"),
13+
Base.BinaryPlatforms.Platform("i686", "linux"; libc = "musl") => ("fftw",),
14+
Base.BinaryPlatforms.Platform("i686", "windows") => ("fftw", "mkl"),
15+
Base.BinaryPlatforms.Platform("powerpc64le", "linux"; libc = "glibc") => ("fftw",),
16+
Base.BinaryPlatforms.Platform("x86_64", "macos") => ("fftw", "mkl"),
17+
Base.BinaryPlatforms.Platform("x86_64", "linux"; libc = "glibc") => ("fftw",),
18+
Base.BinaryPlatforms.Platform("x86_64", "linux"; libc = "musl") => ("fftw",),
19+
Base.BinaryPlatforms.Platform("x86_64", "freebsd") => ("fftw",),
20+
Base.BinaryPlatforms.Platform("x86_64", "windows") => ("fftw", "mkl"),
21+
)
22+
const valid_fftw_providers = Base.BinaryPlatforms.select_platform(platforms_providers, Base.BinaryPlatforms.HostPlatform())
23+
if valid_fftw_providers === nothing
824
error("no valid FFTW library available")
925
end
1026

@@ -56,6 +72,12 @@ end
5672

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

@@ -90,6 +112,12 @@ end
90112

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

0 commit comments

Comments
 (0)