[Piglit] [PATCH 5/5] cl: Add missing math tests

Jan Vesely jano.vesely at gmail.com
Sun Oct 1 20:10:17 UTC 2017


Basic tests. All new tests, but sincos pass on beignet(SKL) (sin/cos
tests fail on beignet)

Signed-off-by: Jan Vesely <jano.vesely at gmail.com>
---
 generated_tests/gen_cl_math_builtins.py | 283 +++++++++++++++++++++++++++++++-
 1 file changed, 280 insertions(+), 3 deletions(-)

diff --git a/generated_tests/gen_cl_math_builtins.py b/generated_tests/gen_cl_math_builtins.py
index 31e0e9750..7f67b7b17 100644
--- a/generated_tests/gen_cl_math_builtins.py
+++ b/generated_tests/gen_cl_math_builtins.py
@@ -27,8 +27,8 @@ from __future__ import print_function, division, absolute_import
 import os
 
 from genclbuiltins import gen, NEGNAN
-from math import acos, acosh, asin, asinh, atan, atan2, atanh, cos, cosh, exp
-from math import fabs, fmod, log10, log1p, pi, pow, sin, sinh, sqrt, tan, tanh
+from math import acos, acosh, asin, asinh, atan, atan2, atanh, cos, cosh, exp, expm1
+from math import fabs, fmod, gamma, hypot, lgamma, log, log10, log1p, modf, pi, pow, sin, sinh, sqrt, tan, tanh
 
 CLC_VERSION_MIN = {
     'acos' : 10,
@@ -51,27 +51,52 @@ CLC_VERSION_MIN = {
     'erf' : 10,
     'erfc' : 10,
     'exp' : 10,
+    'exp10' : 10,
+    'exp2' : 10,
+    'expm1' : 10,
     'fabs' : 10,
     'fdim' : 10,
     'floor' : 10,
+    'fma' : 10,
     'fmax' : 10,
     'fmin' : 10,
     'fmod' : 10,
     'fract' : 10,
     'frexp' : 10,
+    'hypot' : 10,
     'ilogb' : 10,
     'ldexp' : 10,
+    'lgamma' : 10,
+    'lgamma_r' : 10,
+    'log' : 10,
     'log10' : 10,
     'log1p' : 10,
+    'log2' : 10,
+    'logb' : 10,
+    'nan' : 10,
+    'mad' : 10,
+    'maxmag' : 11,
+    'minmag' : 11,
+    'modf' : 10,
     'nextafter' : 10,
+    'pow' : 10,
+    'pown' : 10,
+    'powr' : 10,
     'remainder' : 10,
+    'remquo' : 10,
+    'rint' : 10,
+    'rootn' : 10,
     'round' : 10,
+    'rsqrt' : 10,
     'sin' : 10,
+    'sincos' : 10,
     'sinh' : 10,
     'sinpi' : 10,
+    'sqrt' : 10,
     'tan' : 10,
     'tanh' : 10,
-    'sqrt' : 10,
+    'tanpi' : 10,
+    'tgamma' : 10,
     'trunc' : 10
 }
 
@@ -85,6 +110,13 @@ I = {
     'float' : 'int'
 }
 
+U = {
+    'float' : 'uint'
+}
+
+def quo(x, y):
+    return int(round(x/y))
+
 tests = {
     'acos' : {
         'arg_types' : [F, F],
@@ -267,6 +299,33 @@ tests = {
         ],
         'tolerance' : 3
     },
+    'exp10' : {
+        'arg_types' : [F, F],
+        'function_type': 'ttt',
+        'values' : [
+            [1.0,  10 ** 0.95, 10 ** pi, 10 ** -pi, float("inf"), float.fromhex('0x1.4298593c335e3p+10')], # Result
+            [0.0, 0.95, pi, -pi, float("inf"), float.fromhex('0x1.8e2cp+1')]  # Arg0
+        ],
+        'tolerance' : 3
+    },
+    'exp2' : {
+        'arg_types' : [F, F],
+        'function_type': 'ttt',
+        'values' : [
+            [1.0,  2 ** 0.95, 2 ** pi, 2 ** -pi, float("inf"), float.fromhex('0x1.146b7fd8431e3p+3')], # Result
+            [0.0, 0.95, pi, -pi, float("inf"), float.fromhex('0x1.8e2cp+1')]  # Arg0
+        ],
+        'tolerance' : 3
+    },
+    'expm1' : {
+        'arg_types' : [F, F],
+        'function_type': 'ttt',
+        'values' : [
+            [0.0, expm1(0.95), expm1(pi), expm1(-pi), float("inf"), float.fromhex('0x1.56fe8a160893ep+4')], # Result
+            [0.0, 0.95, pi, -pi, float("inf"), float.fromhex('0x1.8e2cp+1')]  # Arg0
+        ],
+        'tolerance' : 3
+    },
     'fabs' : {
         'arg_types' : [F, F],
         'function_type': 'ttt',
@@ -293,6 +352,16 @@ tests = {
             [0.5, -0.5, 0.0, -0.0, float("nan"), -3.99, 1.5]
         ]
     },
+    'fma' : {
+        'arg_types': [F, F, F, F],
+        'function_type': 'tss',
+        'values': [
+            [pi,   1.0, pi , -0.5, float("nan"), float("nan"), float("nan")], # Result
+            [1.0,   pi, 0.0,  0.0, 1.0, float("nan"), float("nan")], # Arg0
+            [pi,   0.0, pi,  -0.5, float("nan"), 1.0, float("nan")], # Arg1
+            [0.0,  1.0, pi,  -0.5, float("nan"), 1.0, float("nan")]  # Arg2
+        ]
+    },
     'fmax' : {
         'arg_types': [F, F, F],
         'function_type': 'tss',
@@ -343,6 +412,16 @@ tests = {
         ],
        'num_out_args' : 2
     },
+    'hypot' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [hypot(0, 1.0), hypot(3, 10.0), hypot(1, -3.0), hypot(10, 1234.5), hypot(2147483647, -1.0), float("inf")], # Result
+            [0,      3,    1,     10, 2147483647,    2147483647], # Arg0
+            [1.0, 10.0, -3.0, 1234.5,       -1.0, float("-inf")] # Arg1
+        ],
+        'tolerance' : 4
+    },
     'ilogb' : {
         'arg_types': [I, F],
         'function_type': 'ttt',
@@ -362,6 +441,35 @@ tests = {
         ],
         'tolerance' : 0
     },
