From 7ede6704e60b2cb5e478d1aea406bc3a9a0431cd Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 2 Feb 2024 08:42:55 -0500 Subject: [PATCH 1/3] Vectorize TensorPrimitives.Cosh/Sinh/Tanh for double This just replicates the float path to be used for double as well, expanding out the constants used to be more precise. --- .../netcore/TensorPrimitives.netcore.cs | 238 ++++++++++++------ 1 file changed, 168 insertions(+), 70 deletions(-) diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs index 381e5f25011e84..a9b53c884e5cfa 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs @@ -10,10 +10,6 @@ #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type -// TODO: -// - Vectorize remaining trig-related functions (some aren't vectorized at all, some are only vectorized for float). -// - Vectorize integer operations when sizeof(T) == 1 or 2 (currently only vectorized in most operations for sizeof(T) == 4 or 8). - namespace System.Numerics.Tensors { public static unsafe partial class TensorPrimitives @@ -13064,42 +13060,75 @@ public static Vector512 Invoke(Vector512 x) // // coshf = v/2 * exp(x - log(v)) where v = 0x1.0000e8p-1 - private const float LOGV = 0.693161f; - private const float HALFV = 1.0000138f; - private const float INVV2 = 0.24999309f; + private const double LOGV = 0.6931610107421875; + private const double HALFV = 1.000013828277588; + private const double INVV2 = 0.24999308586120605; - public static bool Vectorizable => typeof(T) == typeof(float); + public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); public static T Invoke(T x) => T.Cosh(x); public static Vector128 Invoke(Vector128 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector128 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector128 x = t.AsSingle(); + + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)LOGV)); + return (Vector128.Create((float)HALFV) * (z + (Vector128.Create((float)INVV2) / z))).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector128 x = t.AsDouble(); - Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); - return (Vector128.Create(HALFV) * (z + (Vector128.Create(INVV2) / z))).As(); + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); + return (Vector128.Create(HALFV) * (z + (Vector128.Create(INVV2) / z))).As(); + } } public static Vector256 Invoke(Vector256 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector256 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector256 x = t.AsSingle(); + + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)LOGV)); + return (Vector256.Create((float)HALFV) * (z + (Vector256.Create((float)INVV2) / z))).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector256 x = t.AsDouble(); - Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); - return (Vector256.Create(HALFV) * (z + (Vector256.Create(INVV2) / z))).As(); + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); + return (Vector256.Create(HALFV) * (z + (Vector256.Create(INVV2) / z))).As(); + } } public static Vector512 Invoke(Vector512 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector512 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector512 x = t.AsSingle(); + + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)LOGV)); + return (Vector512.Create((float)HALFV) * (z + (Vector512.Create((float)INVV2) / z))).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector512 x = t.AsDouble(); - Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); - return (Vector512.Create(HALFV) * (z + (Vector512.Create(INVV2) / z))).As(); + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); + return (Vector512.Create(HALFV) * (z + (Vector512.Create(INVV2) / z))).As(); + } } } @@ -13132,49 +13161,87 @@ public static Vector512 Invoke(Vector512 t) // Same as cosh, but with `z -` rather than `z +`, and with the sign // flipped on the result based on the sign of the input. - private const uint SIGN_MASK = 0x7FFFFFFF; - private const float LOGV = 0.693161f; - private const float HALFV = 1.0000138f; - private const float INVV2 = 0.24999309f; + private const double LOGV = 0.6931610107421875; + private const double HALFV = 1.000013828277588; + private const double INVV2 = 0.24999308586120605; - public static bool Vectorizable => typeof(T) == typeof(float); + public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); public static T Invoke(T x) => T.Sinh(x); public static Vector128 Invoke(Vector128 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector128 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector128 x = t.AsSingle(); - Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); - Vector128 result = Vector128.Create(HALFV) * (z - (Vector128.Create(INVV2) / z)); - Vector128 sign = x.AsUInt32() & Vector128.Create(~SIGN_MASK); - return (sign ^ result.AsUInt32()).AsSingle().As(); + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)LOGV)); + Vector128 result = Vector128.Create((float)HALFV) * (z - (Vector128.Create((float)INVV2) / z)); + Vector128 sign = x.AsUInt32() & Vector128.Create(~(uint)int.MaxValue); + return (sign ^ result.AsUInt32()).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector128 x = t.AsDouble(); + + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); + Vector128 result = Vector128.Create(HALFV) * (z - (Vector128.Create(INVV2) / z)); + Vector128 sign = x.AsUInt64() & Vector128.Create(~(ulong)long.MaxValue); + return (sign ^ result.AsUInt64()).As(); + } } public static Vector256 Invoke(Vector256 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector256 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector256 x = t.AsSingle(); - Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); - Vector256 result = Vector256.Create(HALFV) * (z - (Vector256.Create(INVV2) / z)); - Vector256 sign = x.AsUInt32() & Vector256.Create(~SIGN_MASK); - return (sign ^ result.AsUInt32()).AsSingle().As(); + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)LOGV)); + Vector256 result = Vector256.Create((float)HALFV) * (z - (Vector256.Create((float)INVV2) / z)); + Vector256 sign = x.AsUInt32() & Vector256.Create(~(uint)int.MaxValue); + return (sign ^ result.AsUInt32()).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector256 x = t.AsDouble(); + + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); + Vector256 result = Vector256.Create(HALFV) * (z - (Vector256.Create(INVV2) / z)); + Vector256 sign = x.AsUInt64() & Vector256.Create(~(ulong)long.MaxValue); + return (sign ^ result.AsUInt64()).As(); + } } public static Vector512 Invoke(Vector512 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector512 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector512 x = t.AsSingle(); - Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); - Vector512 result = Vector512.Create(HALFV) * (z - (Vector512.Create(INVV2) / z)); - Vector512 sign = x.AsUInt32() & Vector512.Create(~SIGN_MASK); - return (sign ^ result.AsUInt32()).AsSingle().As(); + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)LOGV)); + Vector512 result = Vector512.Create((float)HALFV) * (z - (Vector512.Create((float)INVV2) / z)); + Vector512 sign = x.AsUInt32() & Vector512.Create(~(uint)int.MaxValue); + return (sign ^ result.AsUInt32()).As(); + } + else + { + Debug.Assert(typeof(T) == typeof(double)); + Vector512 x = t.AsDouble(); + + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); + Vector512 result = Vector512.Create(HALFV) * (z - (Vector512.Create(INVV2) / z)); + Vector512 sign = x.AsUInt64() & Vector512.Create(~(ulong)long.MaxValue); + return (sign ^ result.AsUInt64()).As(); + } } } @@ -13223,43 +13290,74 @@ public static Vector512 Invoke(Vector512 t) // If x < 0, then we use the identity // tanhf(-x) = -tanhf(x) - private const uint SIGN_MASK = 0x7FFFFFFF; - - public static bool Vectorizable => typeof(T) == typeof(float); + public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); public static T Invoke(T x) => T.Tanh(x); public static Vector128 Invoke(Vector128 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector128 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector128 x = t.AsSingle(); - Vector128 y = Vector128.Abs(x); - Vector128 z = ExpM1Operator.Invoke(Vector128.Create(-2f) * y); - Vector128 sign = x.AsUInt32() & Vector128.Create(~SIGN_MASK); - return (sign ^ (-z / (z + Vector128.Create(2f))).AsUInt32()).AsSingle().As(); + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpM1Operator.Invoke(Vector128.Create(-2f) * y); + Vector128 sign = x.AsUInt32() & Vector128.Create(~(uint)int.MaxValue); + return (sign ^ (-z / (z + Vector128.Create(2f))).AsUInt32()).As(); + } + else + { + Vector128 x = t.AsDouble(); + + Vector128 y = Vector128.Abs(x); + Vector128 z = ExpM1Operator.Invoke(Vector128.Create(-2d) * y); + Vector128 sign = x.AsUInt64() & Vector128.Create(~(ulong)long.MaxValue); + return (sign ^ (-z / (z + Vector128.Create(2d))).AsUInt64()).As(); + } } public static Vector256 Invoke(Vector256 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector256 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector256 x = t.AsSingle(); - Vector256 y = Vector256.Abs(x); - Vector256 z = ExpM1Operator.Invoke(Vector256.Create(-2f) * y); - Vector256 sign = x.AsUInt32() & Vector256.Create(~SIGN_MASK); - return (sign ^ (-z / (z + Vector256.Create(2f))).AsUInt32()).AsSingle().As(); + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpM1Operator.Invoke(Vector256.Create(-2f) * y); + Vector256 sign = x.AsUInt32() & Vector256.Create(~(uint)int.MaxValue); + return (sign ^ (-z / (z + Vector256.Create(2f))).AsUInt32()).As(); + } + else + { + Vector256 x = t.AsDouble(); + + Vector256 y = Vector256.Abs(x); + Vector256 z = ExpM1Operator.Invoke(Vector256.Create(-2d) * y); + Vector256 sign = x.AsUInt64() & Vector256.Create(~(ulong)long.MaxValue); + return (sign ^ (-z / (z + Vector256.Create(2d))).AsUInt64()).As(); + } } public static Vector512 Invoke(Vector512 t) { - Debug.Assert(typeof(T) == typeof(float)); - Vector512 x = t.AsSingle(); + if (typeof(T) == typeof(float)) + { + Vector512 x = t.AsSingle(); - Vector512 y = Vector512.Abs(x); - Vector512 z = ExpM1Operator.Invoke(Vector512.Create(-2f) * y); - Vector512 sign = x.AsUInt32() & Vector512.Create(~SIGN_MASK); - return (sign ^ (-z / (z + Vector512.Create(2f))).AsUInt32()).AsSingle().As(); + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpM1Operator.Invoke(Vector512.Create(-2f) * y); + Vector512 sign = x.AsUInt32() & Vector512.Create(~(uint)int.MaxValue); + return (sign ^ (-z / (z + Vector512.Create(2f))).AsUInt32()).As(); + } + else + { + Vector512 x = t.AsDouble(); + + Vector512 y = Vector512.Abs(x); + Vector512 z = ExpM1Operator.Invoke(Vector512.Create(-2d) * y); + Vector512 sign = x.AsUInt64() & Vector512.Create(~(ulong)long.MaxValue); + return (sign ^ (-z / (z + Vector512.Create(2d))).AsUInt64()).As(); + } } } From 87037f93ea3defeb01e67cda5cd054c092ae9e1f Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 2 Feb 2024 20:37:40 -0500 Subject: [PATCH 2/3] Address PR feedback --- .../Tensors/netcore/TensorPrimitives.netcore.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs index 730f8d56cba0c0..df7d906b8bca81 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs @@ -13060,9 +13060,9 @@ public static Vector512 Invoke(Vector512 x) // // coshf = v/2 * exp(x - log(v)) where v = 0x1.0000e8p-1 - private const double LOGV = 0.6931610107421875; - private const double HALFV = 1.000013828277588; - private const double INVV2 = 0.24999308586120605; + private const double LOGV = 0.6931471805599453; + private const double HALFV = 1.0; + private const double INVV2 = 0.25; public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); @@ -13161,9 +13161,9 @@ public static Vector512 Invoke(Vector512 t) // Same as cosh, but with `z -` rather than `z +`, and with the sign // flipped on the result based on the sign of the input. - private const double LOGV = 0.6931610107421875; - private const double HALFV = 1.000013828277588; - private const double INVV2 = 0.24999308586120605; + private const double LOGV = 0.6931471805599453; + private const double HALFV = 1.0; + private const double INVV2 = 0.25; public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); From 7ed8e3ee963832ae6148bc1347bb7c3ac016e4ed Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sat, 3 Feb 2024 16:33:56 -0500 Subject: [PATCH 3/3] Separate float/double constants --- .../netcore/TensorPrimitives.netcore.cs | 68 +++++++++++-------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs index df7d906b8bca81..2a903a4ca32824 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs @@ -13060,9 +13060,13 @@ public static Vector512 Invoke(Vector512 x) // // coshf = v/2 * exp(x - log(v)) where v = 0x1.0000e8p-1 - private const double LOGV = 0.6931471805599453; - private const double HALFV = 1.0; - private const double INVV2 = 0.25; + private const float SINGLE_LOGV = 0.693161f; + private const float SINGLE_HALFV = 1.0000138f; + private const float SINGLE_INVV2 = 0.24999309f; + + private const double DOUBLE_LOGV = 0.6931471805599453; + private const double DOUBLE_HALFV = 1.0; + private const double DOUBLE_INVV2 = 0.25; public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); @@ -13075,8 +13079,8 @@ public static Vector128 Invoke(Vector128 t) Vector128 x = t.AsSingle(); Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)LOGV)); - return (Vector128.Create((float)HALFV) * (z + (Vector128.Create((float)INVV2) / z))).As(); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)SINGLE_LOGV)); + return (Vector128.Create((float)SINGLE_HALFV) * (z + (Vector128.Create((float)SINGLE_INVV2) / z))).As(); } else { @@ -13084,8 +13088,8 @@ public static Vector128 Invoke(Vector128 t) Vector128 x = t.AsDouble(); Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); - return (Vector128.Create(HALFV) * (z + (Vector128.Create(INVV2) / z))).As(); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create(DOUBLE_LOGV)); + return (Vector128.Create(DOUBLE_HALFV) * (z + (Vector128.Create(DOUBLE_INVV2) / z))).As(); } } @@ -13096,8 +13100,8 @@ public static Vector256 Invoke(Vector256 t) Vector256 x = t.AsSingle(); Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)LOGV)); - return (Vector256.Create((float)HALFV) * (z + (Vector256.Create((float)INVV2) / z))).As(); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)SINGLE_LOGV)); + return (Vector256.Create((float)SINGLE_HALFV) * (z + (Vector256.Create((float)SINGLE_INVV2) / z))).As(); } else { @@ -13105,8 +13109,8 @@ public static Vector256 Invoke(Vector256 t) Vector256 x = t.AsDouble(); Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); - return (Vector256.Create(HALFV) * (z + (Vector256.Create(INVV2) / z))).As(); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create(DOUBLE_LOGV)); + return (Vector256.Create(DOUBLE_HALFV) * (z + (Vector256.Create(DOUBLE_INVV2) / z))).As(); } } @@ -13117,8 +13121,8 @@ public static Vector512 Invoke(Vector512 t) Vector512 x = t.AsSingle(); Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)LOGV)); - return (Vector512.Create((float)HALFV) * (z + (Vector512.Create((float)INVV2) / z))).As(); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)SINGLE_LOGV)); + return (Vector512.Create((float)SINGLE_HALFV) * (z + (Vector512.Create((float)SINGLE_INVV2) / z))).As(); } else { @@ -13126,8 +13130,8 @@ public static Vector512 Invoke(Vector512 t) Vector512 x = t.AsDouble(); Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); - return (Vector512.Create(HALFV) * (z + (Vector512.Create(INVV2) / z))).As(); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create(DOUBLE_LOGV)); + return (Vector512.Create(DOUBLE_HALFV) * (z + (Vector512.Create(DOUBLE_INVV2) / z))).As(); } } } @@ -13161,9 +13165,13 @@ public static Vector512 Invoke(Vector512 t) // Same as cosh, but with `z -` rather than `z +`, and with the sign // flipped on the result based on the sign of the input. - private const double LOGV = 0.6931471805599453; - private const double HALFV = 1.0; - private const double INVV2 = 0.25; + private const float SINGLE_LOGV = 0.693161f; + private const float SINGLE_HALFV = 1.0000138f; + private const float SINGLE_INVV2 = 0.24999309f; + + private const double DOUBLE_LOGV = 0.6931471805599453; + private const double DOUBLE_HALFV = 1.0; + private const double DOUBLE_INVV2 = 0.25; public static bool Vectorizable => typeof(T) == typeof(float) || typeof(T) == typeof(double); @@ -13176,8 +13184,8 @@ public static Vector128 Invoke(Vector128 t) Vector128 x = t.AsSingle(); Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)LOGV)); - Vector128 result = Vector128.Create((float)HALFV) * (z - (Vector128.Create((float)INVV2) / z)); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create((float)SINGLE_LOGV)); + Vector128 result = Vector128.Create((float)SINGLE_HALFV) * (z - (Vector128.Create((float)SINGLE_INVV2) / z)); Vector128 sign = x.AsUInt32() & Vector128.Create(~(uint)int.MaxValue); return (sign ^ result.AsUInt32()).As(); } @@ -13187,8 +13195,8 @@ public static Vector128 Invoke(Vector128 t) Vector128 x = t.AsDouble(); Vector128 y = Vector128.Abs(x); - Vector128 z = ExpOperator.Invoke(y - Vector128.Create(LOGV)); - Vector128 result = Vector128.Create(HALFV) * (z - (Vector128.Create(INVV2) / z)); + Vector128 z = ExpOperator.Invoke(y - Vector128.Create(DOUBLE_LOGV)); + Vector128 result = Vector128.Create(DOUBLE_HALFV) * (z - (Vector128.Create(DOUBLE_INVV2) / z)); Vector128 sign = x.AsUInt64() & Vector128.Create(~(ulong)long.MaxValue); return (sign ^ result.AsUInt64()).As(); } @@ -13201,8 +13209,8 @@ public static Vector256 Invoke(Vector256 t) Vector256 x = t.AsSingle(); Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)LOGV)); - Vector256 result = Vector256.Create((float)HALFV) * (z - (Vector256.Create((float)INVV2) / z)); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create((float)SINGLE_LOGV)); + Vector256 result = Vector256.Create((float)SINGLE_HALFV) * (z - (Vector256.Create((float)SINGLE_INVV2) / z)); Vector256 sign = x.AsUInt32() & Vector256.Create(~(uint)int.MaxValue); return (sign ^ result.AsUInt32()).As(); } @@ -13212,8 +13220,8 @@ public static Vector256 Invoke(Vector256 t) Vector256 x = t.AsDouble(); Vector256 y = Vector256.Abs(x); - Vector256 z = ExpOperator.Invoke(y - Vector256.Create(LOGV)); - Vector256 result = Vector256.Create(HALFV) * (z - (Vector256.Create(INVV2) / z)); + Vector256 z = ExpOperator.Invoke(y - Vector256.Create(DOUBLE_LOGV)); + Vector256 result = Vector256.Create(DOUBLE_HALFV) * (z - (Vector256.Create(DOUBLE_INVV2) / z)); Vector256 sign = x.AsUInt64() & Vector256.Create(~(ulong)long.MaxValue); return (sign ^ result.AsUInt64()).As(); } @@ -13226,8 +13234,8 @@ public static Vector512 Invoke(Vector512 t) Vector512 x = t.AsSingle(); Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)LOGV)); - Vector512 result = Vector512.Create((float)HALFV) * (z - (Vector512.Create((float)INVV2) / z)); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create((float)SINGLE_LOGV)); + Vector512 result = Vector512.Create((float)SINGLE_HALFV) * (z - (Vector512.Create((float)SINGLE_INVV2) / z)); Vector512 sign = x.AsUInt32() & Vector512.Create(~(uint)int.MaxValue); return (sign ^ result.AsUInt32()).As(); } @@ -13237,8 +13245,8 @@ public static Vector512 Invoke(Vector512 t) Vector512 x = t.AsDouble(); Vector512 y = Vector512.Abs(x); - Vector512 z = ExpOperator.Invoke(y - Vector512.Create(LOGV)); - Vector512 result = Vector512.Create(HALFV) * (z - (Vector512.Create(INVV2) / z)); + Vector512 z = ExpOperator.Invoke(y - Vector512.Create(DOUBLE_LOGV)); + Vector512 result = Vector512.Create(DOUBLE_HALFV) * (z - (Vector512.Create(DOUBLE_INVV2) / z)); Vector512 sign = x.AsUInt64() & Vector512.Create(~(ulong)long.MaxValue); return (sign ^ result.AsUInt64()).As(); }