Skip to content

Commit

Permalink
dont force unroll loop in reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Sep 13, 2018
1 parent 81dd6ca commit 79b7283
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ end

@generated function _mapreduce(f, op, dims::Colon, nt::NamedTuple{()},
::Size{S}, a::StaticArray...) where {S}
tmp = [:(a[$j][1]) for j 1:length(a)]
expr = :(f($(tmp...)))
for i 2:prod(S)
tmp = [:(a[$j][$i]) for j 1:length(a)]
expr = :(op($expr, f($(tmp...))))
end
tmp = [:(a[$j][i]) for j 1:length(a)]
return quote
@_inline_meta
@inbounds return $expr
i = 1
@inbounds s = f($(tmp...))
@inbounds @simd for i = 2:$(prod(S))
s = op(s, f($(tmp...)))
end
return s
end
end

@generated function _mapreduce(f, op, dims::Colon, nt::NamedTuple{(:init,)},
::Size{S}, a::StaticArray...) where {S}
expr = :(nt.init)
Expand Down

0 comments on commit 79b7283

Please sign in to comment.