Skip to content

Commit

Permalink
inline inner loop functions and add abs2 as a simdable function
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Jun 13, 2018
1 parent bff1c48 commit c0e785c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ struct SIMDableFunction{f}; end
(::SIMDableFunction{f})(args...) where {f} = f(args...)
simdable(f::Union{map(typeof, (+, *, &, |, add_sum, mul_prod, -, /, ^, identity))...}) = SIMDableFunction{f}()
simdable(f) = f
function _mapreduce_impl_loop(f::SIMDableFunction, op::SIMDableFunction, A::Array, ifirst, ilast)
@inline function _mapreduce_impl_loop(f::SIMDableFunction, op::SIMDableFunction, A::Array, ifirst, ilast)
@inbounds a1 = A[ifirst]
@inbounds a2 = A[ifirst+1]
v = op(f(a1), f(a2))
Expand All @@ -212,7 +212,7 @@ function _mapreduce_impl_loop(f::SIMDableFunction, op::SIMDableFunction, A::Arra
end
return v
end
function _mapreduce_impl_loop(f, op, A, ifirst, ilast)
@inline function _mapreduce_impl_loop(f, op, A, ifirst, ilast)
@inbounds a1 = A[ifirst]
@inbounds a2 = A[ifirst+1]
v = op(f(a1), f(a2))
Expand Down
2 changes: 1 addition & 1 deletion base/reducedim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ end

# The innermost loops are split out to allow for @simd in known safe cases
# add a few more simd-safe functions that were not available earlier in bootstrap
simdable(f::Union{map(typeof, (abs, sqrt, log, log10, log2))...}) = SIMDableFunction{f}()
simdable(f::Union{map(typeof, (abs, abs2, sqrt, log, log10, log2))...}) = SIMDableFunction{f}()
@inline function _mapreducedim_loop1!(f, op, R, A, IR, IA, i1)
@inbounds begin
r = R[i1,IR]
Expand Down

0 comments on commit c0e785c

Please sign in to comment.