Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/ForwardDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import SpecialFunctions
import LogExpFunctions
import CommonSubexpressions

const SIMDFloat = Union{Float64, Float32}
const SIMDInt = Union{
Int128, Int64, Int32, Int16, Int8,
UInt128, UInt64, UInt32, UInt16, UInt8,
}
const SIMDType = Union{SIMDFloat, SIMDInt}

include("prelude.jl")
include("partials.jl")
include("dual.jl")
Expand Down
20 changes: 20 additions & 0 deletions src/dual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ end
# fma #
#-----#

@inline function calc_fma_xyz(x::Dual{T,V,N},
y::Dual{T,V,N},
z::Dual{T,V,N}) where {T, V<:SIMDFloat,N}
xv, yv, zv = value(x), value(y), value(z)
rv = fma(xv, yv, zv)
N == 0 && return Dual{T}(rv)
xp, yp, zp = Vec(partials(x).values), Vec(partials(y).values), Vec(partials(z).values)
parts = Tuple(fma(xv, yp, fma(yv, xp, zp)))
Dual{T}(rv, parts)
end
@generated function calc_fma_xyz(x::Dual{T,<:Any,N},
y::Dual{T,<:Any,N},
z::Dual{T,<:Any,N}) where {T,N}
Expand Down Expand Up @@ -583,6 +593,16 @@ end
# muladd #
#--------#

@inline function calc_muladd_xyz(x::Dual{T,V,N},
y::Dual{T,V,N},
z::Dual{T,V,N}) where {T, V<:SIMDType,N}
xv, yv, zv = value(x), value(y), value(z)
rv = muladd(xv, yv, zv)
N == 0 && return Dual{T}(rv)
xp, yp, zp = Vec(partials(x).values), Vec(partials(y).values), Vec(partials(z).values)
parts = Tuple(muladd(xv, yp, muladd(yv, xp, zp)))
Dual{T}(rv, parts)
end
@generated function calc_muladd_xyz(x::Dual{T,<:Any,N},
y::Dual{T,<:Any,N},
z::Dual{T,<:Any,N}) where {T,N}
Expand Down
7 changes: 0 additions & 7 deletions src/partials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,6 @@ end
return tupexpr(i -> :(rand(V)), N)
end


const SIMDFloat = Union{Float64, Float32}
const SIMDInt = Union{
Int128, Int64, Int32, Int16, Int8,
UInt128, UInt64, UInt32, UInt16, UInt8,
}
const SIMDType = Union{SIMDFloat, SIMDInt}
const NT{N,T} = NTuple{N,T}

# SIMD implementation
Expand Down