+    'lgamma' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, lgamma(1.5), lgamma(0.5), float("nan"), lgamma(1.e-15), float("nan")], # Result
+            [1.0, 1.5, 0.5,        0.0,           1.e-15,        float("nan")] # Arg
+        ],
+        'tolerance' : 16777216 # Specs say it's currently undefined
+    },
+    'lgamma_r' : {
+        'arg_types': [F, I, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, lgamma(1.5), lgamma(0.5), float("nan"), lgamma(1.e-15), float("nan")], # Result0
+            [1, -1, 1, 1, 1, 1], # Result1
+            [1.0, 1.5, 0.5,        0.0,           1.e-15,        float("nan")] # Arg
+        ],
+        'tolerance' : 16777216, # Specs say it's currently undefined
+        'num_out_args' : 2
+    },
+    'log' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [log(0.5), float("-inf"), log(1.e-15), float("nan")], #Result
+            [0.5,      0.0,           1.e-15,      float("nan")]  #Arg0
+        ],
+        'tolerance' : 3
+    },
     'log10' : {
         'arg_types': [F, F],
         'function_type': 'ttt',
@@ -380,6 +488,74 @@ tests = {
         ],
         'tolerance' : 2
     },
+    'log2' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [log(0.5, 2), float("-inf"), log(1.e-15, 2), float("nan")], #Result
+            [0.5,         0.0,           1.e-15,         float("nan")]  #Arg0
+        ],
+        'tolerance' : 3
+    },
+    'logb' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0, 3, 1, 10, float("inf"), float("inf")], #Result
+            [1.0, 10.0, -3.0, 1234.5, float("inf"), float("-inf")] #Arg0
+        ],
+        'tolerance' : 0
+    },
+    'mad' : {
+        'arg_types': [F, F, F, F],
+        'function_type': 'tss',
+        'values': [
+            [pi,   1.0, pi , -0.5, float("nan"), float("nan"), float("nan")], # Result
+            [1.0,   pi, 0.0,  0.0, 1.0, float("nan"), float("nan")], # Arg0
+            [pi,   0.0, pi,  -0.5, float("nan"), 1.0, float("nan")], # Arg1
+            [0.0,  1.0, pi,  -0.5, float("nan"), 1.0, float("nan")]  # Arg2
+        ],
+        'tolerance' : 16777216 #infinite ULP
+    },
+    'maxmag' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [1.0, -0.5, 0.0, -0.5, 1.0, 1.0,          float("nan")], #Result
+            [1.0, -0.5, 0.0,  0.0, 1.0, float("nan"), float("nan")], #Arg0
+            [0.0,  0.0, 0.0, -0.5, float("nan"), 1.0, float("nan")] #Arg1
+        ]
+    },
+    'minmag' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, -0.5, 0.0,  1.0, 1.0, 1.0,          float("nan")], #Result
+            [1.0, -0.5, 1.0,  1.0, 1.0, float("nan"), float("nan")], #Arg0
+            [0.0,  1.0, 0.0, -1.5, float("nan"), 1.0, float("nan")] #Arg1
+        ]
+    },
+    'modf' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, modf(1.5)[0], modf(0.25)[0], 0.0, modf(1.e-15)[0], float("nan")], # Result0
+            [1,   modf(1.5)[1], modf(0.25)[1], 0.0, modf(1.e-15)[1], float("nan")], # Result1
+            [1.0, 1.5,          0.25,          0.0, 1.e-15,         float("nan")] # Arg
+        ],
+        'num_out_args' : 2
+    },
+# FIXME: kernel names are broken, and we cant really compare nans to see if the
+# code made it
+#    'nan' : {
+#        'arg_types': [F, U],
+#        'function_type': 'ttt',
+#        'values': [
+#            [float("nan"), float("nan"), float("nan")],
+#            [0xdead, 0xadbeef, 0xdead]
+#        ],
+#        'tolerance' : 0
+#    },
     'nextafter' : {
         'arg_types': [F, F, F],
         'function_type': 'ttt',
@@ -389,6 +565,36 @@ tests = {
             [1.0,          -1.0         , 2.0, 0.0, 3.4, float("nan"), 5.0], # Arg1
         ]
     },
