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
110
211function get_provider ()
312 # Note: we CANNOT do something like have the `default` value be `get(ENV, "JULIA_FFTW_PROVIDER", "fftw")` here.
413 # This is because the only way the Julia knows that a default has changed is if the values on-disk change; so
514 # if your "default" value can be changed from the outside, you quickly run into cache invalidation issues.
615 # So the default here _must_ be a constant.
7- default_provider = " fftw "
16+ default_provider = first (valid_fftw_providers)
817
918 # Load the preference
1019 provider = @load_preference (" provider" , default_provider)
1120
1221 # 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), " , " )) ] " )
1524 provider = default_provider
1625 end
1726 return provider
@@ -34,8 +43,8 @@ Also supports `Preferences` sentinel values `nothing` and `missing`; see the doc
3443`Preferences.set_preferences!()` for more information on what these values mean.
3544"""
3645function 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), " , " )) ] " ))
3948 end
4049 set_preferences! (@__MODULE__ , " provider" => provider; export_prefs, force = true )
4150 if provider != fftw_provider
4756
4857# If we're using fftw_jll, load it in
4958@static if fftw_provider == " fftw"
50- import FFTW_jll
5159 libfftw3[] = FFTW_jll. libfftw3_path
5260 libfftw3f[] = FFTW_jll. libfftw3f_path
5361
8290
8391# If we're using MKL, load it in and set library paths appropriately.
8492@static if fftw_provider == " mkl"
85- import MKL_jll
8693 libfftw3[] = MKL_jll. libmkl_rt_path
8794 libfftw3f[] = MKL_jll. libmkl_rt_path
8895 const _last_num_threads = Ref (Cint (1 ))
0 commit comments