Browse Source

Adding test fixes and more support for SM6.5 WaveMultiPrefix functions (#2421)

* Adding test fixes and more support for SM6.5 WaveMultiPrefix functions

1)	Ensure wave lane-id’s are sorted when accumulating result
2)	Fix made for HLSL in ShaderOpArithTable.xml to ensure the input aligns with what is being tested
3)	Added support for the “UBit” version for all of these tests.
Alex Paige 6 years ago
parent
commit
cad61c1978

+ 25 - 9
tools/clang/unittests/HLSL/ExecutionTest.cpp

@@ -6174,10 +6174,14 @@ static T GetWaveMultiPrefixInitialAccumValue(LPCWSTR testName) {
   } else if (_wcsicmp(testName, L"WaveMultiPrefixSum") == 0 ||
   } else if (_wcsicmp(testName, L"WaveMultiPrefixSum") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixUSum") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixUSum") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixBitOr") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixBitOr") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUBitOr") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixBitXor") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixBitXor") == 0 ||
-             _wcsicmp(testName, L"WaveMultiPrefixCountBits") == 0) {
+             _wcsicmp(testName, L"WaveMultiPrefixUBitXor") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixCountBits") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUCountBits") == 0) {
     return static_cast<T>(0);
     return static_cast<T>(0);
-  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitAnd") == 0) {
+  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitAnd") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUBitAnd") == 0) {
     return static_cast<T>(-1);
     return static_cast<T>(-1);
   } else {
   } else {
     return static_cast<T>(0);
     return static_cast<T>(0);
@@ -6192,17 +6196,21 @@ std::function<T(T, T)> GetWaveMultiPrefixReferenceFunction(LPCWSTR testName) {
   } else if (_wcsicmp(testName, L"WaveMultiPrefixSum") == 0 ||
   } else if (_wcsicmp(testName, L"WaveMultiPrefixSum") == 0 ||
              _wcsicmp(testName, L"WaveMultiPrefixUSum") == 0) {
              _wcsicmp(testName, L"WaveMultiPrefixUSum") == 0) {
     return [] (T lhs, T rhs) -> T { return lhs + rhs; };
     return [] (T lhs, T rhs) -> T { return lhs + rhs; };
-  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitAnd") == 0) {
+  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitAnd") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUBitAnd") == 0) {
     return [] (T lhs, T rhs) -> T { return lhs & rhs; };
     return [] (T lhs, T rhs) -> T { return lhs & rhs; };
-  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitOr") == 0) {
+  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitOr") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUBitOr") == 0) {
     return [] (T lhs, T rhs) -> T { return lhs | rhs; };
     return [] (T lhs, T rhs) -> T { return lhs | rhs; };
-  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitXor") == 0) {
+  } else if (_wcsicmp(testName, L"WaveMultiPrefixBitXor") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUBitXor") == 0) {
     return [] (T lhs, T rhs) -> T { return lhs ^ rhs; };
     return [] (T lhs, T rhs) -> T { return lhs ^ rhs; };
-  } else if (_wcsicmp(testName, L"WaveMultiPrefixCountBits") == 0) {
+  } else if (_wcsicmp(testName, L"WaveMultiPrefixCountBits") == 0 ||
+             _wcsicmp(testName, L"WaveMultiPrefixUCountBits") == 0) {
     // For CountBits, each lane contributes a boolean value. The test input is
     // For CountBits, each lane contributes a boolean value. The test input is
-    // an integer, so convert to a boolean by computing (input > 10) If this
-    // condition is true, we contribute one to the bit count.
-    return [] (T lhs, T rhs) -> T { return lhs + (rhs > 10 ? 1 : 0); };
+    // a zero or non-zero integer. If the input is a non-zero value then the
+    // condition is true, thus we contribute one to the bit count.
+    return [] (T lhs, T rhs) -> T { return lhs + (rhs ? 1 : 0); };
   } else {
   } else {
     return [] (T lhs, T rhs) -> T { return 0; };
     return [] (T lhs, T rhs) -> T { return 0; };
   }
   }
