[Piglit] [PATCH] cl: Add popcount tests for CL 1.2
Aaron Watry
awatry at gmail.com
Fri Sep 19 14:16:19 PDT 2014
Signed-off-by: Aaron Watry <awatry at gmail.com>
---
generated_tests/generate-cl-int-builtins.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/generated_tests/generate-cl-int-builtins.py b/generated_tests/generate-cl-int-builtins.py
index 61fc93e..6a12171 100644
--- a/generated_tests/generate-cl-int-builtins.py
+++ b/generated_tests/generate-cl-int-builtins.py
@@ -46,6 +46,7 @@ CLC_VERSION_MIN = {
'max': 11, # max/min are only same-size in CL1.0, but TSS in CL1.1
'min': 11,
'mul_hi': 10,
+ 'popcount': 12,
'rotate': 10,
'sub_sat': 10,
'upsample': 10,
@@ -103,10 +104,10 @@ def mul_hi(x, y, type):
res = (x*y) >> DATA_SIZES[type]
return res
-# def pop(val,type):
-# # TODO: Calculate number of non-zero bits in value (CLC 1.2)
-# return 0
-
+def pop(val, type):
+ # Calculate number of non-zero bits in value
+ width = DATA_SIZES[type]
+ return bin(val & (2**width-1))[2:].zfill(width).count('1')
def pow(val, pow):
return val ** pow
@@ -257,6 +258,14 @@ generic_tests = {
[0, 2, 1, MAX, MIN, 1, 2, MAX]
]
},
+ 'popcount': {
+ 'arg_types': [T, T],
+ 'function_type': 'ttt',
+ 'values': [
+ [0, 1, 1, 1, 2, [pop, MAX, TYPE], [pop, MIN, TYPE]],
+ [0, 1, 2, 32, 3, MAX, MIN ]
+ ]
+ },
'rhadd': {
'arg_types': [T, T, T],
'function_type': 'ttt',
--
1.9.1
More information about the Piglit
mailing list