summaryrefslogtreecommitdiff
path: root/generated_tests
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2013-09-12 08:26:23 -0700
committerTom Stellard <thomas.stellard@amd.com>2013-09-27 20:21:52 -0700
commit5806ee385adf8f8b4c9181243d8c4a6152942acd (patch)
tree9457ff9322526d56a26f2789ef66ad091539a4d1 /generated_tests
parent82ab98fc6b0a6f77aa13c1d75b3f8c51f99a5dcb (diff)
cl: Add a python script for generating tests for math builtins
This includes a test for the nextafter builtin.
Diffstat (limited to 'generated_tests')
-rw-r--r--generated_tests/CMakeLists.txt4
-rw-r--r--generated_tests/genclbuiltins.py2
-rw-r--r--generated_tests/generate-cl-math-builtins.py66
3 files changed, 71 insertions, 1 deletions
diff --git a/generated_tests/CMakeLists.txt b/generated_tests/CMakeLists.txt
index a0ba4b1bb..2a1c3ff34 100644
--- a/generated_tests/CMakeLists.txt
+++ b/generated_tests/CMakeLists.txt
@@ -60,6 +60,9 @@ piglit_make_generated_tests(
piglit_make_generated_tests(
cl_store_tests.list
generate-cl-store-tests.py)
+piglit_make_generated_tests(
+ builtin_cl_math_tests.list
+ generate-cl-math-builtins.py)
# Add a "gen-tests" target that can be used to generate all the
# tests without doing any other compilation.
@@ -68,6 +71,7 @@ add_custom_target(gen-tests ALL
builtin_uniform_tests.list
constant_array_size_tests.list
builtin_cl_int_tests.list
+ builtin_cl_math_tests.list
cl_store_tests.list
interpolation_tests.list
non-lvalue_tests.list
diff --git a/generated_tests/genclbuiltins.py b/generated_tests/genclbuiltins.py
index 29dfe3972..721191e3a 100644
--- a/generated_tests/genclbuiltins.py
+++ b/generated_tests/genclbuiltins.py
@@ -252,7 +252,7 @@ def getValue(type, val):
getValue(type, val[3]), getValue(type, val[4]))
# At this point, we should have been passed a number
- if (isinstance(val, (int, long))):
+ if (isinstance(val, (int, long, float))):
return val
print('Invalid value '+repr(val)+' encountered in getValue\n')
diff --git a/generated_tests/generate-cl-math-builtins.py b/generated_tests/generate-cl-math-builtins.py
new file mode 100644
index 000000000..25143bada
--- /dev/null
+++ b/generated_tests/generate-cl-math-builtins.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# 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 <thomas.stellard@amd.com>
+#
+
+import os
+
+from genclbuiltins import gen
+
+CLC_VERSION_MIN = {
+ 'nextafter' : 10
+}
+
+DATA_TYPES = ['float']
+
+F = {
+ 'float' : 'float'
+}
+
+tests = {
+ 'nextafter' : {
+ 'arg_types': [F, F, F],
+ 'function_type': 'ttt',
+ 'values': [
+ [1.401298e-45, -1.401298e-45, 1.00000011920928955078125, 0.999999940395355224609375, float("nan"), float("nan"), 5.0 ], # Result
+ [0.0, 0.0 , 1.0, 1.0, float("nan"), 2.5, 5.0], # Arg0
+ [1.0, -1.0 , 2.0, 0.0, 3.4, float("nan"), 5.0], # Arg1
+ ]
+ }
+}
+
+
+def main():
+ dirName = os.path.join("cl", "builtin", "math")
+
+ 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)
+
+
+main()