Commit 0aef6454 by Antonio Maiorano

Subzero: fix cosh/sinh deqp failures

As was done with LLVM (https://swiftshader-review.googlesource.com/c/SwiftShader/+/35988), implement Sinh and Cosh in terms of Exp for Subzero. Both backends now call into EmulatedReactor. This is not the right solution, as Reactor should be implemented in terms of std cosh/sinh or intrinsics, as per b/149110874. Bug: b/145754674 Change-Id: I8f513e46fb4af270a847343e4b561927aaad1560 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41009Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com>
parent 2d7ca9ce
......@@ -193,12 +193,14 @@ RValue<Float4> Atan(RValue<Float4> x)
RValue<Float4> Sinh(RValue<Float4> x)
{
return call4(sinhf, x);
// TODO(b/149110874) Use coshf/sinhf when we've implemented SpirV versions at the SpirV level
return Float4(0.5f) * (emulated::Exp(x) - emulated::Exp(-x));
}
RValue<Float4> Cosh(RValue<Float4> x)
{
return call4(coshf, x);
// TODO(b/149110874) Use coshf/sinhf when we've implemented SpirV versions at the SpirV level
return Float4(0.5f) * (emulated::Exp(x) + emulated::Exp(-x));
}
RValue<Float4> Tanh(RValue<Float4> x)
......
......@@ -16,6 +16,7 @@
#include "CPUID.hpp"
#include "Debug.hpp"
#include "EmulatedReactor.hpp"
#include "LLVMReactorDebugInfo.hpp"
#include "Reactor.hpp"
#include "x86.hpp"
......@@ -3171,12 +3172,12 @@ RValue<Float4> Atan(RValue<Float4> v)
RValue<Float4> Sinh(RValue<Float4> v)
{
return Float4(0.5f) * (Exp(v) - Exp(-v));
return emulated::Sinh(v);
}
RValue<Float4> Cosh(RValue<Float4> v)
{
return Float4(0.5f) * (Exp(v) + Exp(-v));
return emulated::Cosh(v);
}
RValue<Float4> Tanh(RValue<Float4> v)
......
......@@ -2134,6 +2134,15 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float, IntrinsicTest_Float, testing
// clang-format on
// TODO(b/149110874) Use coshf/sinhf when we've implemented SpirV versions at the SpirV level
float vulkan_sinhf(float a)
{
return ((expf(a) - expf(-a)) / 2);
}
float vulkan_coshf(float a)
{
return ((expf(a) + expf(-a)) / 2);
}
// clang-format off
INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4, IntrinsicTest_Float4, testing::Values(
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sin(v); }, sinf, {0.f, 1.f, PI, 12345.f} },
......@@ -2142,8 +2151,8 @@ INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4, IntrinsicTest_Float4, testi
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asin(v); }, asinf, {0.f, 1.f, -1.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acos(v); }, acosf, {0.f, 1.f, -1.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Atan(v); }, atanf, {0.f, 1.f, PI, 12345.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sinh(v); }, sinhf, {0.f, 1.f, PI, 12345.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cosh(v); }, coshf, {0.f, 1.f, PI, 12345.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sinh(v); }, vulkan_sinhf, {0.f, 1.f, PI, 12345.f, 0x1.65a84ep6} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cosh(v); }, vulkan_coshf, {0.f, 1.f, PI, 12345.f, 0x1.65a84ep6} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Tanh(v); }, tanhf, {0.f, 1.f, PI, 12345.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asinh(v); }, asinhf, {0.f, 1.f, PI, 12345.f} },
IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acosh(v); }, acoshf, { 1.f, PI, 12345.f} },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment