Skip to content

Commit 1664691

Browse files
committed
Use muladd over fma
- `muladd` will choose the most efficient implementation See https://docs.julialang.org/en/v1/base/math/#Base.muladd
1 parent 5bd0e64 commit 1664691

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/Utils.jl

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ function is_good_array(x::AbstractArray{T}, V::Val{unroll}=Val(16)) where {unrol
8888
cumulator = mask
8989
for i in vectorized_segment
9090
batch = ntuple(j -> @inbounds(x[i + (j - 1)]), V)
91-
if T <: Real
92-
cumulator = fma.(mask, batch, cumulator)
93-
else
94-
cumulator = muladd.(mask, batch, cumulator)
95-
end
91+
cumulator = muladd.(mask, batch, cumulator)
9692
end
9793
cumulator == mask || return false
9894
end
@@ -105,11 +101,7 @@ function is_good_array(x::AbstractArray{T}, V::Val{unroll}=Val(16)) where {unrol
105101
end
106102
scalar_cumulator = _zero
107103
for i in tail_segment
108-
if T <: Real
109-
scalar_cumulator = fma(_zero, @inbounds(x[i]), scalar_cumulator)
110-
else
111-
scalar_cumulator = muladd(_zero, @inbounds(x[i]), scalar_cumulator)
112-
end
104+
scalar_cumulator = muladd(_zero, @inbounds(x[i]), scalar_cumulator)
113105
end
114106
return scalar_cumulator == _zero
115107
end

0 commit comments

Comments
 (0)