-
Notifications
You must be signed in to change notification settings - Fork 802
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
base: main
Are you sure you want to change the base?
Changes from all commits
f54718e
b8585b8
0495fd5
271cb0a
20eaa93
27f4e31
5d66ed8
068f4fc
c51afa9
dbbc868
eab4ea4
a4de02c
57a6be9
66bd46b
cfebdfd
b5c78af
0aa2c1e
17786f1
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,6 +103,21 @@ static constexpr Operation Operations[] = { | |||||
| #include "LongVectorOps.def" | ||||||
| }; | ||||||
|
|
||||||
| #define OP_WITH_OUT_PARAM(OPERATION, TYPE, IMPL) \ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Given that we're restricting this to unary ops I think we can clarify that by appending the 1 in the name like some of the other macros do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think it would be better to put this macro with the other similar class of macro definitions around line 625. |
||||||
| 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); \ | ||||||
| size_t VectorSize = Inputs[0].size(); \ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
| std::vector<TYPE> Expected; \ | ||||||
| Expected.resize(VectorSize * 2); \ | ||||||
| for (size_t I = 0; I < VectorSize; ++I) { \ | ||||||
| IMPL \ | ||||||
| } \ | ||||||
| return Expected; \ | ||||||
| } \ | ||||||
| }; | ||||||
|
|
||||||
| constexpr const Operation &getOperation(OpType Op) { | ||||||
| if (Op < OpType::NumOpTypes) | ||||||
| return Operations[unsigned(Op)]; | ||||||
|
|
@@ -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(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(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(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.