Skip to content

Commit

Permalink
Split FFTW into its own package
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed May 23, 2017
1 parent ed429e1 commit 9cbf978
Show file tree
Hide file tree
Showing 15 changed files with 361 additions and 168 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
deps/deps.jl
deps/downloads
deps/usr
deps/src
docs/build
docs/site
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Documentation: http:https://docs.travis-ci.com/user/languages/julia/
language: julia
os:
- linux
- osx
julia:
- 0.6
- nightly
notifications:
email: false
# uncomment the following lines to override the default test script
#script:
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
# - julia -e 'Pkg.clone(pwd()); Pkg.build("FFTW"); Pkg.test("FFTW"; coverage=true)'
after_success:
- julia -e 'Pkg.add("Coverage"); cd(Pkg.dir("FFTW")); using Coverage; Coveralls.submit(Coveralls.process_folder())'
- julia -e 'Pkg.add("Documenter"); cd(Pkg.dir("FFTW")); include(joinpath("docs", "make.jl"))'
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2017 Steven G. Johnson, Jeff Bezanson, and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# FFTW.jl

TODO
4 changes: 4 additions & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
julia 0.6-
BinDeps
@osx Homebrew
@windows WinRPM
39 changes: 39 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

branches:
only:
- master

notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
Pkg.clone(pwd(), \"FFTW\"); Pkg.build(\"FFTW\")"

test_script:
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"FFTW\")"
74 changes: 74 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using BinDeps
using BinDeps: builddir

BinDeps.@setup

const FFTW_VER = v"3.3.6-pl1"

if is_windows()
const libfftw_name = "libfftw3"
const libfftwf_name = "libfftw3f"
else
const libfftw_name = "libfftw3_threads"
const libfftwf_name = "libfftw3f_threads"
end

libfftw = library_dependency(libfftw_name, aliases=[replace(libfftw_name, "3", "")])
libfftwf = library_dependency(libfftwf_name, aliases=[replace(libfftwf_name, "3", "")])

provides(AptGet, "libfftw3", [libfftw, libfftwf], os=:Linux)
provides(Pacman, "fftw", [libfftw, libfftwf], os=:Linux)
provides(Zypper, "libfftw3", [libfftw, libfftwf], os=:Linux)
provides(Yum, "fftw", [libfftw, libfftwf], os=:Linux)
# provides(BSDPkg, "fftw3", [libfftw, libfftwf], os=:FreeBSD)

if is_windows()
using WinRPM
provides(WinRPM.RPM, "fftw", [libfftw, libfftwf], os=:Windows)
elseif is_apple()
using Homebrew
provides(Homebrew.HB, "fftw", [libfftw, libfftwf], os=:Darwin)
end

general_config = ["--prefix=" * abspath(builddir(libfftw)),
"--libdir=" * abspath(libdir(libfftw)),
"--bindir=" * abspath(bindir(libfftw))]

try
# There might not be a cc defined or available in the path
machine = readchomp(`cc -dumpmachine`)
push!(general_config, "--build=" * machine)

This comment has been minimized.

Copy link
@tkelman

tkelman Jun 7, 2017

Contributor

why do you care about --build ? that's the system where it gets built, not the system it's building for

This comment has been minimized.

Copy link
@ararslan

ararslan Jun 7, 2017

Author Member

It was in the Base Makefile so I put it here

This comment has been minimized.

Copy link
@tkelman

tkelman Jun 8, 2017

Contributor

the base makefile allows you to override the compiler, but it isn't helping anything there either

This comment has been minimized.

Copy link
@stevengj

stevengj Jun 8, 2017

Member

Yeah, I would recommend omitting this. (The only time I've ever used --build was years ago, when compiling code on exotic Cray systems that config.guess didn't recognize correctly.)

This comment has been minimized.

Copy link
@tkelman

tkelman Jun 8, 2017

Contributor

or if you're building a project with really old autotools files on some architecture too new for them (like aarch64 or similar), but usually where you're building from doesn't matter so much as long as autotools can figure out the right way to invoke whichever toolchain you're using

This comment has been minimized.

Copy link
@tkelman

tkelman Jun 8, 2017

Contributor

looks like it was added for JuliaLang/julia#3242, 4 years ago when msys2 was also new and not recognized by most autotools scripts - this package won't be building from source there though

This comment has been minimized.

Copy link
@ararslan

ararslan Jun 8, 2017

Author Member

Should that be changed before the package is registered?

end

fftw_config = ["--enabled-shared", "--disable-fortran", "--disable-mpi", "--enable-threads"]
fftw_enable_single = "--enable-single"

if Sys.ARCH === :ppc
push!(fftw_config, "--enable-altivec")
elseif Sys.ARCH === :x86_64
append!(fftw_config, ["--enable-sse2", "--enable-fma"])
end

if is_windows()
append!(fftw_config, ["--with-our-malloc", "--with-combined-threads"])
Sys.ARCH === :x86_64 || push!(fftw_config, "--with-incoming-stack-boundary=2")
end

const MAKE = is_bsd() && !is_apple() ? `gmake` : `make`

provides(Sources, URI("http:https://www.fftw.org/fftw-$FFTW_VER.tar.gz"), [libfftw, libfftwf])

provides(BuildProcess, (@build_steps begin
GetSources(libfftw)
CreateDirectory(joinpath(builddir(libfftw), "libfftw"))
@build_steps begin
ChangeDirectory(joinpath(builddir(libfftw), "libfftw"))
FileRule(joinpath(libdir(libfftw), "libfftw." * Libdl.dlext), @build_steps begin
CreateDirectory(libdir(libfftw))
`$(joinpath(".", "configure")) $general_config $fftw_config $fftw_enable_single`
`$MAKE`
end)
end
end), libfftw)

BinDeps.@install Dict([:libfftw => :libfftw, :libfftwf => :libfftwf])
18 changes: 18 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Documenter, FFTW

makedocs(
modules = [FFTW],
clean = false,
format = :html,
sitename = "FFTW.jl",
pages = Any[
"Home" => "index.md",
],
)

deploydocs(
repo = "github.com/JuliaMath/FFTW.jl.git",
target = "build",
deps = nothing,
make = nothing,
)
32 changes: 32 additions & 0 deletions src/FFTW.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
__precompile__()

module FFTW

const depsfile = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
if isfile(depsfile)
include(depsfile)
else
error("FFTW is not properly installed. Please run Pkg.build(\"FFTW\") ",
"and restart Julia.")
end

# MKL provides its own FFTW
fftw_vendor() = Base.BLAS.vendor() === :mkl ? :mkl : :fftw

if fftw_vendor() === :mkl
const libfftw_name = "libmkl_rt"
const libfftwf_name = "libmkl_rt"
elseif is_windows()
const libfftw_name = "libfftw3"
const libfftwf_name = "libfftw3f"
else
const libfftw_name = "libfftw3_threads"
const libfftwf_name = "libfftw3f_threads"
end

include("dft.jl")
include("fft.jl")
include("dct.jl")
include("dsp.jl") # TODO: Move these functions to DSP.jl

end # module
75 changes: 74 additions & 1 deletion src/dct.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license
# This file was formerly a part of Julia. License is MIT: https://julialang.org/license

# (This is part of the FFTW module.)

export dct, idct, dct!, idct!, plan_dct, plan_idct, plan_dct!, plan_idct!

"""
plan_dct!(A [, dims [, flags [, timelimit]]])
Same as [`plan_dct`](@ref), but operates in-place on `A`.
"""
function plan_dct! end

"""
plan_idct(A [, dims [, flags [, timelimit]]])
Pre-plan an optimized inverse discrete cosine transform (DCT), similar to
[`plan_fft`](@ref) except producing a function that computes
[`idct`](@ref). The first two arguments have the same meaning as for
[`idct`](@ref).
"""
function plan_idct end

"""
plan_dct(A [, dims [, flags [, timelimit]]])
Pre-plan an optimized discrete cosine transform (DCT), similar to
[`plan_fft`](@ref) except producing a function that computes
[`dct`](@ref). The first two arguments have the same meaning as for
[`dct`](@ref).
"""
function plan_dct end

"""
plan_idct!(A [, dims [, flags [, timelimit]]])
Same as [`plan_idct`](@ref), but operates in-place on `A`.
"""
function plan_idct! end

"""
dct(A [, dims])
Performs a multidimensional type-II discrete cosine transform (DCT) of the array `A`, using
the unitary normalization of the DCT. The optional `dims` argument specifies an iterable
subset of dimensions (e.g. an integer, range, tuple, or array) to transform along. Most
efficient if the size of `A` along the transformed dimensions is a product of small primes;
see [`nextprod`](@ref). See also [`plan_dct`](@ref) for even greater
efficiency.
"""
function dct end

"""
idct(A [, dims])
Computes the multidimensional inverse discrete cosine transform (DCT) of the array `A`
(technically, a type-III DCT with the unitary normalization). The optional `dims` argument
specifies an iterable subset of dimensions (e.g. an integer, range, tuple, or array) to
transform along. Most efficient if the size of `A` along the transformed dimensions is a
product of small primes; see [`nextprod`](@ref). See also
[`plan_idct`](@ref) for even greater efficiency.
"""
function idct end

"""
dct!(A [, dims])
Same as [`dct!`](@ref), except that it operates in-place on `A`, which must be an
array of real or complex floating-point values.
"""
function dct! end

"""
idct!(A [, dims])
Same as [`idct!`](@ref), but operates in-place on `A`.
"""
function idct! end

# Discrete cosine transforms (type II/III) via FFTW's r2r transforms;
# we follow the Matlab convention and adopt a unitary normalization here.
# Unlike Matlab we compute the multidimensional transform by default,
Expand Down
Loading

0 comments on commit 9cbf978

Please sign in to comment.