Skip to content
Draft
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectorOps.def
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ INPUT_SET(NoZero)
INPUT_SET(Positive)
INPUT_SET(Bitwise)
INPUT_SET(SelectCond)
INPUT_SET(Float)

#undef INPUT_SET

Expand Down Expand Up @@ -125,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, "", ">")
Expand All @@ -137,6 +141,7 @@ 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
Expand Down
23 changes: 23 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectorTestData.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,18 @@ 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);
// HLSLHalf_t cast this to float when assigning it.
INPUT_SET(InputSet::Float, std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::signaling_NaN(),
-std::numeric_limits<float>::signaling_NaN(),
std::numeric_limits<float>::quiet_NaN(),
-std::numeric_limits<float>::quiet_NaN(), 0.0, -0.0,
std::numeric_limits<float>::min(), std::numeric_limits<float>::max(),
-std::numeric_limits<float>::min(),
-std::numeric_limits<float>::max(),
std::numeric_limits<float>::denorm_min(),
std::numeric_limits<float>::denorm_min() * 10.0, 1.0 / 3.0);
END_INPUT_SETS()

BEGIN_INPUT_SETS(float)
Expand All @@ -364,6 +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::Float, std::numeric_limits<float>::infinity(),
-std::numeric_limits<float>::infinity(),
std::numeric_limits<float>::signaling_NaN(),
-std::numeric_limits<float>::signaling_NaN(),
std::numeric_limits<float>::quiet_NaN(),
-std::numeric_limits<float>::quiet_NaN(), 0.0f, -0.0f,
std::numeric_limits<float>::min(), std::numeric_limits<float>::max(),
-std::numeric_limits<float>::min(),
-std::numeric_limits<float>::max(),
std::numeric_limits<float>::denorm_min(),
std::numeric_limits<float>::denorm_min() * 10.0f, 1.0f / 3.0f);
END_INPUT_SETS()

BEGIN_INPUT_SETS(double)
Expand Down
14 changes: 14 additions & 0 deletions tools/clang/unittests/HLSLExec/LongVectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this macro will be helpful for the other float ops we're adding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"boolean float op" sounds a bit contradictory.

I think we're doing a bunch of "float specials" here, I wonder if it would make sense to group them in that way?

template <typename T> struct Op<OP, T, 1> : StrictValidation { \
HLSLBool_t operator()(T A) { return IMPL; } \
};

BOOLEAN_FLOAT_OP(OpType::IsFinite, (std::isfinite(A)));

//
// dispatchTest
//
Expand Down Expand Up @@ -1671,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);
Expand Down
8 changes: 8 additions & 0 deletions tools/clang/unittests/HLSLExec/ShaderOpArith.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4112,6 +4112,14 @@ void MSMain(uint GID : SV_GroupIndex,
}
#endif
#ifdef FUNC_TEST_ISFINITE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this really be something like "FLOAT_SPECIALS" and have another define choose between isinifite, isinf and isnan?

vector<OUT_TYPE, NUM> TestIsFinite(vector<TYPE, NUM> Vector)
{
vector<bool, NUM> IsFinite = isfinite(Vector);
return IsFinite;
}
#endif
#ifdef FUNC_SHUFFLE_VECTOR
vector<OUT_TYPE, NUM> TestShuffleVector(TYPE Scalar)
{
Expand Down