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# #################################
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 }
214206const SIMDType = Union{SIMDFloat, SIMDInt}
215207const 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