diff --git a/libclc/generic/lib/gen_convert.py b/libclc/generic/lib/gen_convert.py index 8dbdcd283357..469244047de9 100644 --- a/libclc/generic/lib/gen_convert.py +++ b/libclc/generic/lib/gen_convert.py @@ -26,17 +26,19 @@ # # convert_<_sat><_roundingMode>() -types = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float'] -int_types = ['char', 'uchar', 'short', 'ushort', 'int', 'uint'] -unsigned_types = ['uchar', 'ushort', 'uint'] -float_types = ['float'] +types = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong', 'float', 'double'] +int_types = ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long', 'ulong'] +unsigned_types = ['uchar', 'ushort', 'uint', 'ulong'] +float_types = ['float', 'double'] +int64_types = ['long', 'ulong'] +float64_types = ['double'] vector_sizes = ['', '2', '3', '4', '8', '16'] half_sizes = [('2',''), ('4','2'), ('8','4'), ('16','8')] saturation = ['','_sat'] rounding_modes = ['_rtz','_rte','_rtp','_rtn'] float_prefix = {'float':'FLT_', 'double':'DBL_'} -float_suffix = {'float':'f'} +float_suffix = {'float':'f', 'double':''} bool_type = {'char' : 'char', 'uchar' : 'char', @@ -44,19 +46,25 @@ bool_type = {'char' : 'char', 'ushort': 'short', 'int' : 'int', 'uint' : 'int', - 'float' : 'int'} + 'long' : 'long', + 'ulong' : 'long', + 'float' : 'int', + 'double' : 'long'} unsigned_type = {'char' : 'uchar', 'uchar' : 'uchar', 'short' : 'ushort', 'ushort': 'ushort', 'int' : 'uint', - 'uint' : 'uint'} + 'uint' : 'uint', + 'long' : 'ulong', + 'ulong' : 'ulong'} sizeof_type = {'char' : 1, 'uchar' : 1, 'short' : 2, 'ushort' : 2, 'int' : 4, 'uint' : 4, - 'float' : 4} + 'long' : 8, 'ulong' : 8, + 'float' : 4, 'double' : 8} limit_max = {'char' : 'CHAR_MAX', 'uchar' : 'UCHAR_MAX', @@ -79,14 +87,14 @@ limit_min = {'char' : 'CHAR_MIN', def conditional_guard(src, dst): int64_count = 0 float64_count = 0 - # if src in int64_types: - # int64_count = int64_count +1 - # elif src in float64_types: - # float64_count = float64_count + 1 - # if dst in int64_types: - # int64_count = int64_count +1 - # elif dst in float64_types: - # float64_count = float64_count + 1 + if src in int64_types: + int64_count = int64_count +1 + elif src in float64_types: + float64_count = float64_count + 1 + if dst in int64_types: + int64_count = int64_count +1 + elif dst in float64_types: + float64_count = float64_count + 1 if float64_count > 0: #In embedded profile, if cl_khr_fp64 is supported cles_khr_int64 has to be print("#ifdef cl_khr_fp64") diff --git a/libclc/generic/lib/math/nextafter.cl b/libclc/generic/lib/math/nextafter.cl index 33147ecd6b84..b22797a1271b 100644 --- a/libclc/generic/lib/math/nextafter.cl +++ b/libclc/generic/lib/math/nextafter.cl @@ -1,15 +1,15 @@ #include #include "../clcmacro.h" -extern float __nextafterf(float x, float y); +extern float __nextafterf(float x, float y) -_CLC_DEFINE_BINARY_BUILTIN(float, nextafter, __nextafterf, float, float) -// __attribute__((always_inline)) __attribute__((overloadable)) float nextafter(float x, float y) { return __nextafterf(x, y); } -// __attribute__((overloadable)) __attribute__((always_inline)) float2 nextafter(float2 x, float2 y) { return (float2)(nextafter(x.x, y.x), nextafter(x.y, y.y)); } -// __attribute__((overloadable)) __attribute__((always_inline)) float3 nextafter(float3 x, float3 y) { return (float3)(nextafter(x.x, y.x), nextafter(x.y, y.y), nextafter(x.z, y.z)); } -// __attribute__((overloadable)) __attribute__((always_inline)) float4 nextafter(float4 x, float4 y) { return (float4)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } -// __attribute__((overloadable)) __attribute__((always_inline)) float8 nextafter(float8 x, float8 y) { return (float8)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } -// __attribute__((overloadable)) __attribute__((always_inline)) float16 nextafter(float16 x, float16 y) { return (float16)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } +// _CLC_DEFINE_BINARY_BUILTIN(float, nextafter, __builtin_nextafterf, float, float) +__attribute__((always_inline)) __attribute__((overloadable)) float nextafter(float x, float y) { return __nextafterf(x, y); } +__attribute__((overloadable)) __attribute__((always_inline)) float2 nextafter(float2 x, float2 y) { return (float2)(nextafter(x.x, y.x), nextafter(x.y, y.y)); } +__attribute__((overloadable)) __attribute__((always_inline)) float3 nextafter(float3 x, float3 y) { return (float3)(nextafter(x.x, y.x), nextafter(x.y, y.y), nextafter(x.z, y.z)); } +__attribute__((overloadable)) __attribute__((always_inline)) float4 nextafter(float4 x, float4 y) { return (float4)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } +__attribute__((overloadable)) __attribute__((always_inline)) float8 nextafter(float8 x, float8 y) { return (float8)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } +__attribute__((overloadable)) __attribute__((always_inline)) float16 nextafter(float16 x, float16 y) { return (float16)(nextafter(x.lo, y.lo), nextafter(x.hi, y.hi)); } #ifdef cl_khr_fp64 diff --git a/libclc/riscv32/lib/workitem/get_global_size.cl b/libclc/riscv32/lib/workitem/get_global_size.cl index 5b64419c4299..2fb59cbbe754 100644 --- a/libclc/riscv32/lib/workitem/get_global_size.cl +++ b/libclc/riscv32/lib/workitem/get_global_size.cl @@ -1,17 +1,17 @@ #include -extern size_t __builtin_riscv_global_size_x(); -extern size_t __builtin_riscv_global_size_y(); -extern size_t __builtin_riscv_global_size_z(); +extern size_t __buitlin_riscv_global_size_x(); +extern size_t __buitlin_riscv_global_size_y(); +extern size_t __buitlin_riscv_global_size_z(); _CLC_DEF _CLC_OVERLOAD size_t get_global_size(uint dim) { switch (dim) { case 0: - return __builtin_riscv_global_size_x(); + return __buitlin_riscv_global_size_x(); case 1: - return __builtin_riscv_global_size_y(); + return __buitlin_riscv_global_size_y(); case 2: - return __builtin_riscv_global_size_z(); + return __buitlin_riscv_global_size_z(); default: return 1; }