On Sat, 2015-04-11 at 21:16 -0400, Jan Vesely wrote: > Move sign and mix out of math > All tests pass on Turks (min needs a libclc patch) > All tests except min and step pass on Intel CPU. Min and step fail > in NaN cases.
Hi, According to the OpenCL 1.1 and 1.2 spec: "If x or y are infinite or NaN, the return values are undefined." So technically, if either argument is NaN, even rand() is a possible output. :) - Bruno > > Signed-off-by: Jan Vesely <[email protected]> > --- > > NOTE: you'll need to remove old math tests (or entire builtin > directory) > manually to make piglit happy. > > generated_tests/CMakeLists.txt | 4 + > generated_tests/gen_cl_common_builtins.py | 154 > ++++++++++++++++++++++++++++++ > generated_tests/gen_cl_math_builtins.py | 21 ---- > tests/cl.py | 3 + > 4 files changed, 161 insertions(+), 21 deletions(-) > create mode 100644 generated_tests/gen_cl_common_builtins.py > > diff --git a/generated_tests/CMakeLists.txt > b/generated_tests/CMakeLists.txt > index 82679e1..5036a5d 100644 > --- a/generated_tests/CMakeLists.txt > +++ b/generated_tests/CMakeLists.txt > @@ -134,6 +134,9 @@ piglit_make_generated_tests( > piglit_make_generated_tests( > builtin_cl_relational_tests.list > gen_cl_relational_builtins.py) > +piglit_make_generated_tests( > + builtin_cl_common_tests.list > + gen_cl_common_builtins.py) > > # Create a custom target for generating OpenGL tests > # This is not added to the default target, instead it is added > @@ -167,6 +170,7 @@ add_custom_target(gen-cl-tests > DEPENDS builtin_cl_int_tests.list > builtin_cl_math_tests.list > builtin_cl_relational_tests.list > + builtin_cl_common_tests.list > cl_store_tests.list > ) > > diff --git a/generated_tests/gen_cl_common_builtins.py > b/generated_tests/gen_cl_common_builtins.py > new file mode 100644 > index 0000000..1e81d1b > --- /dev/null > +++ b/generated_tests/gen_cl_common_builtins.py > @@ -0,0 +1,154 @@ > +# Copyright 2013 Advanced Micro Devices, Inc. > +# > +# Permission is hereby granted, free of charge, to any person > obtaining a > +# copy of this software and associated documentation files (the > "Software"), > +# to deal in the Software without restriction, including without > limitation > +# the rights to use, copy, modify, merge, publish, distribute, > sublicense, > +# and/or sell copies of the Software, and to permit persons to whom > the > +# Software is furnished to do so, subject to the following > conditions: > +# > +# The above copyright notice and this permission notice (including > the next > +# paragraph) shall be included in all copies or substantial > portions of the > +# Software. > +# > +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > EXPRESS OR > +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, > +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO > EVENT SHALL > +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES > OR OTHER > +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > ARISING FROM, > +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > DEALINGS IN THE > +# SOFTWARE. > +# > +# Authors: Tom Stellard <[email protected]> > +# Aaron Watry <[email protected]> > +# > + > +from __future__ import print_function, division, absolute_import > +import os > + > +from genclbuiltins import gen, NEGNAN > +from math import radians, degrees, pi > + > +CLC_VERSION_MIN = { > + 'clamp' : 10, > + 'degrees' : 10, > + 'max' : 10, > + 'min' : 10, > + 'mix' : 10, > + 'radians' : 10, > + 'step' : 10, > + 'smoothstep' : 10, > + 'sign' : 10 > +} > + > +DATA_TYPES = ['float'] > + > +F = { > + 'float' : 'float' > +} > + > +I = { > + 'float' : 'int' > +} > + > +tests = { > + 'clamp' : { > + 'arg_types': [F, F, F, F], > + 'function_type': 'tss', > + 'values': [ > + [0.5, 0.0, 0.0, 0.0, float("nan")], #Result > + [1.0, -0.5, 0.0, 0.0, float("nan")], #Arg0 > + [0.0, 0.0, 0.0, -0.5, float("nan")], #Arg1 > + [0.5, 0.5, 0.0, 0.5, float("nan")], #Arg2 > + ] > + }, > + 'degrees' : { > + 'arg_types': [F, F], > + 'function_type': 'ttt', > + 'values': [ > + [degrees(0.5), degrees(-0.5), 180.0, 0.0, 360, 1800.0, > 18000, 90], #Result > + [0.5, -0.5, pi, 0.0, 2*pi, 10*pi, > 100*pi, pi/2] #Arg0 > + ] > + }, > + 'max' : { > + 'arg_types': [F, F, F], > + 'function_type': 'tss', > + 'values': [ > + [1.0, 0.0, 0.0, 0.0, float("nan"), 1.0], #Result > + [1.0, -0.5, 0.0, 0.0, 1.0, float("nan")], #Arg0 > + [0.0, 0.0, 0.0, -0.5, float("nan"), 1.0] #Arg1 > + ] > + }, > + 'min' : { > + 'arg_types': [F, F, F], > + 'function_type': 'tss', > + 'values': [ > + [0.0, -0.5, 0.0, -0.5, 1.0, float("nan")], #Result > + [1.0, -0.5, 0.0, 0.0, 1.0, float("nan")], #Arg0 > + [0.0, 0.0, 0.0, -0.5, float("nan"), 1.0] #Arg1 > + ] > + }, > + 'mix' : { #x + (y - x) * a > + 'arg_types': [F, F, F, F], > + 'function_type': 'tts', > + 'values': [ > + [0.5, -0.25, 0.0, -0.5, 1.0, 3.0, 10.0, float("nan"), > float("nan"), float("nan")], #Result > + [1.0, -0.5, 0.0, 0.0, 1.0, 4.0, 15.0, 5.0, 4.0, > float("nan")], #Arg0 > + [0.0, 0.0, 0.0, -0.5, 2.0, 2.0, 10.0, -0.2, > float("nan"), 1.5], #Arg1 > + [0.5, 0.5, 0.0, 1.0, 0.0, 0.5, 1.0, float("nan"), > 1.0, 0.0], #Arg2 > + ] > + }, > + 'radians' : { > + 'arg_types': [F, F], > + 'function_type': 'ttt', > + 'values': [ > + [0.5, -0.5, pi, 0.0, 2*pi, 10*pi, > 100*pi, pi/2], #Result > + [degrees(0.5), degrees(-0.5), 180.0, 0.0, 360, 1800.0, > 18000, 90] #Arg0 > + ] > + }, > + #TODO Add scalar combination (tst?) > + 'step' : { > + 'arg_types': [F, F, F], > + 'function_type': 'ttt', > + 'values': [ > + [0.0, 1.0, 1.0, 0.0, 1.0, 1.0], #Result > + [1.0, -0.5, 0.0, 0.0, 1.0, float("nan")], #Arg0 > + [0.0, 0.0, 0.0, -0.5, float("nan"), 1.0] #Arg1 > + ] > + }, > + #TODO Add scalar combination (tst?) > + 'smoothstep' : { > + 'arg_types': [F, F, F, F], > + 'function_type': 'ttt', > + 'values': [ > + [0.0, 0.0, 1.0, 1.0, 0.5, 0.896], #Result > + [0.0, 0.0, 0.0, -0.5, 0.0, 0.0], #Arg0 > + [1.0, 1.0, 0.5, 0.0, 0.5, 0.5], #Arg1 > + [-0.5, 0.0, 0.5, 1.0, 0.25, 0.4] #Arg2 > + ] > + }, > + 'sign' : { > + 'arg_types': [F, F], > + 'function_type': 'ttt', > + 'values': [ > + [1.0, -1.0, 0.0, -0.0, 0.0], #Result > + [0.5, -0.5, 0.0, -0.0, float("nan")] #Arg0 > + ] > + } > +} > + > + > +def main(): > + dirName = os.path.join("cl", "builtin", "common") > + > + testDefs = {} > + functions = sorted(tests.keys()) > + for dataType in DATA_TYPES: > + for fnName in functions: > + testDefs[(dataType, fnName)] = tests[fnName] > + > + gen(DATA_TYPES, CLC_VERSION_MIN, functions, testDefs, dirName) > + > + > +if __name__ == '__main__': > + main() > diff --git a/generated_tests/gen_cl_math_builtins.py > b/generated_tests/gen_cl_math_builtins.py > index 9f31d3c..ce7682d 100644 > --- a/generated_tests/gen_cl_math_builtins.py > +++ b/generated_tests/gen_cl_math_builtins.py > @@ -57,10 +57,8 @@ CLC_VERSION_MIN = { > 'ldexp' : 10, > 'log10' : 10, > 'log1p' : 10, > - 'mix' : 10, > 'nextafter' : 10, > 'round' : 10, > - 'sign' : 10, > 'sin' : 10, > 'sinh' : 10, > 'sinpi' : 10, > @@ -317,16 +315,6 @@ tests = { > ], > 'tolerance' : 2 > }, > - 'mix' : { #x + (y - x) * a > - 'arg_types': [F, F, F, F], > - 'function_type': 'tts', > - 'values': [ > - [float("nan"), float("nan"), 1.0, 3.0, 10.0 ], # Result > - [1.0 , 1.0, 1.0, 4.0, 15.0 ], # Arg0 > - [2.0 , float("nan"), 2.0, 2.0, 10.0 ], # Arg1 > - [float("nan"), 0.0, 0.0, 0.5, 1.0 ], # Arg2 > - ] > - }, > 'nextafter' : { > 'arg_types': [F, F, F], > 'function_type': 'ttt', > @@ -344,15 +332,6 @@ tests = { > [0.5, -0.5, 0.0, -0.0, float("nan"), -3.99, 1.5, 0.4, > 0.6] > ] > }, > - 'sign' : { # This is really a Common function but it uses the > same types > - # as a lot of the math functions. > - 'arg_types': [F, F], > - 'function_type': 'ttt', > - 'values': [ > - [1.0, -1.0, 0.0, -0.0, 0.0], > - [0.5, -0.5, 0.0, -0.0, float("nan")] > - ] > - }, > 'sin' : { > 'arg_types' : [F, F], > 'function_type': 'ttt', > diff --git a/tests/cl.py b/tests/cl.py > index dbc9232..0640729 100644 > --- a/tests/cl.py > +++ b/tests/cl.py > @@ -123,5 +123,8 @@ add_program_test_dir(grouptools.join('program', > 'execute', 'builtin'), > add_program_test_dir(grouptools.join('program', 'execute', > 'builtin'), > os.path.join(GENERATED_TESTS_DIR, 'cl', > 'builtin', > 'relational')) > +add_program_test_dir(grouptools.join('program', 'execute', > 'builtin'), > + os.path.join(GENERATED_TESTS_DIR, 'cl', > 'builtin', > + 'common')) > add_program_test_dir(grouptools.join('program', 'execute', 'store'), > os.path.join(GENERATED_TESTS_DIR, 'cl', > 'store')) _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
