Skip to content

Commit 8d65144

Browse files
committed
Introduce function barrier in higher dimensional transform loop
to avoid a lot of allocations.
1 parent ac171b5 commit 8d65144

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/plan.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ function LinearAlgebra.mul!(y::AbstractArray{U,N}, p::FFTAPlan{T,2}, x::Abstract
112112
R3 = CartesianIndices(size(x)[p.region[2]+1:end])
113113
y_tmp = similar(y, axes(y)[p.region])
114114
rows,cols = size(x)[p.region]
115+
# Introduce function barrier here since the variables used in the loop ranges aren't inferred. This
116+
# is partly because the region field of the plan is abstractly typed but even if that wasn't the case,
117+
# it might be a bit tricky to construct the Rxs in an inferred way.
118+
_mul_loop(y_tmp, y, x, p, R1, R2, R3, rows, cols)
119+
end
120+
121+
function _mul_loop(
122+
y_tmp::AbstractArray,
123+
y::AbstractArray,
124+
x::AbstractArray,
125+
p::FFTAPlan,
126+
R1::CartesianIndices,
127+
R2::CartesianIndices,
128+
R3::CartesianIndices,
129+
rows::Int,
130+
cols::Int
131+
)
115132
for I1 in R1
116133
for I2 in R2
117134
for I3 in R3

0 commit comments

Comments
 (0)