+    'pow' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [pow(0, 1.0), pow(-3, 10.0), pow(-11, -3.0), pow(1234.5, 10), pow(2147483647, -1.0), float("inf")], # Result
+            [0,     -3,  -11, 1234.5, 2147483647,    2147483647], # Arg0
+            [1.0, 10.0, -3.0,     10,       -1.0, float("-inf")] # Arg1
+        ],
+        'tolerance' : 16
+    },
+    'pown' : {
+        'arg_types': [F, F, I],
+        'function_type': 'ttt',
+        'values': [
+            [pow(1, 0), pow(10.0, 3), pow(-3.3, -4), pow(1234, 10), pow(-1, 2147483647), float("-inf")], # Result
+            [1.0, 10.0, -3.3, 1234,       -1.0, float("-inf")], # Arg0
+            [0,      3,   -4,   10, 2147483647,    2147483647] # Arg1
+        ],
+        'tolerance' : 16
+    },
+    'powr' : {
+        'arg_types': [F, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [pow(0, 1.0), pow(3, 10.0), pow(11, -3.0), pow(1234.5, 10), pow(2147483647, -1.0), 0.0], # Result
+            [0,      3,   11, 1234.5, 2147483647,    2147483647], # Arg0
+            [1.0, 10.0, -3.0,     10,       -1.0, float("-inf")] # Arg1
+        ],
+        'tolerance' : 16
+    },
     'remainder' : {
         'arg_types': [F, F, F],
         'function_type': 'ttt',
@@ -401,6 +607,39 @@ tests = {
             [ 3.0,  3.0, -3.0, -3.0, 1.0,  1.0, float("inf"), 0.0], # Arg1
         ]
     },
