-
Notifications
You must be signed in to change notification settings - Fork 42
support MKL FFT backend #411
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
base: master
Are you sure you want to change the base?
Changes from all commits
4b98087
eb6f192
b01f715
ce5dce1
90e6960
ac155db
fd2cf2d
c128144
421a3c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ _git2_* | |
| docs/build | ||
| *.info | ||
| .vscode/spellright.dict | ||
| LocalPreferences.toml | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,62 @@ | ||||||
| # Installation | ||||||
|
|
||||||
| ## Requirements | ||||||
| Luna requires Julia v1.9 or later (we currently recommend v1.10). You can download Julia from the [official website](https://julialang.org/downloads/). | ||||||
|
|
||||||
| ## Installing Luna | ||||||
| To install Luna, open a Julia terminal and enter the package manager by pressing `]`, then run: | ||||||
| ```julia | ||||||
| pkg> add Luna | ||||||
| ``` | ||||||
| This will download and install Luna along with all of its dependencies. The first time you load Luna with `using Luna`, it will be precompiled, which may take a few minutes. | ||||||
|
|
||||||
| ### Development version | ||||||
| If you want to use the latest development version of Luna (or contribute to it), you can install it directly from the GitHub repository: | ||||||
| ```julia | ||||||
| pkg> dev Luna | ||||||
| ``` | ||||||
| or, equivalently: | ||||||
| ```julia | ||||||
| pkg> add Luna#master | ||||||
|
||||||
| pkg> add Luna#master | |
| pkg> add Luna#main |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -552,20 +552,59 @@ end | |
|
|
||
| wigner(t, A::Vector{<:Real}; kwargs...) = wigner(t, hilbert(A); kwargs...) | ||
|
|
||
| # MKL's FFTW compatibility layer cannot create partial-dimension FFT plans for 3D+ arrays. | ||
| # For dim=1, we reshape to 2D (zero-copy), apply the FFT, and reshape back. | ||
| # For other dims, we fall back to mapslices with 1D transforms. | ||
|
Comment on lines
+555
to
+557
|
||
| function _fft_dim(x::AbstractArray, dim::Integer) | ||
| ndims(x) <= 2 && return FFTW.fft(x, dim) | ||
| if dim == 1 | ||
| sz = size(x) | ||
| return reshape(FFTW.fft(reshape(x, sz[1], :), 1), :, sz[2:end]...) | ||
| end | ||
| return mapslices(s -> FFTW.fft(vec(s)), x; dims=dim) | ||
| end | ||
|
Comment on lines
+558
to
+565
|
||
|
|
||
| function _ifft_dim(x::AbstractArray, dim::Integer) | ||
| ndims(x) <= 2 && return FFTW.ifft(x, dim) | ||
| if dim == 1 | ||
| sz = size(x) | ||
| return reshape(FFTW.ifft(reshape(x, sz[1], :), 1), :, sz[2:end]...) | ||
| end | ||
| return mapslices(s -> FFTW.ifft(vec(s)), x; dims=dim) | ||
| end | ||
|
|
||
| function _rfft_dim(x::AbstractArray, dim::Integer) | ||
| ndims(x) <= 2 && return FFTW.rfft(x, dim) | ||
| if dim == 1 | ||
| sz = size(x) | ||
| return reshape(FFTW.rfft(reshape(x, sz[1], :), 1), :, sz[2:end]...) | ||
| end | ||
| return mapslices(s -> FFTW.rfft(vec(s)), x; dims=dim) | ||
| end | ||
|
|
||
| function _irfft_dim(x::AbstractArray, d::Integer, dim::Integer) | ||
| ndims(x) <= 2 && return FFTW.irfft(x, d, dim) | ||
| if dim == 1 | ||
| sz = size(x) | ||
| return reshape(FFTW.irfft(reshape(x, sz[1], :), d, 1), d, sz[2:end]...) | ||
| end | ||
| return mapslices(s -> FFTW.irfft(vec(s), d), x; dims=dim) | ||
| end | ||
|
|
||
| """ | ||
| hilbert(x; dim=1) | ||
|
|
||
| Compute the Hilbert transform, i.e. find the analytic signal from a real signal. | ||
| """ | ||
| function hilbert(x::Array{T,N}; dim = 1) where T <: Real where N | ||
| xf = FFTW.fft(x, dim) | ||
| xf = _fft_dim(x, dim) | ||
| n1 = size(xf, dim)÷2 | ||
| n2 = size(xf, dim) | ||
| idxlo = CartesianIndices(size(xf)[1:dim - 1]) | ||
| idxhi = CartesianIndices(size(xf)[dim + 1:end]) | ||
| xf[idxlo, 2:n1, idxhi] .*= 2 | ||
| xf[idxlo, (n1+1):n2, idxhi] .= 0 | ||
| return FFTW.ifft(xf, dim) | ||
| return _ifft_dim(xf, dim) | ||
| end | ||
|
|
||
| """ | ||
|
|
@@ -627,7 +666,7 @@ function oversample(t, x::Array{<:Real, N}; factor::Int=4, dim=1) where N | |
| if factor == 1 | ||
| return t, x | ||
| end | ||
| xf = FFTW.rfft(x, dim) | ||
| xf = _rfft_dim(x, dim) | ||
|
|
||
| len = size(xf, dim) | ||
| newlen_t = factor * length(t) | ||
|
|
@@ -648,14 +687,14 @@ function oversample(t, x::Array{<:Real, N}; factor::Int=4, dim=1) where N | |
| idxlo = CartesianIndices(size(xfo)[1:dim - 1]) | ||
| idxhi = CartesianIndices(size(xfo)[dim + 1:end]) | ||
| xfo[idxlo, 1:len, idxhi] .= factor .* xf | ||
| return to, FFTW.irfft(xfo, newlen_t, dim) | ||
| return to, _irfft_dim(xfo, newlen_t, dim) | ||
| end | ||
|
|
||
| function oversample(t, x::Array{<:Complex,N}; factor::Int=4, dim=1) where N | ||
| if factor == 1 | ||
| return t, x | ||
| end | ||
| xf = FFTW.fftshift(FFTW.fft(x, dim), dim) | ||
| xf = FFTW.fftshift(_fft_dim(x, dim), dim) | ||
|
|
||
| len = size(xf, dim) | ||
| newlen = factor * length(t) | ||
|
|
@@ -677,7 +716,7 @@ function oversample(t, x::Array{<:Complex,N}; factor::Int=4, dim=1) where N | |
| idxlo = CartesianIndices(size(xfo)[1:dim - 1]) | ||
| idxhi = CartesianIndices(size(xfo)[dim + 1:end]) | ||
| xfo[idxlo, startidx:endidx, idxhi] .= factor .* xf | ||
| return to, FFTW.ifft(FFTW.ifftshift(xfo, dim), dim) | ||
| return to, _ifft_dim(FFTW.ifftshift(xfo, dim), dim) | ||
| end | ||
|
|
||
| """ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow runs on both
pushandpull_request, but the job condition usesgithub.event.pull_request.draft. Onpushevents that context is null, so this job will be skipped (and may not behave as intended). If you want the MKL tests to run on pushes too, consider a condition likegithub.event_name != 'pull_request' || github.event.pull_request.draft == false; if you only want it on PRs, consider restricting the workflow triggers instead of relying on a PR-only context.