Skip to content

Commit 237a571

Browse files
committed
Revert "use explicit simd for iszero check on partials (#559)"
This reverts commit 5bb4546.
1 parent b7d1de7 commit 237a571

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

src/ForwardDiff.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ if VERSION >= v"1.6"
88
end
99
using Random
1010
using LinearAlgebra
11-
import SIMD: Vec
1211

1312
import Printf
1413
import NaNMath

src/partials.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,6 @@ end
141141
@inline _mul_partials(a::Partials{0,A}, b::Partials{N,B}, afactor, bfactor) where {N,A,B} = bfactor * b
142142
@inline _mul_partials(a::Partials{N,A}, b::Partials{0,B}, afactor, bfactor) where {N,A,B} = afactor * a
143143

144-
const SIMDFloat = Union{Float64, Float32}
145-
const SIMDInt = Union{
146-
Int128, Int64, Int32, Int16, Int8,
147-
UInt128, UInt64, UInt32, UInt16, UInt8,
148-
}
149-
const SIMDType = Union{SIMDFloat, SIMDInt}
150-
151144
##################################
152145
# Generated Functions on NTuples #
153146
##################################
@@ -171,7 +164,6 @@ end
171164
@inline rand_tuple(::AbstractRNG, ::Type{Tuple{}}) = tuple()
172165
@inline rand_tuple(::Type{Tuple{}}) = tuple()
173166

174-
iszero_tuple(tup::NTuple{N,V}) where {N, V<:SIMDType} = sum(Vec(tup) != zero(V)) == 0
175167
@generated function iszero_tuple(tup::NTuple{N,V}) where {N,V}
176168
ex = Expr(:&&, [:(z == tup[$i]) for i=1:N]...)
177169
return quote
@@ -213,14 +205,15 @@ const SIMDInt = Union{
213205
}
214206
const SIMDType = Union{SIMDFloat, SIMDInt}
215207
const NT{N,T} = NTuple{N,T}
208+
using SIMD
216209

217210
# SIMD implementation
218-
@inline add_tuples(a::NT{N,T}, b::NT{N,T}) where {N, T<:SIMDType} = Tuple(Vec(a) + Vec(b))
219-
@inline sub_tuples(a::NT{N,T}, b::NT{N,T}) where {N, T<:SIMDType} = Tuple(Vec(a) - Vec(b))
220-
@inline scale_tuple(tup::NT{N,T}, x::T) where {N, T<:SIMDType} = Tuple(Vec(tup) * x)
221-
@inline div_tuple_by_scalar(tup::NT{N,T}, x::T) where {N, T<:SIMDFloat} = Tuple(Vec(tup) / x)
222-
@inline minus_tuple(tup::NT{N,T}) where {N, T<:SIMDType} = Tuple(-Vec(tup))
223-
@inline mul_tuples(a::NT{N,T}, b::NT{N,T}, af::T, bf::T) where {N, T<:SIMDType} = Tuple(muladd(af, Vec(a), bf * Vec(b)))
211+
add_tuples(a::NT{N,T}, b::NT{N,T}) where {N, T<:SIMDType} = Tuple(Vec(a) + Vec(b))
212+
sub_tuples(a::NT{N,T}, b::NT{N,T}) where {N, T<:SIMDType} = Tuple(Vec(a) - Vec(b))
213+
scale_tuple(tup::NT{N,T}, x::T) where {N, T<:SIMDType} = Tuple(Vec(tup) * x)
214+
div_tuple_by_scalar(tup::NT{N,T}, x::T) where {N, T<:SIMDFloat} = Tuple(Vec(tup) / x)
215+
minus_tuple(tup::NT{N,T}) where {N, T<:SIMDType} = Tuple(-Vec(tup))
216+
mul_tuples(a::NT{N,T}, b::NT{N,T}, af::T, bf::T) where {N, T<:SIMDType} = Tuple(muladd(Vec{N,T}(af), Vec(a), Vec{N,T}(bf) * Vec(b)))
224217

225218

226219
# Fallback implementations
@@ -229,7 +222,7 @@ const NT{N,T} = NTuple{N,T}
229222
@generated scale_tuple(tup::NT{N}, x) where N = tupexpr(i -> :(tup[$i] * x), N)
230223
@generated div_tuple_by_scalar(tup::NT{N}, x) where N = tupexpr(i -> :(tup[$i] / x), N)
231224
@generated minus_tuple(tup::NT{N}) where N = tupexpr(i -> :(-tup[$i]), N)
232-
@generated mul_tuples(a::NT{N}, b::NT{N}, af, bf) where N = tupexpr(i -> :(muladd(af, a[$i], bf * b[$i])), N)
225+
@generated mul_tuples(a::NT{N}, b::NT{N}, af, bf) where N = tupexpr(i -> :((af * a[$i]) + (bf * b[$i])), N)
233226

234227
###################
235228
# Pretty Printing #

0 commit comments

Comments
 (0)