+    'remquo' : {
+        'arg_types': [F, I, F, F],
+        'function_type': 'ttt',
+        'values': [
+            [float.fromhex("-0x1.ccccdp-1"), float.fromhex("0x1.ccccdp-1"),
+             float.fromhex("-0x1.ccccdp-1"), float.fromhex("0x1.ccccdp-1"),
+             0.0, -0.0, 5.1, float("-nan")
+            ], # Result
+            [quo(5.1, 3.0), quo(-5.1, 3.0),  quo(5.1, -3.0), quo(-5.1, -3.0),
+             quo(0.0, 1.0), quo(-0.0, 1.0), quo(5.1, float("inf")), 0], # Arg0
+            [ 5.1, -5.1,  5.1, -5.1, 0.0, -0.0, 5.1,          5.1], # Arg0
+            [ 3.0,  3.0, -3.0, -3.0, 1.0,  1.0, float("inf"), 0.0], # Arg1
+        ],
+        'num_out_args' : 2
+    },
+    'rint' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, -0.0, 1.0, -1.0, float("nan"), -4.0,  2.0, 0.0, 1.0],
+            [0.5, -0.5, 0.6, -0.6, float("nan"), -3.99, 1.5, 0.4, 0.6]
+        ]
+    },
+    'rootn' : {
+        'arg_types': [F, F, I],
+        'function_type': 'ttt',
+        'values': [
+            [pow(1, 1/2), pow(10.0, 1/3), float("nan"), pow(1234, 1/10), -1, float("-inf")], # Result
+            [1.0, 10.0, -3.3, 1234,       -1.0, float("-inf")], # Arg0
+            [2,      3,   -4,   10, 2147483647,    2147483647] # Arg1
+        ],
+        'tolerance' : 16
+    },
     'round' : {
         'arg_types': [F, F],
         'function_type': 'ttt',
@@ -409,6 +648,15 @@ tests = {
             [0.5, -0.5, 0.0, -0.0, float("nan"), -3.99, 1.5, 0.4, 0.6]
         ]
     },
+    'rsqrt' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [1.0, 1.0/2.0,  1/6.0, 1/2.5 , float("nan"), 1/4.0,  float("inf"), 1/sqrt(7.0), 1/sqrt(pi)], # Result
+            [1.0, 4.0, 36.0, 6.25, float("nan"), 16.0, 0.0, 7.0, pi], # Arg1
+        ],
+        'tolerance': 2
+    },
     'sin' : {
         'arg_types' : [F, F],
         'function_type': 'ttt',
@@ -418,6 +666,17 @@ tests = {
         ],
         'tolerance': 4
     },
+    'sincos' : {
+        'arg_types' : [F, F, F],
+        'function_type': 'ttt',
+        'values' : [
+            [0.0, 1.0,   0.0, -1.0,       0.0,    sin(2.234567), sin(7), sin(8), sin(pow(2,20)), sin(pow(2,24)), sin(pow(2,120)), float("nan")], # Result0
+            [1.0, 0.0,    -1.0, 0.0,        1.0,    cos(1.12345), cos(7), cos(8), cos(pow(2,20)), cos(pow(2,24)), cos(pow(2,120)), float("nan")], # Result1
+            [0.0, pi / 2, pi, 3 * pi / 2, 2 * pi, 2.234567, 7, 8, pow(2,20), pow(2,24), pow(2,120), float("nan")] # Arg0
+        ],
+        'tolerance': 4,
+        'num_out_args' : 2
+    },
     'sinh' : {
         'arg_types' : [F, F],
         'function_type': 'ttt',
@@ -467,6 +726,24 @@ tests = {
         ],
         'tolerance': 5
     },
+    'tanpi' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [0.0, 1.0,  0.0, sqrt(3), -1.0,   tan(pi * 2.234567), float("nan") ], # Result
+            [0.0, 1/4, 1,  1/3,    3/4, 2.234567 ,     float("nan") ], # Arg1
+        ],
+        'tolerance': 6
+    },
+    'tgamma' : {
+        'arg_types': [F, F],
+        'function_type': 'ttt',
+        'values': [
+            [1.0, gamma(1.5), gamma(0.5), float("nan"), gamma(1.e-15), float("nan")], # Result
+            [1.0, 1.5, 0.5,        0.0,           1.e-15,        float("nan")] # Arg
+        ],
+        'tolerance' : 16
+    },
     'trunc' : {
         'arg_types': [F, F],
         'function_type': 'ttt',
-- 
2.13.6



More information about the Piglit mailing list