Browse Source

ExecutionTest fixes (#249)

- allow operations to flush denorms to sign-preserved zero
- Fix line ending issue for ExecutionTest
- Add else statement for WaveActiveCounBits
Young Kim 8 years ago
parent
commit
543faf9a20

File diff suppressed because it is too large
+ 1350 - 1350
tools/clang/unittests/HLSL/ExecutionTest.cpp


+ 27 - 0
tools/clang/unittests/HLSL/HlslTestUtils.h

@@ -182,10 +182,34 @@ inline bool GetTestParamUseWARP(bool defaultVal) {
 
 
 }
 }
 
 
+inline bool isdenorm(float f) {
+  return FP_SUBNORMAL == fpclassify(f);
+}
+
+inline bool isdenorm(double d) {
+  return FP_SUBNORMAL == fpclassify(d);
+}
+
+inline float ifdenorm_flushf(float a) {
+  return isdenorm(a) ? copysign(0.0f, a) : a;
+}
+
+inline bool ifdenorm_flushf_eq(float a, float b) {
+  return ifdenorm_flushf(a) == ifdenorm_flushf(b);
+}
+
+inline bool ifdenorm_flushf_eq_or_nans(float a, float b) {
+  if (isnan(a) && isnan(b)) return true;
+  return ifdenorm_flushf(a) == ifdenorm_flushf(b);
+}
+
 inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPTolerance) {
 inline bool CompareFloatULP(const float &fsrc, const float &fref, int ULPTolerance) {
     if (isnan(fsrc)) {
     if (isnan(fsrc)) {
         return isnan(fref);
         return isnan(fref);
     }
     }
+    if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
+        return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
+    }
     if (fsrc == fref) {
     if (fsrc == fref) {
         return true;
         return true;
     }
     }
@@ -198,6 +222,9 @@ inline bool CompareFloatEpsilon(const float &fsrc, const float &fref, float epsi
     if (isnan(fsrc)) {
     if (isnan(fsrc)) {
         return isnan(fref);
         return isnan(fref);
     }
     }
+    if (isdenorm(fref)) { // Arithmetic operations of denorm may flush to sign-preserved zero
+        return (isdenorm(fsrc) || fsrc == 0) && (signbit(fsrc) == signbit(fref));
+    }
     return fsrc == fref || fabsf(fsrc - fref) < epsilon;
     return fsrc == fref || fabsf(fsrc - fref) < epsilon;
 }
 }
 
 

+ 3 - 0
tools/clang/unittests/HLSL/ShaderOpArithTable.xml

@@ -2512,6 +2512,9 @@
                         if (pts.mask != 0) {
                         if (pts.mask != 0) {
                             pts.output = WaveActiveCountBits(pts.input > 3);
                             pts.output = WaveActiveCountBits(pts.input > 3);
                         }
                         }
+                        else {
+                            pts.output = WaveActiveCountBits(pts.input > 3);
+                        }
                         g_sb[GI] = pts;
                         g_sb[GI] = pts;
                     }
                     }
                 ]]>
                 ]]>

Some files were not shown because too many files changed in this diff