diff options
author | Serge Martin <edb+piglit@sigluy.net> | 2015-09-30 21:36:56 +0200 |
---|---|---|
committer | Serge Martin <edb@sigluy.net> | 2015-10-04 16:16:57 +0200 |
commit | a2d8b3a647ccb5519fd5cd766ad98db769d56991 (patch) | |
tree | 6446439004651f5d2d42c5518439de6ece12f25c | |
parent | ed25c94e8a28e1336ea5561a25b96addf8ed8ee4 (diff) |
cl: add popcount builtin
Reviewed-by: Jan Vesely <jan.vesely@rutgers.edu>
-rw-r--r-- | generated_tests/gen_cl_int_builtins.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/generated_tests/gen_cl_int_builtins.py b/generated_tests/gen_cl_int_builtins.py index b94e118ff..03848f07b 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]] } } |