Skip to content

Commit 8f39763

Browse files
authored
[SYCL-PTX] Enable 16 bits float builtins. (#2024)
This patch enables 16 bits float in the libclc. It also provides a bindings between __fp16 (with native halfs) and _Float16, it is safe as in libclc the configuration both lower to the same type. Signed-off-by: Victor Lomuller <[email protected]>
1 parent 9f42124 commit 8f39763

File tree

6 files changed

+9477
-4
lines changed

6 files changed

+9477
-4
lines changed

libclc/generic/include/as_type.h

+9
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,13 @@
8585
#define as_half16(x) __builtin_astype(x, half16)
8686
#endif
8787

88+
#ifdef __CLC_HAS_FLOAT16
89+
#define as_float16_t(x) __builtin_astype(x, __clc_float16_t)
90+
#define as_vec2_float16_t(x) __builtin_astype(x, __clc_vec2_float16_t)
91+
#define as_vec3_float16_t(x) __builtin_astype(x, __clc_vec3_float16_t)
92+
#define as_vec4_float16_t(x) __builtin_astype(x, __clc_vec4_float16_t)
93+
#define as_vec8_float16_t(x) __builtin_astype(x, __clc_vec8_float16_t)
94+
#define as_vec16_float16_t(x) __builtin_astype(x, __clc_vec16_float16_t)
95+
#endif
96+
8897
#endif // CLC_AS_TYPE

libclc/generic/include/lp64_types.h

+14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#ifndef CLC_LP64_TYPES
1010
#define CLC_LP64_TYPES
1111

12+
#ifdef __FLT16_MAX__
13+
#define __CLC_HAS_FLOAT16
14+
#endif
15+
1216
typedef bool __clc_bool_t;
1317

1418
typedef char __clc_char_t;
@@ -106,6 +110,16 @@ typedef half __clc_vec16_fp16_t __attribute__((ext_vector_type(16)));
106110

107111
#endif
108112

113+
#ifdef __CLC_HAS_FLOAT16
114+
115+
typedef _Float16 __clc_float16_t;
116+
typedef _Float16 __clc_vec2_float16_t __attribute__((ext_vector_type(2)));
117+
typedef _Float16 __clc_vec3_float16_t __attribute__((ext_vector_type(3)));
118+
typedef _Float16 __clc_vec4_float16_t __attribute__((ext_vector_type(4)));
119+
typedef _Float16 __clc_vec8_float16_t __attribute__((ext_vector_type(8)));
120+
typedef _Float16 __clc_vec16_float16_t __attribute__((ext_vector_type(16)));
121+
122+
#endif
109123
typedef __clc_int64_t __clc_size_t;
110124

111125
#ifdef __SYCL_DEVICE_ONLY__

libclc/generic/libspirv/SOURCES

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
float16.cl
12
subnormal_config.cl
23
subnormal_helper_func.ll
34
async/async_work_group_strided_copy.cl

0 commit comments

Comments
 (0)