From 10e776ce49a78e6507e422e2318735201666dadf Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Sun, 1 Oct 2017 13:58:24 -0700 Subject: [PATCH 1/2] Use an environment variable to request MKL --- .gitignore | 1 + README.md | 9 +++++++++ deps/build.jl | 22 ++++++++++++++++++---- docs/src/index.md | 9 +++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 88ee7eb..e1c2166 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ deps/src deps/builds docs/build docs/site +.build_settings diff --git a/README.md b/README.md index 213ec51..c5157f5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/deps/build.jl b/deps/build.jl index 838d1ff..1efb5ad 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -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) @@ -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 diff --git a/docs/src/index.md b/docs/src/index.md index b99fb32..31d7458 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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. From 9a52ccc1084161bf1afccc9409f45f799fdd7325 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 3 Oct 2017 12:16:00 -0700 Subject: [PATCH 2/2] Fix use of Base.Test for recent move to stdlib --- test/runtests.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 978caac..2874b11 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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)