From f54718e69ff860b2f73bad404ea80336536c2bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Fri, 24 Oct 2025 12:59:05 -0700 Subject: [PATCH 01/16] adding test? --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 5 +++++ tools/clang/unittests/HLSLExec/LongVectors.cpp | 14 ++++++++++++++ tools/clang/unittests/HLSLExec/ShaderOpArith.xml | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index c4f96e1b5a..7f4a7dc9e0 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,6 +18,7 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) +INPUT_SET(IsFinite) #undef INPUT_SET @@ -137,6 +138,10 @@ OP_DEFAULT(Binary, Logical_Or, 2, "or", ",") OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) + +OP_DEFAULT(BooleanFloat, IsFinite, 1, "", "") + + // For the 'any' and 'all' reduction operation, we test with three different // input data sets to cover the different cases of the operation. 'Any' returns // true if any of the inputs are non-zero, false otherwise. This is in diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 93a46d02fb..f1523b3a82 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1140,6 +1140,17 @@ STRICT_OP_1(OpType::LoadAndStore_DT_SB_SRV, (A)); STRICT_OP_1(OpType::LoadAndStore_RD_SB_UAV, (A)); STRICT_OP_1(OpType::LoadAndStore_RD_SB_SRV, (A)); +// +// Float Ops +// + +#define BOOLEAN_FLOAT_OP(OP, IMPL) \ + template struct Op : StrictValidation { \ + HLSLBool_t operator()(T A) { return IMPL; } \ + }; + +BOOLEAN_FLOAT_OP(OpType::IsFinite, (std::isfinite(A))); + // // dispatchTest // @@ -1915,6 +1926,9 @@ class DxilConf_SM69_Vectorized { HLK_TEST(LoadAndStore_RD_SB_SRV, double); HLK_TEST(LoadAndStore_RD_SB_UAV, double); + // Boolean Float + HLK_TEST(IsFinite, float) + private: bool Initialized = false; bool VerboseLogging = false; diff --git a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml index f89a87ca68..76e7c3e154 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml +++ b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml @@ -4112,6 +4112,14 @@ void MSMain(uint GID : SV_GroupIndex, } #endif + #ifdef FUNC_TEST_ISFINITE + vector TestIsFinite(vector Vector) + { + vector IsFinite = isfinite(Vector); + return IsFinite; + } + #endif + #ifdef FUNC_SHUFFLE_VECTOR vector TestShuffleVector(TYPE Scalar) { From b8585b8e528bae31487495c24d5efa213eec9233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Fri, 24 Oct 2025 13:02:00 -0700 Subject: [PATCH 02/16] remove input set --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index 7f4a7dc9e0..01bdc818fb 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,7 +18,6 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) -INPUT_SET(IsFinite) #undef INPUT_SET From 0495fd57ec9d38f6007a9beb52de79a14cbbfed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Fri, 24 Oct 2025 14:47:15 -0700 Subject: [PATCH 03/16] adding test --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 4 ++-- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index 01bdc818fb..53d230dfcc 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -137,8 +137,8 @@ OP_DEFAULT(Binary, Logical_Or, 2, "or", ",") OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) - -OP_DEFAULT(BooleanFloat, IsFinite, 1, "", "") +OP(Ternary, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", + "LongVectorOp", Default1, Default2, Default3) // For the 'any' and 'all' reduction operation, we test with three different diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 24a4301299..9ec9b752c3 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -351,7 +351,8 @@ INPUT_SET(InputSet::SelectCond, 0.0, 1.0); END_INPUT_SETS() BEGIN_INPUT_SETS(float) -INPUT_SET(InputSet::Default1, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, +INPUT_SET(InputSet::Default1, 1.0, -1.0, 1.0, + std::numeric_limits::infinity(), 1.0, -1.0, 1.0, -1.0, 1.0, -1.0); INPUT_SET(InputSet::Default2, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0); From 271cb0aadda9d6603a0d98be38ce2cd9804f388f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Mon, 27 Oct 2025 11:29:49 -0700 Subject: [PATCH 04/16] fix --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 5 +++-- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index 53d230dfcc..3b2aeec51e 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,6 +18,7 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) +INPUT_SET(Infinite) #undef INPUT_SET @@ -137,8 +138,8 @@ OP_DEFAULT(Binary, Logical_Or, 2, "or", ",") OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) -OP(Ternary, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", - "LongVectorOp", Default1, Default2, Default3) +OP(Unary, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", + "LongVectorOp", Default1, Default2, Infinite) // For the 'any' and 'all' reduction operation, we test with three different diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 9ec9b752c3..d56813b2bf 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -351,8 +351,7 @@ INPUT_SET(InputSet::SelectCond, 0.0, 1.0); END_INPUT_SETS() BEGIN_INPUT_SETS(float) -INPUT_SET(InputSet::Default1, 1.0, -1.0, 1.0, - std::numeric_limits::infinity(), 1.0, -1.0, 1.0, -1.0, 1.0, +INPUT_SET(InputSet::Default1, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0); INPUT_SET(InputSet::Default2, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0); @@ -365,6 +364,8 @@ INPUT_SET(InputSet::RangeOne, 0.727f, 0.331f, -0.957f, 0.677f, -0.025f, 0.495f, INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f, 0.01f, 331.2330f, 3250.01f); INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f); +INPUT_SET(InputSet::Infinite, + std::numeric_limits::infinity(), -std::numeric_limits::infinity(), 32); END_INPUT_SETS() BEGIN_INPUT_SETS(double) From 27f4e319e1aee6aa52dec82d1e3a8038bd1759d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Mon, 27 Oct 2025 12:08:19 -0700 Subject: [PATCH 05/16] adding other numeric types test --- .../clang/unittests/HLSLExec/LongVectorOps.def | 2 +- .../unittests/HLSLExec/LongVectorTestData.h | 18 ++++++++++++++++-- tools/clang/unittests/HLSLExec/LongVectors.cpp | 12 +++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index 3b2aeec51e..c7e270f5a0 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -139,7 +139,7 @@ OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) OP(Unary, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", - "LongVectorOp", Default1, Default2, Infinite) + "LongVectorOp", Infinite, Default2, Default3) // For the 'any' and 'all' reduction operation, we test with three different diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index d56813b2bf..6217c1b97e 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -262,6 +262,7 @@ INPUT_SET(InputSet::Default3, true, false, true, false, true, true, true, true, INPUT_SET(InputSet::Zero, false); INPUT_SET(InputSet::NoZero, true); INPUT_SET(InputSet::SelectCond, false, true); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int16_t) @@ -275,6 +276,8 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x5555, static_cast(0xAAAA), std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int32_t) @@ -288,6 +291,8 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x55555555, static_cast(0xAAAAAAAA), std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int64_t) @@ -301,6 +306,8 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x5555555555555555LL, 0xAAAAAAAAAAAAAAAALL, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint16_t) @@ -311,6 +318,7 @@ INPUT_SET(InputSet::BitShiftRhs, 1, 6, 3, 0, 9, 3, 12, 13, 14, 15); INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x5555, 0xAAAA, 0x8000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint32_t) @@ -321,6 +329,7 @@ INPUT_SET(InputSet::BitShiftRhs, 1, 6, 3, 0, 9, 3, 30, 31, 32); INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x55555555, 0xAAAAAAAA, 0x80000000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint64_t) @@ -332,6 +341,7 @@ INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x5555555555555555, 0xAAAAAAAAAAAAAAAA, 0x8000000000000000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(HLSLHalf_t) @@ -348,6 +358,8 @@ INPUT_SET(InputSet::RangeOne, 0.331, 0.727, -0.957, 0.677, -0.025, 0.495, 0.855, INPUT_SET(InputSet::Positive, 1.0, 1.0, 342.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(float) @@ -364,8 +376,8 @@ INPUT_SET(InputSet::RangeOne, 0.727f, 0.331f, -0.957f, 0.677f, -0.025f, 0.495f, INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f, 0.01f, 331.2330f, 3250.01f); INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f); -INPUT_SET(InputSet::Infinite, - std::numeric_limits::infinity(), -std::numeric_limits::infinity(), 32); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(double) @@ -384,6 +396,8 @@ INPUT_SET(InputSet::SplitDouble, 0.0, -1.0, 1.0, -1.0, 12345678.87654321, -1.0, INPUT_SET(InputSet::Positive, 1.0, 1.0, 65535.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity()); END_INPUT_SETS() #undef BEGIN_INPUT_SETS diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index f1523b3a82..25bb291d2f 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1491,6 +1491,15 @@ class DxilConf_SM69_Vectorized { HLK_TEST(ShuffleVector, float); HLK_TEST(ShuffleVector, double); + HLK_TEST(IsFinite, int16_t); + HLK_TEST(IsFinite, int32_t); + HLK_TEST(IsFinite, int64_t); + HLK_TEST(IsFinite, uint16_t); + HLK_TEST(IsFinite, uint32_t); + HLK_TEST(IsFinite, uint64_t); + HLK_TEST(IsFinite, HLSLHalf_t); + HLK_TEST(IsFinite, float); + HLK_TEST(IsFinite, double); // Explicit Cast HLK_TEST(CastToInt16, HLSLBool_t); @@ -1926,9 +1935,6 @@ class DxilConf_SM69_Vectorized { HLK_TEST(LoadAndStore_RD_SB_SRV, double); HLK_TEST(LoadAndStore_RD_SB_UAV, double); - // Boolean Float - HLK_TEST(IsFinite, float) - private: bool Initialized = false; bool VerboseLogging = false; From 5d66ed8127ef9d6dbc605dddde19e1f7e4d0cd89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Mon, 27 Oct 2025 12:09:42 -0700 Subject: [PATCH 06/16] clean up --- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 6217c1b97e..cb7927f4d2 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -262,7 +262,6 @@ INPUT_SET(InputSet::Default3, true, false, true, false, true, true, true, true, INPUT_SET(InputSet::Zero, false); INPUT_SET(InputSet::NoZero, true); INPUT_SET(InputSet::SelectCond, false, true); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int16_t) From 068f4fcc355d26eddfb1c07749450f59c2da1ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Mon, 27 Oct 2025 12:14:46 -0700 Subject: [PATCH 07/16] reduce tests to only float point types --- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 9 --------- tools/clang/unittests/HLSLExec/LongVectors.cpp | 7 +------ 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index cb7927f4d2..ae28405be6 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -275,8 +275,6 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x5555, static_cast(0xAAAA), std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int32_t) @@ -290,8 +288,6 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x55555555, static_cast(0xAAAAAAAA), std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(int64_t) @@ -305,8 +301,6 @@ INPUT_SET(InputSet::Bitwise, std::numeric_limits::min(), -1, 0, 1, 3, 6, 9, 0x5555555555555555LL, 0xAAAAAAAAAAAAAAAALL, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint16_t) @@ -317,7 +311,6 @@ INPUT_SET(InputSet::BitShiftRhs, 1, 6, 3, 0, 9, 3, 12, 13, 14, 15); INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x5555, 0xAAAA, 0x8000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint32_t) @@ -328,7 +321,6 @@ INPUT_SET(InputSet::BitShiftRhs, 1, 6, 3, 0, 9, 3, 30, 31, 32); INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x55555555, 0xAAAAAAAA, 0x80000000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(uint64_t) @@ -340,7 +332,6 @@ INPUT_SET(InputSet::Bitwise, 0, 1, 3, 6, 9, 0x5555555555555555, 0xAAAAAAAAAAAAAAAA, 0x8000000000000000, 127, std::numeric_limits::max()); INPUT_SET(InputSet::SelectCond, 0, 1); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity()); END_INPUT_SETS() BEGIN_INPUT_SETS(HLSLHalf_t) diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 25bb291d2f..d6d13c0a9f 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1491,12 +1491,6 @@ class DxilConf_SM69_Vectorized { HLK_TEST(ShuffleVector, float); HLK_TEST(ShuffleVector, double); - HLK_TEST(IsFinite, int16_t); - HLK_TEST(IsFinite, int32_t); - HLK_TEST(IsFinite, int64_t); - HLK_TEST(IsFinite, uint16_t); - HLK_TEST(IsFinite, uint32_t); - HLK_TEST(IsFinite, uint64_t); HLK_TEST(IsFinite, HLSLHalf_t); HLK_TEST(IsFinite, float); HLK_TEST(IsFinite, double); @@ -1935,6 +1929,7 @@ class DxilConf_SM69_Vectorized { HLK_TEST(LoadAndStore_RD_SB_SRV, double); HLK_TEST(LoadAndStore_RD_SB_UAV, double); + private: bool Initialized = false; bool VerboseLogging = false; From c51afa99f017cefc107948801ab18eaae70d3d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Mon, 27 Oct 2025 12:15:11 -0700 Subject: [PATCH 08/16] format --- tools/clang/unittests/HLSLExec/LongVectors.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index d6d13c0a9f..472f2fde9d 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1929,7 +1929,6 @@ class DxilConf_SM69_Vectorized { HLK_TEST(LoadAndStore_RD_SB_SRV, double); HLK_TEST(LoadAndStore_RD_SB_UAV, double); - private: bool Initialized = false; bool VerboseLogging = false; From dbbc86810dd14d9b00e775a1692899e749b9c14d Mon Sep 17 00:00:00 2001 From: Joao Saffran Date: Tue, 28 Oct 2025 17:57:48 -0700 Subject: [PATCH 09/16] add weird values --- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index ae28405be6..7e8f985266 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -348,8 +348,9 @@ INPUT_SET(InputSet::RangeOne, 0.331, 0.727, -0.957, 0.677, -0.025, 0.495, 0.855, INPUT_SET(InputSet::Positive, 1.0, 1.0, 342.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); +// HLSLHalf_t cast this to float when assigning it. +INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0, -0.0, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); END_INPUT_SETS() BEGIN_INPUT_SETS(float) @@ -367,7 +368,7 @@ INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f, 0.01f, 331.2330f, 3250.01f); INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f); INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); + -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0f, -0.0f, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0f, 1.0f / 3.0f); END_INPUT_SETS() BEGIN_INPUT_SETS(double) @@ -387,7 +388,8 @@ INPUT_SET(InputSet::Positive, 1.0, 1.0, 65535.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity()); + -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0, -0.0, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); + END_INPUT_SETS() #undef BEGIN_INPUT_SETS From eab4ea4763e0fc0a1b41838a297ff2587cccac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Tue, 28 Oct 2025 18:19:59 -0700 Subject: [PATCH 10/16] remove double --- .../unittests/HLSLExec/LongVectorOps.def | 8 ++--- .../unittests/HLSLExec/LongVectorTestData.h | 29 ++++++++++++++----- .../clang/unittests/HLSLExec/LongVectors.cpp | 6 ++-- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index c7e270f5a0..0baeb27c98 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,7 +18,7 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) -INPUT_SET(Infinite) +INPUT_SET(Float) #undef INPUT_SET @@ -126,6 +126,9 @@ OP_DEFAULT(UnaryMath, Log10, 1, "log10", "") OP_DEFAULT(UnaryMath, Log2, 1, "log2", "") OP_DEFAULT_DEFINES(UnaryMath, Frexp, 1, "TestFrexp", "", " -DFUNC_FREXP=1") +OP(UnaryMath, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", + "LongVectorOp", Float, Default2, Default3) + OP_DEFAULT(BinaryComparison, LessThan, 2, "", "<") OP_DEFAULT(BinaryComparison, LessEqual, 2, "", "<=") OP_DEFAULT(BinaryComparison, GreaterThan, 2, "", ">") @@ -138,9 +141,6 @@ OP_DEFAULT(Binary, Logical_Or, 2, "or", ",") OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) -OP(Unary, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", - "LongVectorOp", Infinite, Default2, Default3) - // For the 'any' and 'all' reduction operation, we test with three different // input data sets to cover the different cases of the operation. 'Any' returns diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 7e8f985266..1d13a22ae7 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -349,8 +349,17 @@ INPUT_SET(InputSet::Positive, 1.0, 1.0, 342.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); // HLSLHalf_t cast this to float when assigning it. -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0, -0.0, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); +INPUT_SET(InputSet::Float, std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), + std::numeric_limits::signaling_NaN(), + -std::numeric_limits::signaling_NaN(), + std::numeric_limits::quiet_NaN(), + -std::numeric_limits::quiet_NaN(), 0.0, -0.0, + std::numeric_limits::min(), std::numeric_limits::max(), + -std::numeric_limits::min(), + -std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); END_INPUT_SETS() BEGIN_INPUT_SETS(float) @@ -367,8 +376,17 @@ INPUT_SET(InputSet::RangeOne, 0.727f, 0.331f, -0.957f, 0.677f, -0.025f, 0.495f, INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f, 0.01f, 331.2330f, 3250.01f); INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0f, -0.0f, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0f, 1.0f / 3.0f); +INPUT_SET(InputSet::Float, std::numeric_limits::infinity(), + -std::numeric_limits::infinity(), + std::numeric_limits::signaling_NaN(), + -std::numeric_limits::signaling_NaN(), + std::numeric_limits::quiet_NaN(), + -std::numeric_limits::quiet_NaN(), 0.0f, -0.0f, + std::numeric_limits::min(), std::numeric_limits::max(), + -std::numeric_limits::min(), + -std::numeric_limits::max(), + std::numeric_limits::denorm_min(), + std::numeric_limits::denorm_min() * 10.0f, 1.0f / 3.0f); END_INPUT_SETS() BEGIN_INPUT_SETS(double) @@ -387,9 +405,6 @@ INPUT_SET(InputSet::SplitDouble, 0.0, -1.0, 1.0, -1.0, 12345678.87654321, -1.0, INPUT_SET(InputSet::Positive, 1.0, 1.0, 65535.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); -INPUT_SET(InputSet::Infinite, std::numeric_limits::infinity(), - -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), std::numeric_limits::quiet_NaN(), -std::numeric_limits::quiet_NaN(), 0.0, -0.0, std::numeric_limits::min(), std::numeric_limits::max(), -std::numeric_limits::min(), -std::numeric_limits::max(), std::numeric_limits::denorm_min(), std::numeric_limits::denorm_min() * 10.0, 1.0 / 3.0); - END_INPUT_SETS() #undef BEGIN_INPUT_SETS diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 472f2fde9d..e2769ad9a5 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1491,9 +1491,6 @@ class DxilConf_SM69_Vectorized { HLK_TEST(ShuffleVector, float); HLK_TEST(ShuffleVector, double); - HLK_TEST(IsFinite, HLSLHalf_t); - HLK_TEST(IsFinite, float); - HLK_TEST(IsFinite, double); // Explicit Cast HLK_TEST(CastToInt16, HLSLBool_t); @@ -1685,6 +1682,9 @@ class DxilConf_SM69_Vectorized { HLK_TEST(Abs, double); HLK_TEST(Sign, double); + HLK_TEST(IsFinite, HLSLHalf_t); + HLK_TEST(IsFinite, float); + // Binary Comparison HLK_TEST(LessThan, int16_t); From a4de02ce01d3cba0fede7b669e3076efac8e3cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Wed, 29 Oct 2025 12:51:58 -0700 Subject: [PATCH 11/16] adding other tests --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 5 ++++- tools/clang/unittests/HLSLExec/LongVectors.cpp | 10 +++++++++- tools/clang/unittests/HLSLExec/ShaderOpArith.xml | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index 0baeb27c98..e552774eef 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -128,6 +128,10 @@ OP_DEFAULT_DEFINES(UnaryMath, Frexp, 1, "TestFrexp", "", " -DFUNC_FREXP=1") OP(UnaryMath, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", "LongVectorOp", Float, Default2, Default3) +OP(UnaryMath, IsInf, 1, "TestIsInf", "", " -DFUNC_TEST_ISINF=1", + "LongVectorOp", Float, Default2, Default3) +OP(UnaryMath, IsNan, 1, "TestIsNan", "", " -DFUNC_TEST_ISNAN=1", + "LongVectorOp", Float, Default2, Default3) OP_DEFAULT(BinaryComparison, LessThan, 2, "", "<") OP_DEFAULT(BinaryComparison, LessEqual, 2, "", "<=") @@ -141,7 +145,6 @@ OP_DEFAULT(Binary, Logical_Or, 2, "or", ",") OP(Ternary, Select, 3, "TestSelect", "", " -DFUNC_TEST_SELECT=1", "LongVectorOp", SelectCond, Default2, Default3) - // For the 'any' and 'all' reduction operation, we test with three different // input data sets to cover the different cases of the operation. 'Any' returns // true if any of the inputs are non-zero, false otherwise. This is in diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index e2769ad9a5..1235bb2806 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1150,7 +1150,9 @@ STRICT_OP_1(OpType::LoadAndStore_RD_SB_SRV, (A)); }; BOOLEAN_FLOAT_OP(OpType::IsFinite, (std::isfinite(A))); - +BOOLEAN_FLOAT_OP(OpType::IsInf, (std::isinf(A))); +BOOLEAN_FLOAT_OP(OpType::IsNan, (std::isnan(A))); +#undef BOOLEAN_FLOAT_OP // // dispatchTest // @@ -1685,6 +1687,12 @@ class DxilConf_SM69_Vectorized { HLK_TEST(IsFinite, HLSLHalf_t); HLK_TEST(IsFinite, float); + HLK_TEST(IsInf, HLSLHalf_t); + HLK_TEST(IsInf, float); + + HLK_TEST(IsNan, HLSLHalf_t); + HLK_TEST(IsNan, float); + // Binary Comparison HLK_TEST(LessThan, int16_t); diff --git a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml index 76e7c3e154..e8912d5d88 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml +++ b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml @@ -4120,6 +4120,22 @@ void MSMain(uint GID : SV_GroupIndex, } #endif + #ifdef FUNC_TEST_ISINF + vector TestIsInf(vector Vector) + { + vector IsInf = isinf(Vector); + return IsInf; + } + #endif + + #ifdef FUNC_TEST_ISNAN + vector TestIsNan(vector Vector) + { + vector IsNan = isnan(Vector); + return IsNan; + } + #endif + #ifdef FUNC_SHUFFLE_VECTOR vector TestShuffleVector(TYPE Scalar) { From 57a6be99560a384270f741d6dc0ad57bddc411f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Wed, 29 Oct 2025 13:26:27 -0700 Subject: [PATCH 12/16] rename input set --- tools/clang/unittests/HLSLExec/LongVectorOps.def | 8 ++++---- tools/clang/unittests/HLSLExec/LongVectorTestData.h | 4 ++-- tools/clang/unittests/HLSLExec/LongVectors.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index e552774eef..a8498d6b35 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -18,7 +18,7 @@ INPUT_SET(NoZero) INPUT_SET(Positive) INPUT_SET(Bitwise) INPUT_SET(SelectCond) -INPUT_SET(Float) +INPUT_SET(FloatSpecial) #undef INPUT_SET @@ -127,11 +127,11 @@ OP_DEFAULT(UnaryMath, Log2, 1, "log2", "") OP_DEFAULT_DEFINES(UnaryMath, Frexp, 1, "TestFrexp", "", " -DFUNC_FREXP=1") OP(UnaryMath, IsFinite, 1, "TestIsFinite", "", " -DFUNC_TEST_ISFINITE=1", - "LongVectorOp", Float, Default2, Default3) + "LongVectorOp", FloatSpecial, Default2, Default3) OP(UnaryMath, IsInf, 1, "TestIsInf", "", " -DFUNC_TEST_ISINF=1", - "LongVectorOp", Float, Default2, Default3) + "LongVectorOp", FloatSpecial, Default2, Default3) OP(UnaryMath, IsNan, 1, "TestIsNan", "", " -DFUNC_TEST_ISNAN=1", - "LongVectorOp", Float, Default2, Default3) + "LongVectorOp", FloatSpecial, Default2, Default3) OP_DEFAULT(BinaryComparison, LessThan, 2, "", "<") OP_DEFAULT(BinaryComparison, LessEqual, 2, "", "<=") diff --git a/tools/clang/unittests/HLSLExec/LongVectorTestData.h b/tools/clang/unittests/HLSLExec/LongVectorTestData.h index 1d13a22ae7..92b0b97811 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorTestData.h +++ b/tools/clang/unittests/HLSLExec/LongVectorTestData.h @@ -349,7 +349,7 @@ INPUT_SET(InputSet::Positive, 1.0, 1.0, 342.0, 0.01, 5531.0, 0.01, 1.0, 0.01, 331.2330, 3250.01); INPUT_SET(InputSet::SelectCond, 0.0, 1.0); // HLSLHalf_t cast this to float when assigning it. -INPUT_SET(InputSet::Float, std::numeric_limits::infinity(), +INPUT_SET(InputSet::FloatSpecial, std::numeric_limits::infinity(), -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), @@ -376,7 +376,7 @@ INPUT_SET(InputSet::RangeOne, 0.727f, 0.331f, -0.957f, 0.677f, -0.025f, 0.495f, INPUT_SET(InputSet::Positive, 1.0f, 1.0f, 65535.0f, 0.01f, 5531.0f, 0.01f, 1.0f, 0.01f, 331.2330f, 3250.01f); INPUT_SET(InputSet::SelectCond, 0.0f, 1.0f); -INPUT_SET(InputSet::Float, std::numeric_limits::infinity(), +INPUT_SET(InputSet::FloatSpecial, std::numeric_limits::infinity(), -std::numeric_limits::infinity(), std::numeric_limits::signaling_NaN(), -std::numeric_limits::signaling_NaN(), diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 1235bb2806..9bc3a7d5d6 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1144,15 +1144,15 @@ STRICT_OP_1(OpType::LoadAndStore_RD_SB_SRV, (A)); // Float Ops // -#define BOOLEAN_FLOAT_OP(OP, IMPL) \ +#define FLOAT_SPECIAL_OP(OP, IMPL) \ template struct Op : StrictValidation { \ HLSLBool_t operator()(T A) { return IMPL; } \ }; -BOOLEAN_FLOAT_OP(OpType::IsFinite, (std::isfinite(A))); -BOOLEAN_FLOAT_OP(OpType::IsInf, (std::isinf(A))); -BOOLEAN_FLOAT_OP(OpType::IsNan, (std::isnan(A))); -#undef BOOLEAN_FLOAT_OP +FLOAT_SPECIAL_OP(OpType::IsFinite, (std::isfinite(A))); +FLOAT_SPECIAL_OP(OpType::IsInf, (std::isinf(A))); +FLOAT_SPECIAL_OP(OpType::IsNan, (std::isnan(A))); +#undef FLOAT_SPECIAL_OP // // dispatchTest // From 66bd46b8158fd8a7f4efcf0ceae0bdcfd0dc5b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Wed, 29 Oct 2025 15:46:01 -0700 Subject: [PATCH 13/16] adding modf test --- .../unittests/HLSLExec/LongVectorOps.def | 3 ++ .../clang/unittests/HLSLExec/LongVectors.cpp | 47 +++++++++++++++++++ .../unittests/HLSLExec/ShaderOpArith.xml | 26 ++++++++++ 3 files changed, 76 insertions(+) diff --git a/tools/clang/unittests/HLSLExec/LongVectorOps.def b/tools/clang/unittests/HLSLExec/LongVectorOps.def index a8498d6b35..ba3779c807 100644 --- a/tools/clang/unittests/HLSLExec/LongVectorOps.def +++ b/tools/clang/unittests/HLSLExec/LongVectorOps.def @@ -132,6 +132,9 @@ OP(UnaryMath, IsInf, 1, "TestIsInf", "", " -DFUNC_TEST_ISINF=1", "LongVectorOp", FloatSpecial, Default2, Default3) OP(UnaryMath, IsNan, 1, "TestIsNan", "", " -DFUNC_TEST_ISNAN=1", "LongVectorOp", FloatSpecial, Default2, Default3) +OP(UnaryMath, ModF, 1, "TestModF", "", " -DFUNC_TEST_MODF=1", + "LongVectorOp", Default1, Default2, Default3) + OP_DEFAULT(BinaryComparison, LessThan, 2, "", "<") OP_DEFAULT(BinaryComparison, LessEqual, 2, "", "<=") diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 9bc3a7d5d6..8e5ecf79a1 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1,3 +1,5 @@ +#include +#include #ifndef NOMINMAX #define NOMINMAX 1 #endif @@ -1153,6 +1155,47 @@ FLOAT_SPECIAL_OP(OpType::IsFinite, (std::isfinite(A))); FLOAT_SPECIAL_OP(OpType::IsInf, (std::isinf(A))); FLOAT_SPECIAL_OP(OpType::IsNan, (std::isnan(A))); #undef FLOAT_SPECIAL_OP + +template struct Op : DefaultValidation {}; + +template <> struct ExpectedBuilder { + static std::vector buildExpected(Op, + const InputSets &Inputs) { + DXASSERT_NOMSG(Inputs.size() == 1); + size_t VectorSize = Inputs[0].size(); + std::vector Expected; + Expected.resize(VectorSize * 2); + for (size_t I = 0; I < VectorSize; ++I) { + float Exp = 0; + float Man = std::modf(Inputs[0][I], &Exp); + Expected[I] = Man; + Expected[I + VectorSize] = static_cast(Exp); + } + + return Expected; + } +}; + +template <> struct ExpectedBuilder { + static std::vector buildExpected(Op, + const InputSets &Inputs) { + DXASSERT_NOMSG(Inputs.size() == 1); + size_t VectorSize = Inputs[0].size(); + std::vector Expected; + Expected.resize(VectorSize * 2); + for (size_t I = 0; I < VectorSize; ++I) { + 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); + } + + return Expected; + } +}; + + // // dispatchTest // @@ -1693,6 +1736,10 @@ class DxilConf_SM69_Vectorized { HLK_TEST(IsNan, HLSLHalf_t); HLK_TEST(IsNan, float); + + HLK_TEST(ModF, HLSLHalf_t); + HLK_TEST(ModF, float); + // Binary Comparison HLK_TEST(LessThan, int16_t); diff --git a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml index e8912d5d88..36ce184e97 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml +++ b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml @@ -4136,6 +4136,32 @@ void MSMain(uint GID : SV_GroupIndex, } #endif + #ifdef FUNC_TEST_MODF + vector TestModF(vector Vector) + { + vector Mantissa; + vector Exponent; + + Mantissa = modf(Vector, Exponent); + + g_OutputVector.Store< vector >(2 * NUM, Exponent); + + return Mantissa; + } + + vector TestModF(vector Vector) + { + vector Mantissa; + vector Exponent; + + Mantissa = modf(Vector, Exponent); + + g_OutputVector.Store< vector >(4 * NUM, Exponent); + + return Mantissa; + } + #endif + #ifdef FUNC_SHUFFLE_VECTOR vector TestShuffleVector(TYPE Scalar) { From b5c78afde0aeee8ecdfb7888ea8050c145c4e4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Thu, 30 Oct 2025 11:31:35 -0700 Subject: [PATCH 14/16] adding macro --- .../clang/unittests/HLSLExec/LongVectors.cpp | 112 +++++++----------- 1 file changed, 41 insertions(+), 71 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/LongVectors.cpp b/tools/clang/unittests/HLSLExec/LongVectors.cpp index 63e01b022e..be5c2053ae 100644 --- a/tools/clang/unittests/HLSLExec/LongVectors.cpp +++ b/tools/clang/unittests/HLSLExec/LongVectors.cpp @@ -1,5 +1,3 @@ -#include -#include #ifndef NOMINMAX #define NOMINMAX 1 #endif @@ -105,6 +103,21 @@ static constexpr Operation Operations[] = { #include "LongVectorOps.def" }; +#define OP_WITH_OUT_PARAM(OPERATION, TYPE, IMPL) \ + template <> struct ExpectedBuilder { \ + static std::vector buildExpected(Op, \ + const InputSets &Inputs) { \ + DXASSERT_NOMSG(Inputs.size() == 1); \ + size_t VectorSize = Inputs[0].size(); \ + std::vector 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)]; @@ -1017,41 +1030,21 @@ DEFAULT_OP_1(OpType::Log2, (std::log2(A))); // with special logic. Frexp is only supported for fp32 values. template <> struct Op : DefaultValidation {}; -template <> struct ExpectedBuilder { - static std::vector buildExpected(Op &, - const InputSets &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. - - size_t VectorSize = Inputs[0].size(); - - std::vector Expected; - Expected.resize(VectorSize * 2); - - for (size_t I = 0; I < VectorSize; ++I) { - int Exp = 0; - float Man = std::frexp(Inputs[0][I], &Exp); +OP_WITH_OUT_PARAM(Frexp, float, { + 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(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(Exp); +}); // // Binary Comparison @@ -1240,43 +1233,20 @@ FLOAT_SPECIAL_OP(OpType::IsNan, (std::isnan(A))); template struct Op : DefaultValidation {}; -template <> struct ExpectedBuilder { - static std::vector buildExpected(Op, - const InputSets &Inputs) { - DXASSERT_NOMSG(Inputs.size() == 1); - size_t VectorSize = Inputs[0].size(); - std::vector Expected; - Expected.resize(VectorSize * 2); - for (size_t I = 0; I < VectorSize; ++I) { - float Exp = 0; - float Man = std::modf(Inputs[0][I], &Exp); - Expected[I] = Man; - Expected[I + VectorSize] = static_cast(Exp); - } - - return Expected; - } -}; - -template <> struct ExpectedBuilder { - static std::vector buildExpected(Op, - const InputSets &Inputs) { - DXASSERT_NOMSG(Inputs.size() == 1); - size_t VectorSize = Inputs[0].size(); - std::vector Expected; - Expected.resize(VectorSize * 2); - for (size_t I = 0; I < VectorSize; ++I) { - 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); - } - - return Expected; - } -}; - +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 From 0aa2c1ec134228dd77a3946e8b4ee56998315ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Thu, 30 Oct 2025 11:38:07 -0700 Subject: [PATCH 15/16] using sizeof --- tools/clang/unittests/HLSLExec/ShaderOpArith.xml | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml index 36ce184e97..0121d2b0bf 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml +++ b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml @@ -4137,26 +4137,14 @@ void MSMain(uint GID : SV_GroupIndex, #endif #ifdef FUNC_TEST_MODF - vector TestModF(vector Vector) + vector TestModF(vector Vector) { vector Mantissa; vector Exponent; Mantissa = modf(Vector, Exponent); - g_OutputVector.Store< vector >(2 * NUM, Exponent); - - return Mantissa; - } - - vector TestModF(vector Vector) - { - vector Mantissa; - vector Exponent; - - Mantissa = modf(Vector, Exponent); - - g_OutputVector.Store< vector >(4 * NUM, Exponent); + g_OutputVector.Store< vector >(sizeof(OUT_TYPE) * NUM, Exponent); return Mantissa; } From 17786f176ea43e23ab1722a22d7d1d7d6ad03497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Saffran?= Date: Thu, 30 Oct 2025 11:39:25 -0700 Subject: [PATCH 16/16] removing merge error --- .../unittests/HLSLExec/ShaderOpArith.xml | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml index 0121d2b0bf..43fe5d6412 100644 --- a/tools/clang/unittests/HLSLExec/ShaderOpArith.xml +++ b/tools/clang/unittests/HLSLExec/ShaderOpArith.xml @@ -4112,30 +4112,6 @@ void MSMain(uint GID : SV_GroupIndex, } #endif - #ifdef FUNC_TEST_ISFINITE - vector TestIsFinite(vector Vector) - { - vector IsFinite = isfinite(Vector); - return IsFinite; - } - #endif - - #ifdef FUNC_TEST_ISINF - vector TestIsInf(vector Vector) - { - vector IsInf = isinf(Vector); - return IsInf; - } - #endif - - #ifdef FUNC_TEST_ISNAN - vector TestIsNan(vector Vector) - { - vector IsNan = isnan(Vector); - return IsNan; - } - #endif - #ifdef FUNC_TEST_MODF vector TestModF(vector Vector) {