diff options
author | Homer Hsing <homer.xing@intel.com> | 2013-10-10 10:13:41 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-10-10 13:22:38 +0800 |
commit | 04efbda63e00bef950ac35dde9285b3002ba9ba4 (patch) | |
tree | a50955c21d1472ed231e009b7f0e591fdff2fd51 /kernels/builtin_convert_sat.cl | |
parent | 1ad7e368cf9e1ac2f5256b70b20e1e46a06a92e0 (diff) |
saturated conversion of native GPU data type, larger to narrower
This patch supports saturated conversion of
native GPU data type (char/short/int/float),
from a larger-range data type to a narrower-range data type.
For instance, convert_uchar_sat(int)
Several test cases are in this patch.
v2: add uint->int, int->uint
Signed-off-by: Homer Hsing <homer.xing@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'kernels/builtin_convert_sat.cl')
-rw-r--r-- | kernels/builtin_convert_sat.cl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/kernels/builtin_convert_sat.cl b/kernels/builtin_convert_sat.cl new file mode 100644 index 0000000..281c890 --- /dev/null +++ b/kernels/builtin_convert_sat.cl @@ -0,0 +1,32 @@ +#define DEF(DSTTYPE, SRCTYPE) \ + kernel void builtin_convert_ ## SRCTYPE ## _to_ ## DSTTYPE ## _sat(global SRCTYPE *src, global DSTTYPE *dst) { \ + int i = get_global_id(0); \ + dst[i] = convert_ ## DSTTYPE ## _sat(src[i]); \ +} + +DEF(char, uchar); +DEF(char, short); +DEF(char, ushort); +DEF(char, int); +DEF(char, uint); +DEF(char, float); +DEF(uchar, char); +DEF(uchar, short); +DEF(uchar, ushort); +DEF(uchar, int); +DEF(uchar, uint); +DEF(uchar, float); +DEF(short, ushort); +DEF(short, int); +DEF(short, uint); +DEF(short, float); +DEF(ushort, short); +DEF(ushort, int); +DEF(ushort, uint); +DEF(ushort, float); +DEF(int, uint); +DEF(int, float); +DEF(uint, int); +DEF(uint, float); +#undef DEF + |