From 03005bace5816d40af3fe98123b63d804782e4df Mon Sep 17 00:00:00 2001 From: wheeheee <104880306+wheeheee@users.noreply.github.com> Date: Tue, 3 Feb 2026 14:21:57 +0800 Subject: [PATCH 1/4] change iteration order generally more performant to iterate from left to right since Julia is column-major --- src/plan.jl | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/plan.jl b/src/plan.jl index efa8333..2193934 100644 --- a/src/plan.jl +++ b/src/plan.jl @@ -145,10 +145,8 @@ function LinearAlgebra.mul!(y::AbstractArray{U,N}, p::FFTAPlan_cx{T,1}, x::Abstr end Rpre = CartesianIndices(size(x)[1:p.region[]-1]) Rpost = CartesianIndices(size(x)[p.region[]+1:end]) - for Ipre in Rpre - for Ipost in Rpost - @views fft!(y[Ipre,:,Ipost], x[Ipre,:,Ipost], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1) - end + for Ipost in Rpost, Ipre in Rpre + @views fft!(y[Ipre,:,Ipost], x[Ipre,:,Ipost], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1) end end @@ -186,17 +184,13 @@ function _mul_loop( rows::Int, cols::Int ) - for I1 in R1 - for I2 in R2 - for I3 in R3 - for k in 1:cols - @views fft!(y_tmp[:,k], x[I1,:,I2,k,I3], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1) - end + for I3 in R3, I2 in R2, I1 in R1 + for k in 1:cols + @views fft!(y_tmp[:,k], x[I1,:,I2,k,I3], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1) + end - for k in 1:rows - @views fft!(y[I1,k,I2,:,I3], y_tmp[k,:], 1, 1, p.dir, p.callgraph[2][1].type, p.callgraph[2], 1) - end - end + for k in 1:rows + @views fft!(y[I1,k,I2,:,I3], y_tmp[k,:], 1, 1, p.dir, p.callgraph[2][1].type, p.callgraph[2], 1) end end end From fa3aa9006a32f3d2a75545d373702a8d3baa8452 Mon Sep 17 00:00:00 2001 From: wheeheee <104880306+wheeheee@users.noreply.github.com> Date: Wed, 4 Feb 2026 00:45:20 +0800 Subject: [PATCH 2/4] another `_mul_loop!` for function barrier --- src/plan.jl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plan.jl b/src/plan.jl index 2193934..8a72045 100644 --- a/src/plan.jl +++ b/src/plan.jl @@ -145,6 +145,15 @@ function LinearAlgebra.mul!(y::AbstractArray{U,N}, p::FFTAPlan_cx{T,1}, x::Abstr end Rpre = CartesianIndices(size(x)[1:p.region[]-1]) Rpost = CartesianIndices(size(x)[p.region[]+1:end]) + _mul_loop!(y, x, Rpre, Rpost, p) +end + +function _mul_loop!( + y::AbstractArray{U,N}, + x::AbstractArray{T,N}, + Rpre::CartesianIndices, + Rpost::CartesianIndices, + p::FFTAPlan_cx{T,1}) where {T,U,N} for Ipost in Rpost, Ipre in Rpre @views fft!(y[Ipre,:,Ipost], x[Ipre,:,Ipost], 1, 1, p.dir, p.callgraph[1][1].type, p.callgraph[1], 1) end @@ -170,10 +179,10 @@ function LinearAlgebra.mul!(y::AbstractArray{U,N}, p::FFTAPlan_cx{T,2}, x::Abstr # Introduce function barrier here since the variables used in the loop ranges aren't inferred. This # is partly because the region field of the plan is abstractly typed but even if that wasn't the case, # it might be a bit tricky to construct the Rxs in an inferred way. - _mul_loop(y_tmp, y, x, p, R1, R2, R3, rows, cols) + _mul_loop!(y_tmp, y, x, p, R1, R2, R3, rows, cols) end -function _mul_loop( +function _mul_loop!( y_tmp::AbstractArray, y::AbstractArray, x::AbstractArray, From e9410afa7f70c26f0675ffee1e9d2f063c1a804b Mon Sep 17 00:00:00 2001 From: wheeheee <104880306+wheeheee@users.noreply.github.com> Date: Wed, 4 Feb 2026 00:45:41 +0800 Subject: [PATCH 3/4] add some common files to .gitignore --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0708ed4..d32b7cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -/Manifest.toml -docs/build \ No newline at end of file +Manifest.toml +Manifest-v1*.toml +docs/build +settings.json \ No newline at end of file From de3eb54c65c5b97dd9288f64162adb40c2a2d67f Mon Sep 17 00:00:00 2001 From: wheeheee <104880306+wheeheee@users.noreply.github.com> Date: Wed, 4 Feb 2026 09:14:04 +0800 Subject: [PATCH 4/4] Revert "add some common files to .gitignore" This reverts commit e9410afa7f70c26f0675ffee1e9d2f063c1a804b. --- .gitignore | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d32b7cf..0708ed4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ -Manifest.toml -Manifest-v1*.toml -docs/build -settings.json \ No newline at end of file +/Manifest.toml +docs/build \ No newline at end of file