Skip to content

Commit

Permalink
Allow constructing plans from existent PencilArrays (#29)
Browse files Browse the repository at this point in the history
* Define alternative PencilFFTPlan constructor

This new constructor takes an existing PencilArray.

* Cleanup

* Fix NoTransform

* Define ndims(::GlobalFFTParams)

* Fix in-place example

Inference of input data type was incorrect, since it only used the first
transform.

* Update examples/Manifest.toml

* Define topology and extra_dims for PencilFFTPlan

* Rename pencil creation function

* Test new constructor

* Add alternative Transforms.R2R constructor

* Update PencilFFTPlan constructor docs

* Bump version and prepare for PencilArrays 0.6
  • Loading branch information
jipolanco authored Dec 2, 2020
1 parent f5eeb36 commit 900da81
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 133 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PencilFFTs"
uuid = "4a48f351-57a6-4416-9ec4-c37015456aae"
authors = ["Juan Ignacio Polanco <jipolanc@gmail.com>"]
version = "0.10.1"
version = "0.11.0"

[deps]
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
Expand All @@ -14,7 +14,7 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
[compat]
FFTW = "1"
MPI = "0.16"
PencilArrays = "0.4, 0.5"
PencilArrays = "0.4, 0.5, 0.6"
Reexport = "0.2"
TimerOutputs = "0.5"
julia = "1.3"
9 changes: 5 additions & 4 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ version = "2.3.0"

[[ArrayInterface]]
deps = ["LinearAlgebra", "Requires", "SparseArrays"]
git-tree-sha1 = "529653153dcc9afdb97c9a3a913d6d02d93829d1"
git-tree-sha1 = "c121e78a689da38e4199cf964962385a4810d827"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "2.14.1"
version = "2.14.2"

[[Artifacts]]
deps = ["Pkg"]
Expand Down Expand Up @@ -99,6 +99,7 @@ uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.5.1"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
Expand Down Expand Up @@ -170,10 +171,10 @@ version = "0.5.0"
deps = ["FFTW", "LinearAlgebra", "MPI", "PencilArrays", "Reexport", "TimerOutputs"]
path = ".."
uuid = "4a48f351-57a6-4416-9ec4-c37015456aae"
version = "0.10.0"
version = "0.10.1"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
Expand Down
4 changes: 2 additions & 2 deletions docs/src/examples/in-place.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ transform = Transforms.FFT!()
# One can also combine different types of in-place transforms.
# For instance:
# transform = (
# Transforms.R2R!{FFTW.REDFT01}(),
# Transforms.R2R!(FFTW.REDFT01),
# Transforms.FFT!(),
# Transforms.R2R!{FFTW.DHT}(),
# Transforms.R2R!(FFTW.DHT),
# )

comm = MPI.COMM_WORLD
Expand Down
9 changes: 5 additions & 4 deletions examples/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ version = "2.3.0"

[[ArrayInterface]]
deps = ["LinearAlgebra", "Requires", "SparseArrays"]
git-tree-sha1 = "529653153dcc9afdb97c9a3a913d6d02d93829d1"
git-tree-sha1 = "c121e78a689da38e4199cf964962385a4810d827"
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
version = "2.14.1"
version = "2.14.2"

[[Artifacts]]
deps = ["Pkg"]
Expand Down Expand Up @@ -93,6 +93,7 @@ uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.5.1"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
Expand Down Expand Up @@ -164,10 +165,10 @@ version = "0.5.0"
deps = ["FFTW", "LinearAlgebra", "MPI", "PencilArrays", "Reexport", "TimerOutputs"]
path = ".."
uuid = "4a48f351-57a6-4416-9ec4-c37015456aae"
version = "0.10.0"
version = "0.10.1"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[[Printf]]
Expand Down
4 changes: 2 additions & 2 deletions examples/in-place.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ dims = INPUT_DIMS

# Combine r2r and c2c in-place transforms.
transforms = (
Transforms.R2R!{FFTW.REDFT01}(),
Transforms.R2R!(FFTW.REDFT01),
Transforms.FFT!(),
Transforms.R2R!{FFTW.DHT}(),
Transforms.R2R!(FFTW.DHT),
)

# MPI topology information
Expand Down
2 changes: 1 addition & 1 deletion src/PencilFFTs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export allocate_input, allocate_output, scale_factor
@deprecate get_scale_factor scale_factor

# Functions to be extended for PencilFFTs types.
import PencilArrays: get_comm, timer
import PencilArrays: get_comm, timer, topology, extra_dims

const AbstractTransformList{N} = NTuple{N, AbstractTransform} where N

Expand Down
8 changes: 4 additions & 4 deletions src/Transforms/Transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ false
julia> is_inplace(Transforms.NoTransform!())
true
julia> is_inplace(Transforms.FFT!(), Transforms.R2R!{FFTW.REDFT01}())
julia> is_inplace(Transforms.FFT!(), Transforms.R2R!(FFTW.REDFT01))
true
julia> is_inplace(Transforms.FFT(), Transforms.R2R{FFTW.REDFT01}())
julia> is_inplace(Transforms.FFT(), Transforms.R2R(FFTW.REDFT01))
false
julia> is_inplace(Transforms.FFT(), Transforms.R2R!{FFTW.REDFT01}()) === nothing
julia> is_inplace(Transforms.FFT(), Transforms.R2R!(FFTW.REDFT01)) === nothing
true
```
Expand Down Expand Up @@ -223,7 +223,7 @@ Complex{Float32}
julia> eltype_input(Transforms.RFFT(), Float64)
Float64
julia> eltype_input(Transforms.R2R{FFTW.REDFT01}(), Float64)
julia> eltype_input(Transforms.R2R(FFTW.REDFT01), Float64)
Nothing
julia> eltype_input(Transforms.NoTransform(), Float64)
Expand Down
7 changes: 5 additions & 2 deletions src/Transforms/r2r.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const R2R_SUPPORTED_KINDS = (
)

"""
R2R{kind}()
R2R(kind)
Real-to-real transform of type `kind`.
Expand Down Expand Up @@ -48,7 +48,7 @@ struct R2R{kind} <: AbstractTransform
end

"""
R2R!{kind}()
R2R!(kind)
In-place version of [`R2R`](@ref).
Expand All @@ -61,6 +61,9 @@ struct R2R!{kind} <: AbstractTransform
end
end

@inline R2R(kind) = R2R{kind}()
@inline R2R!(kind) = R2R!{kind}()

const AnyR2R{kind} = Union{R2R{kind}, R2R!{kind}} where {kind}

is_inplace(::R2R) = false
Expand Down
2 changes: 2 additions & 0 deletions src/global_params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ struct GlobalFFTParams{T, N, inplace, F <: AbstractTransformList{N}}
end
end

Base.ndims(::Type{<:GlobalFFTParams{T,N}}) where {T,N} = N
Base.ndims(g::GlobalFFTParams) = ndims(typeof(g))
Transforms.is_inplace(g::GlobalFFTParams{T,N,I}) where {T,N,I} = I

function Base.show(io::IO, g::GlobalFFTParams)
Expand Down
2 changes: 2 additions & 0 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,5 @@ _make_pairs(::Tuple{}, ::Tuple{}) = ()
x = Transpositions.unsafe_as_array(T, buf, dims)
PencilArray(p, x)
end

_temporary_pencil_array(::Type, ::Nothing, etc...) = nothing
Loading

2 comments on commit 900da81

@jipolanco
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/25705

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.0 -m "<description of version>" 900da81658b23f9df8035c4b6a9a5ebb8e685488
git push origin v0.11.0

Please # to comment.