Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use an environment variable to request MKL #44

Merged
merged 2 commits into from
Oct 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 18 additions & 4 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
# 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 haskey(ENV, "JULIA_FFTW_PROVIDER")
provider = ENV["JULIA_FFTW_PROVIDER"]
open(f -> println(f, provider), settings, "w")
elseif isfile(settings)
provider = readchomp(settings)
else
provider = "FFTW"
open(f -> println(f, provider), settings, "w")
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 All @@ -16,6 +26,10 @@ if Base.BLAS.vendor() === :mkl
const libfftwf = "$mklpath"
""")
end
elseif provider == "MKL"
error("MKL build requested for FFTW but Julia was not built with MKL.\n",
"To fix this, set ENV[\"JULIA_FFTW_PROVIDER\"] = \"FFTW\" and \n",
"rerun Pkg.build(\"FFTW\").")
else
include("build_fftw.jl")
end
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
7 changes: 6 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
using FFTW
using FFTW: fftw_vendor
using AbstractFFTs: Plan, plan_inv
using Base.Test

if isdefined(Base, :Test) && !Base.isdeprecated(Base, :Test)
using Base.Test
else
using Test
end

# Base Julia issue #19892
# (test this first to make sure it happens before set_num_threads)
Expand Down