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
8
+ error (" no valid FFTW library available" )
9
+ end
1
10
2
11
function get_provider ()
3
12
# Note: we CANNOT do something like have the `default` value be `get(ENV, "JULIA_FFTW_PROVIDER", "fftw")` here.
4
13
# This is because the only way the Julia knows that a default has changed is if the values on-disk change; so
5
14
# if your "default" value can be changed from the outside, you quickly run into cache invalidation issues.
6
15
# So the default here _must_ be a constant.
7
- default_provider = " fftw "
16
+ default_provider = first (valid_fftw_providers)
8
17
9
18
# Load the preference
10
19
provider = @load_preference (" provider" , default_provider)
11
20
12
21
# Ensure the provider matches one of the ones we support
13
- if provider ∉ ( " fftw " , " mkl " )
14
- @error (" Invalid provider setting \" $(provider) \" ; valid settings include [\" fftw \" , \" mkl \" ], defaulting to \" fftw \" " )
22
+ if provider ∉ valid_fftw_providers
23
+ @error (" Invalid provider setting \" $(provider) \" ; valid settings include [$( join ( map (x -> ' " ' * x * ' " ' , valid_fftw_providers), " , " )) ] " )
15
24
provider = default_provider
16
25
end
17
26
return provider
@@ -34,8 +43,8 @@ Also supports `Preferences` sentinel values `nothing` and `missing`; see the doc
34
43
`Preferences.set_preferences!()` for more information on what these values mean.
35
44
"""
36
45
function set_provider! (provider; export_prefs:: Bool = false )
37
- if provider != = nothing && provider != = missing && provider ∉ ( " fftw " , " mkl " )
38
- throw (ArgumentError (" Invalid provider value ' $(provider) ' " ))
46
+ if provider != = nothing && provider != = missing && provider ∉ valid_fftw_providers
47
+ throw (ArgumentError (" Invalid provider value \" $(provider) \" ; valid settings include [ $( join ( map (x -> ' " ' * x * ' " ' , valid_fftw_providers), " , " )) ] " ))
39
48
end
40
49
set_preferences! (@__MODULE__ , " provider" => provider; export_prefs, force = true )
41
50
if provider != fftw_provider
47
56
48
57
# If we're using fftw_jll, load it in
49
58
@static if fftw_provider == " fftw"
50
- import FFTW_jll
51
59
libfftw3[] = FFTW_jll. libfftw3_path
52
60
libfftw3f[] = FFTW_jll. libfftw3f_path
53
61
82
90
83
91
# If we're using MKL, load it in and set library paths appropriately.
84
92
@static if fftw_provider == " mkl"
85
- import MKL_jll
86
93
libfftw3[] = MKL_jll. libmkl_rt_path
87
94
libfftw3f[] = MKL_jll. libmkl_rt_path
88
95
const _last_num_threads = Ref (Cint (1 ))
0 commit comments