@@ -6304,6 +6312,14 @@ ExecutionTest::WaveIntrinsicsMultiPrefixOpTest(TableParameter *pParameterList,
 
 
     for (auto &w : waves) {
     for (auto &w : waves) {
       std::vector<PerThreadData *> &waveData = w.second;
       std::vector<PerThreadData *> &waveData = w.second;
+      
+      struct {
+        bool operator()(PerThreadData *a, PerThreadData *b) const {
+          return (a->laneId < b->laneId);
+        }
+      } compare;
+	  // Need to sort based on the lane id
+      std::sort(waveData.begin(), waveData.end(), compare);
 
 
       LogCommentFmt(L"LaneId    Mask      Key       Value     Result    Expected");
       LogCommentFmt(L"LaneId    Mask      Key       Value     Result    Expected");
       LogCommentFmt(L"--------  --------  --------  --------  --------  --------");
       LogCommentFmt(L"--------  --------  --------  --------  --------  --------");

+ 8 - 8
tools/clang/unittests/HLSL/ShaderOpArithTable.xml

@@ -6145,16 +6145,16 @@
                 <Value>4</Value>
                 <Value>4</Value>
             </Parameter>
             </Parameter>
             <Parameter Name="Validation.Values">
             <Parameter Name="Validation.Values">
-                <Value>10</Value>
+                <Value>0</Value>
                 <Value>42</Value>
                 <Value>42</Value>
-                <Value>1</Value>
+                <Value>0</Value>
                 <Value>64</Value>
                 <Value>64</Value>
                 <Value>11</Value>
                 <Value>11</Value>
                 <Value>76</Value>
                 <Value>76</Value>
                 <Value>90</Value>
                 <Value>90</Value>
                 <Value>111</Value>
                 <Value>111</Value>
-                <Value>9</Value>
-                <Value>6</Value>
+                <Value>0</Value>
+                <Value>0</Value>
                 <Value>79</Value>
                 <Value>79</Value>
                 <Value>34</Value>
                 <Value>34</Value>
             </Parameter>
             </Parameter>
@@ -6633,16 +6633,16 @@
                 <Value>4</Value>
                 <Value>4</Value>
             </Parameter>
             </Parameter>
             <Parameter Name="Validation.Values">
             <Parameter Name="Validation.Values">
-                <Value>10</Value>
+                <Value>0</Value>
                 <Value>42</Value>
                 <Value>42</Value>
-                <Value>1</Value>
+                <Value>0</Value>
                 <Value>64</Value>
                 <Value>64</Value>
                 <Value>11</Value>
                 <Value>11</Value>
                 <Value>76</Value>
                 <Value>76</Value>
                 <Value>90</Value>
                 <Value>90</Value>
                 <Value>111</Value>
                 <Value>111</Value>
-                <Value>9</Value>
-                <Value>6</Value>
+                <Value>0</Value>
+                <Value>0</Value>
                 <Value>79</Value>
                 <Value>79</Value>
                 <Value>34</Value>
                 <Value>34</Value>
             </Parameter>
             </Parameter>

+ 2 - 2
utils/hct/hctdb_test.py

@@ -1393,7 +1393,7 @@ def add_test_cases():
          [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
          [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
         'cs_6_5', get_shader_text("wave op multi prefix int", "WaveMultiPrefixProduct"))
         'cs_6_5', get_shader_text("wave op multi prefix int", "WaveMultiPrefixProduct"))
     add_test_case('WaveMultiPrefixCountBits', ['WaveMultiPrefixOp'], 'Epsilon', 0,
     add_test_case('WaveMultiPrefixCountBits', ['WaveMultiPrefixOp'], 'Epsilon', 0,
-         [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
+         [['0', '3', '1', '5', '4'], ['0', '42', '0', '64', '11', '76', '90', '111', '0', '0', '79', '34']], [],
         'cs_6_5', get_shader_text("wave op multi prefix int", "WaveMultiPrefixCountBits"))
         'cs_6_5', get_shader_text("wave op multi prefix int", "WaveMultiPrefixCountBits"))
 
 
     add_test_case('WaveMultiPrefixUBitAnd', ['WaveMultiPrefixOp'], 'Epsilon', 0,
     add_test_case('WaveMultiPrefixUBitAnd', ['WaveMultiPrefixOp'], 'Epsilon', 0,
@@ -1412,7 +1412,7 @@ def add_test_cases():
          [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
          [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
         'cs_6_5', get_shader_text("wave op multi prefix uint", "WaveMultiPrefixProduct"))
         'cs_6_5', get_shader_text("wave op multi prefix uint", "WaveMultiPrefixProduct"))
     add_test_case('WaveMultiPrefixUCountBits', ['WaveMultiPrefixOp'], 'Epsilon', 0,
     add_test_case('WaveMultiPrefixUCountBits', ['WaveMultiPrefixOp'], 'Epsilon', 0,
-         [['0', '3', '1', '5', '4'], ['10', '42', '1', '64', '11', '76', '90', '111', '9', '6', '79', '34']], [],
+         [['0', '3', '1', '5', '4'], ['0', '42', '0', '64', '11', '76', '90', '111', '0', '0', '79', '34']], [],
         'cs_6_5', get_shader_text("wave op multi prefix uint", "WaveMultiPrefixCountBits"))
         'cs_6_5', get_shader_text("wave op multi prefix uint", "WaveMultiPrefixCountBits"))