[Piglit] [PATCH] cl: Add signbit(float) relational tests
Aaron Watry
awatry at gmail.com
Fri Jun 20 09:29:13 PDT 2014
Also, while doing this, needed to add a NEGNAN define to genclbuiltins.py because
python just prints nan for float("-nan") when generating tests.
cl-program-tester can handle -nan as an input correctly, so just pass the value
through as a string without python attempting to handle it.
v2: Add nan and -nan tests
Signed-off-by: Aaron Watry <awatry at gmail.com>
CC: Tom Stellard <thomas.stellard at amd.com>
---
generated_tests/genclbuiltins.py | 3 +++
generated_tests/generate-cl-relational-builtins.py | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/generated_tests/genclbuiltins.py b/generated_tests/genclbuiltins.py
index 2d2b322..9173cdb 100644
--- a/generated_tests/genclbuiltins.py
+++ b/generated_tests/genclbuiltins.py
@@ -56,6 +56,7 @@ UMAX = 'unsigned_max_for_type'
TYPE = 'TYPE'
SIZE = 'SIZE'
TRUE = 'true_value_for_type' #1 for scalar, -1 for vector
+NEGNAN = 'Negative NAN as a string, because float("-nan") just produces nan'
# Identity type list
T = {
@@ -234,6 +235,8 @@ def getValue(type, val, isVector):
return -1
else:
return 1
+ elif (val == NEGNAN):
+ return '-nan' #cl-program-tester translates this for us
else:
print('Unknown string value: ' + val + '\n')
elif (isinstance(val, list)):
diff --git a/generated_tests/generate-cl-relational-builtins.py b/generated_tests/generate-cl-relational-builtins.py
index dd9bc35..db7b7f5 100644
--- a/generated_tests/generate-cl-relational-builtins.py
+++ b/generated_tests/generate-cl-relational-builtins.py
@@ -27,7 +27,7 @@
import os
-from genclbuiltins import gen, TRUE
+from genclbuiltins import gen, TRUE, NEGNAN
CLC_VERSION_MIN = {
'isnan' : 10,
@@ -35,6 +35,7 @@ CLC_VERSION_MIN = {
'isgreater' : 10,
'isgreaterequal' : 10,
'isnotequal' : 10,
+ 'signbit' : 10
}
DATA_TYPES = ['float']
@@ -91,6 +92,14 @@ tests = {
[0.0, float("nan"), 1.0, 1, float("nan"), float("inf"), 1.0, 0.5 ], # Arg0
[0.0, float("nan"), 1.0, float("nan"), 1, float("inf"), 0.5, 1.0 ] # Arg1
]
+ },
+ 'signbit' : {
+ 'arg_types': [I, F],
+ 'function_type': 'ttt',
+ 'values': [
+ [0, TRUE, 0, 0, TRUE, 0, TRUE, 0 , TRUE ], # Result
+ [0.0, float(0)*-1, 1.0, 1, float("-inf"), float("inf"), -1.0, float("nan"), NEGNAN ] # Arg0
+ ]
}
}
--
1.9.1
More information about the Piglit
mailing list