Skip to content

Commit

Permalink
Use an environment variable to request MKL
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Oct 1, 2017
1 parent 084713c commit 37ba16e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ deps/src
deps/builds
docs/build
docs/site
.build_settings
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ This package provides Julia bindings to the [FFTW](http://www.fftw.org/) library
fast Fourier transforms, as well as functionality useful for signal processing.
These functions were formerly a part of Base Julia.

Users with a build of Julia based on Intel's Math Kernel Library (MKL) can take use MKL
for FFTs by setting an environment variable `JULIA_FFTW_PROVIDER` to `MKL` and running
`Pkg.build("FFTW")`.
Setting this environment variable only needs to be done for the first build of the package;
after that, the package will remember to use MKL when building and updating.
Note however that MKL provides only a subset of the functionality provided by FFTW. See
Intel's [documentation](https://software.intel.com/en-us/mkl-developer-reference-c-using-fftw3-wrappers)
for more information about potential differences or gaps in functionality.

The FFTW library will be downloaded on versions of Julia where it is no longer distributed
as part of Julia.
Note that FFTW is licensed under GPLv2 or higher (see
Expand Down
17 changes: 13 additions & 4 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# If BLAS was compiled with MKL, we want to use MKL for FFTs as well. Thus
# we have to do this little dance to get around having to use BinDeps for
# a library that's already linked to Julia.
if Base.BLAS.vendor() === :mkl
# If BLAS was compiled with MKL and the user wants MKL-based FFTs, we'll oblige.
# In that case, we have to do this little dance to get around having to use BinDeps
# for a library that's already linked to Julia.
settings = joinpath(@__DIR__, "..", ".build_settings")
if isfile(settings)
provider = readchomp(settings)
elseif haskey(ENV, "JULIA_FFTW_PROVIDER")
provider = ENV["JULIA_FFTW_PROVIDER"]
open(f -> println(f, provider), settings, "w")
else
provider = ""
end
if provider == "MKL" && Base.BLAS.vendor() === :mkl
mklpath = Libdl.dlpath("libmkl_rt")
depsfile = joinpath(@__DIR__, "deps.jl")
isfile(depsfile) && rm(depsfile, force=true)
Expand Down
9 changes: 9 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Pkg.add("FFTW")

from the Julia REPL.

Users with a build of Julia based on Intel's Math Kernel Library (MKL) can take use MKL
for FFTs by setting an environment variable `JULIA_FFTW_PROVIDER` to `MKL` and running
`Pkg.build("FFTW")`.
Setting this environment variable only needs to be done for the first build of the package;
after that, the package will remember to use MKL when building and updating.
Note however that MKL provides only a subset of the functionality provided by FFTW. See
Intel's [documentation](https://software.intel.com/en-us/mkl-developer-reference-c-using-fftw3-wrappers)
for more information about potential differences or gaps in functionality.

## Note

These functions were formerly part of Base Julia.
Expand Down

0 comments on commit 37ba16e

Please sign in to comment.