[Piglit] [PATCH 1/2] cl: add popcount builtin

Serge Martin edb+piglit at sigluy.net
Wed Sep 30 12:25:27 PDT 2015


---
 generated_tests/gen_cl_int_builtins.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/generated_tests/gen_cl_int_builtins.py b/generated_tests/gen_cl_int_builtins.py
index b94e118..03848f0 100644
--- a/generated_tests/gen_cl_int_builtins.py
+++ b/generated_tests/gen_cl_int_builtins.py
@@ -50,6 +50,7 @@ CLC_VERSION_MIN = {
     'rotate': 10,
     'sub_sat': 10,
     'upsample': 10,
+    'popcount': 12,
     'mad24': 10,
     'mul24': 10
 }
@@ -83,6 +84,8 @@ def clz(type, val):
                 count = count + 1
         return DATA_SIZES[type] - count
 
+def popcount(val):
+    return bin(val).count('1')
 
 def div(val1, val2):
     return val1 // val2
@@ -104,10 +107,6 @@ 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 pow(val, pow):
     return val ** pow
@@ -298,6 +297,17 @@ generic_tests = {
             [1, 1,  MAX, 0,   0, 1],
             [0, 1, UMAX, 0, MAX, 7]
         ]
+    },
+    'popcount': {
+        'arg_types': [T, T],
+        'function_type': 'ttt',
+        'values': [
+            [[popcount,   1],
+             [popcount,   3],
+             [popcount,   0],
+             [popcount, MAX],
+             [popcount, MIN]],
+            [1, 3, 0, MAX, MIN]]
     }
 }
 
-- 
2.5.2



More information about the Piglit mailing list