Allow RTE and RTZ for float16 derivative test
authorPeter Deayton <pdeayton@nvidia.com>
Thu, 15 Nov 2018 18:25:58 +0000 (10:25 -0800)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 29 Nov 2018 09:22:08 +0000 (04:22 -0500)
The result of the test may not be representable exactly in a float16.
Allow both round to nearest even and round to zero as valid results.

Components: Vulkan

VK-GL-CTS issue: 1482

Affects:
dEQP-VK.spirv_assembly.instruction.graphics.float16.derivative_*

Change-Id: I7add6f5fc0888897fbb374fb8e5576f7c1284bc3

external/vulkancts/modules/vulkan/spirv_assembly/vktSpvAsmInstructionTests.cpp

index ccbd2cb..9fc51dd 100644 (file)
@@ -10123,10 +10123,19 @@ bool compareDerivativeWithFlavor (const deFloat16* inputAsFP16, const deFloat16*
        for (deUint32 x = 0; x < numDataPointsByAxis; ++x)
        for (deUint32 n = 0; n < N; ++n)
        {
-               const deFloat16 expected        = tcu::Float16(derivativeFunc(inputAsFP16, x, y, n, flavor)).bits();
-               const deFloat16 output          = outputAsFP16[getOffset<R, N>(x, y, n)];
+               const float             expectedFloat   = derivativeFunc(inputAsFP16, x, y, n, flavor);
+               deFloat16               expected                = deFloat32To16Round(expectedFloat, DE_ROUNDINGMODE_TO_NEAREST_EVEN);
+               const deFloat16 output                  = outputAsFP16[getOffset<R, N>(x, y, n)];
 
-               if (!compare16BitFloat(expected, output, error))
+               bool                    reportError             = !compare16BitFloat(expected, output, error);
+
+               if (reportError)
+               {
+                       expected        = deFloat32To16Round(expectedFloat, DE_ROUNDINGMODE_TO_ZERO);
+                       reportError     = !compare16BitFloat(expected, output, error);
+               }
+
+               if (reportError)
                {
                        error = "subcase at " + de::toString(x) + "," + de::toString(y) + "," + de::toString(n) + ": " + error;