Open WhiteBlackGoose opened 2 years ago
Those two have similar formulas:
(e^x + e^-x) / 2
(e^x - e^-x) / 2
So we can have Sinh/Cosh method
Speaking of implementation, we have
var ex = Simd.Exp(x);
var exm = Simd.Reciprocal(ex);
var multiplier = Simd.Create(0.5);
var sinh = Simd.Multiply(Simd.Subtract(ex, exm), multiplier);
var cosh = Simd.Multiply(Simd.Add(ex, exm), multiplier);
return (sinh, cosh);
var compared = LessThan(left, right);
var antiCompared = GreaterThanOrEqual(left, right);
var withOnes = And(compared, Vector.Create(1));
var antiWithOnes = And(compared, Vector.Create(1));
var res = Or(Multiply(withOnes, left), Multiply(antiWithOnes, right));
IsPositiveInfinity
and IsNegativeInfinity
can be verified on exact equality (for ints it returns zero) (though Tanner mentions some exception)IsFinite
is &
and equality: source (for ints it returns all bits set)IsInfinity
is trivial too (for ints it returns zero)NaN
can be checked with inequality to itselfIsNegative
/IsPositive
should probably be Compare Less/Greater against 0? Or sourceIsNormal
just follows sourceShould verify that for Store (and other void returning methods) the nested method trick actually works.
Future: Look at checking for IsHardwareAccelerated before calling down into other methods, don't want to ie call Not(LessThen(...)) if it's not hardware accelerated, because it means two loops with non-hardware accelerated Loads/Stores
Future: Improve IsNegative check by checking for bit instead of doing a full blown compare
Important: Notes from working group meeting
COMMUNITY-DRIVEN WORK TRACKING ISSUE
Tracks implementation of the SIMD Math Proposal.
It is being implemented in the
feature/math-simd
.Tasks
API implementation
665 (generator)
Create
Load
Add
Subtract
Multiply
Divide
Abs
And
Or
Xor
Not
AllBitsSet
IsHardwareAccelerated
670
Equal
NotEqual
GreaterThan
GreaterOrEqual
LessThan
LessThanOrEqual
Min
Max
684
IsFinite
IsInfinity
IsNaN
IsNegative
IsNegativeInfinity
IsNormal
IsPositiveInfinity
Sign
Arithmetics
Negate
Special
As
IEEERemainder
Trigonometry
Acos
Acosh
Asin
Asinh
Atan2
Atan
Atanh
Cos
Cosh
Sin
Sinh
Tan
Tanh
Powers
Exp
Cbrt
Sqrt
Pow
Log10
Log
Log
of two argsReciprocal
Rounding
Floor
Ceiling
Round
Round
of two argsTruncate
Bit operations
ShiftLeft
ShiftRight
RotateLeft
RotateRight
Tests
For all bitnesses x for all types
670
Less
/Greater
Than
(OrEqual
)Min
,Max
Not
)Equal
684
Other
Create
,Load
,Store
Benchmarks
For all bitnesses x for all types
670
Less
/Greater
Than
(OrEqual
)Min
,Max
Not
)Equal
684
Abs
Other
Create
,Load
,Store
TODOs
670
684
Other
Divide
for integers to be done in a more efficient way linkMultiply
for bytes to be done in a more efficient way linkstruct
where possiblelong
andulong
Far TODOs
To discuss
678
AllBitsSet
API for Scalar690
Other
MaxValueOver2
API for Simd and ScalarIsHardwareAccelerated
should be&& IsSupported
? OtherwiseSimd128<MyAwesomeType>.IsHardwareAccelerated
returns true on net5 on avx machineMath.Abs
throws onMath.Abs(int.MinValue)
. We can keep it, or we can have a faster version without this checkCopySign
API