Skip to content

Commit

Permalink
Reduce compilation time for permutedims with high dimensional arrays (
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu authored and LilithHafner committed Feb 22, 2022
1 parent 6eadcf3 commit 945bf0e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1577,13 +1577,12 @@ for (V, PT, BT) in Any[((:N,), BitArray, BitArray), ((:T,:N), Array, StridedArra
#Creates offset, because indexing starts at 1
offset = 1 - sum(@ntuple $N d->strides_{d+1})

sumc = 0
ind = 1
@nexprs 1 d->(counts_{$N+1} = strides_{$N+1}) # a trick to set counts_($N+1)
@nloops($N, i, P,
d->(counts_d = strides_d), # PRE
d->(counts_{d+1} += strides_{d+1}), # POST
d->(sumc += i_d*strides_{d+1}), # PRE
d->(sumc -= i_d*strides_{d+1}), # POST
begin # BODY
sumc = sum(@ntuple $N d->counts_{d+1})
@inbounds P[ind] = B[sumc+offset]
ind += 1
end)
Expand Down

0 comments on commit 945bf0e

Please sign in to comment.