-
Notifications
You must be signed in to change notification settings - Fork 818
Adding ModF tests to HLK Long Vector unittests #7859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
f54718e
b8585b8
0495fd5
271cb0a
20eaa93
27f4e31
5d66ed8
068f4fc
c51afa9
dbbc868
eab4ea4
a4de02c
57a6be9
66bd46b
cfebdfd
b5c78af
0aa2c1e
17786f1
2753e74
0cfb5bd
be40a7b
ad8b7ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -628,6 +628,21 @@ struct StrictValidation { | |
| #define DEFAULT_OP_2(OP, IMPL) OP_2(OP, DefaultValidation<T>, IMPL) | ||
| #define DEFAULT_OP_3(OP, IMPL) OP_3(OP, DefaultValidation<T>, IMPL) | ||
|
|
||
| #define OP_WITH_OUT_PARAM_1(OPERATION, TYPE, IMPL) \ | ||
| template <> struct ExpectedBuilder<OpType::OPERATION, TYPE> { \ | ||
| static std::vector<TYPE> buildExpected(Op<OpType::OPERATION, TYPE, 1>, \ | ||
| const InputSets<TYPE> &Inputs) { \ | ||
| DXASSERT_NOMSG(Inputs.size() == 1); \ | ||
| const size_t VectorSize = Inputs[0].size(); \ | ||
| std::vector<TYPE> Expected; \ | ||
| Expected.resize(VectorSize * 2); \ | ||
| for (size_t I = 0; I < VectorSize; ++I) { \ | ||
| IMPL \ | ||
|
||
| } \ | ||
| return Expected; \ | ||
| } \ | ||
| }; | ||
|
|
||
| // | ||
| // TernaryMath | ||
| // | ||
|
|
@@ -1015,41 +1030,21 @@ DEFAULT_OP_1(OpType::Log2, (std::log2(A))); | |
| // with special logic. Frexp is only supported for fp32 values. | ||
| template <> struct Op<OpType::Frexp, float, 1> : DefaultValidation<float> {}; | ||
|
|
||
| template <> struct ExpectedBuilder<OpType::Frexp, float> { | ||
| static std::vector<float> buildExpected(Op<OpType::Frexp, float, 1> &, | ||
| const InputSets<float> &Inputs) { | ||
| DXASSERT_NOMSG(Inputs.size() == 1); | ||
|
|
||
| // Expected values size is doubled. In the first half we store the | ||
| // Mantissas and in the second half we store the Exponents. This way we | ||
| // can leverage the existing logic which verify expected values in a | ||
| // single vector. We just need to make sure that we organize the output in | ||
| // the same way in the shader and when we read it back. | ||
| OP_WITH_OUT_PARAM_1(Frexp, float, { | ||
|
||
| int Exp = 0; | ||
| float Man = std::frexp(Inputs[0][I], &Exp); | ||
|
|
||
| size_t VectorSize = Inputs[0].size(); | ||
|
|
||
| std::vector<float> Expected; | ||
| Expected.resize(VectorSize * 2); | ||
|
|
||
| for (size_t I = 0; I < VectorSize; ++I) { | ||
| int Exp = 0; | ||
| float Man = std::frexp(Inputs[0][I], &Exp); | ||
| // std::frexp returns a signed mantissa. But the HLSL implmentation | ||
| // returns an unsigned mantissa. | ||
| Man = std::abs(Man); | ||
|
|
||
| // std::frexp returns a signed mantissa. But the HLSL implmentation | ||
| // returns an unsigned mantissa. | ||
| Man = std::abs(Man); | ||
| Expected[I] = Man; | ||
|
|
||
| Expected[I] = Man; | ||
|
|
||
| // std::frexp returns the exponent as an int, but HLSL stores it as a | ||
| // float. However, the HLSL exponents fractional component is always 0. | ||
| // So it can conversion between float and int is safe. | ||
| Expected[I + VectorSize] = static_cast<float>(Exp); | ||
| } | ||
|
|
||
| return Expected; | ||
| } | ||
| }; | ||
| // std::frexp returns the exponent as an int, but HLSL stores it as a | ||
| // float. However, the HLSL exponents fractional component is always 0. | ||
| // So it can conversion between float and int is safe. | ||
| Expected[I + VectorSize] = static_cast<float>(Exp); | ||
| }); | ||
|
|
||
| // | ||
| // Binary Comparison | ||
|
|
@@ -1236,6 +1231,23 @@ FLOAT_SPECIAL_OP(OpType::IsInf, (std::isinf(A))); | |
| FLOAT_SPECIAL_OP(OpType::IsNan, (std::isnan(A))); | ||
| #undef FLOAT_SPECIAL_OP | ||
|
|
||
| template <typename T> struct Op<OpType::ModF, T, 1> : DefaultValidation<T> {}; | ||
|
|
||
| OP_WITH_OUT_PARAM_1(ModF, float, { | ||
| float Exp = 0.0f; | ||
| float Man = std::modf(Inputs[0][I], &Exp); | ||
| Expected[I] = Man; | ||
| Expected[I + VectorSize] = Exp; | ||
| }); | ||
|
|
||
| OP_WITH_OUT_PARAM_1(ModF, HLSLHalf_t, { | ||
| float Exp = 0.0f; | ||
| float Inp = float(Inputs[0][I]); | ||
| float Man = std::modf(Inp, &Exp); | ||
| Expected[I] = HLSLHalf_t(Man); | ||
| Expected[I + VectorSize] = HLSLHalf_t(Exp); | ||
| }); | ||
|
|
||
| // | ||
| // dispatchTest | ||
| // | ||
|
|
@@ -1772,10 +1784,12 @@ class DxilConf_SM69_Vectorized { | |
| HLK_TEST(IsFinite, HLSLHalf_t); | ||
| HLK_TEST(IsInf, HLSLHalf_t); | ||
| HLK_TEST(IsNan, HLSLHalf_t); | ||
| HLK_TEST(ModF, HLSLHalf_t); | ||
|
|
||
| HLK_TEST(IsFinite, float); | ||
| HLK_TEST(IsInf, float); | ||
| HLK_TEST(IsNan, float); | ||
| HLK_TEST(ModF, float); | ||
|
|
||
| // Binary Comparison | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Change 'OPEARTION' to 'OP' to match the pattern of the other macros.