Skip to content
Merged
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
25 changes: 23 additions & 2 deletions tools/clang/unittests/HLSLExec/LongVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,33 @@ CAST_OP(OpType::CastToFloat64, double, (CastToFloat64(A)));
// specs. An example with this spec for sin and cos is available here:
// https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#22.10.20

struct TrigonometricValidation {
template <typename T, OpType OP> struct TrigonometricValidation {
ValidationConfig ValidationConfig = ValidationConfig::Epsilon(0.0008f);
};

// Half precision trig functions have a larger tolerance due to their lower
// precision. Note that the D3D spec
// does not mention half precision trig functions.
template <OpType OP> struct TrigonometricValidation<HLSLHalf_t, OP> {
ValidationConfig ValidationConfig = ValidationConfig::Epsilon(0.003f);
};

// For the half precision trig functions with an infinite range in either
// direction we use 2 ULPs of tolerance instead.
template <> struct TrigonometricValidation<HLSLHalf_t, OpType::Cosh> {
ValidationConfig ValidationConfig = ValidationConfig::Ulp(2.0f);
};

template <> struct TrigonometricValidation<HLSLHalf_t, OpType::Tan> {
ValidationConfig ValidationConfig = ValidationConfig::Ulp(2.0f);
};

template <> struct TrigonometricValidation<HLSLHalf_t, OpType::Sinh> {
ValidationConfig ValidationConfig = ValidationConfig::Ulp(2.0f);
};

#define TRIG_OP(OP, IMPL) \
template <typename T> struct Op<OP, T, 1> : TrigonometricValidation { \
template <typename T> struct Op<OP, T, 1> : TrigonometricValidation<T, OP> { \
T operator()(T A) { return IMPL; } \
}

Expand Down