From 17e918a0bff6755871dfe2be2eeab4b6ccb81713 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 15 May 2024 15:41:32 +0100 Subject: [PATCH 1/3] [libclc] Separate out generic AS support macros The previous model where we declare/define builtins based on whether target supports the generic address space was not able to capture the full complexity of what we need. We could see this in the fact that the two targets which we marked as not supporting the generic AS do in fact support it. The problem is rather that the target AS they map the generic AS to is the same target AS mapped to by the private AS. This problem hasn't properly been made apparent because all builtins we want to support with the generic AS also have overloads on the private AS. However, as can be seen in PRs like #13428, some targets want to support generic AS overloads of atomic builtins which don't also have private AS overloads. It's here that the simple dichotomy breaks down. This patch splits up the support of the generic AS into: 1. The target doesn't support the generic AS 2. The target supports the generic AS as a distinct target AS 3. The target supports the generic AS mapped identically as the private the AS All of our previous uses of case 1 have been migrated to case 3. These targets can make use of case 2 in the future to support generic AS builtins where no private AS builtins are supported. Note how we hardcode the assumption that the clash is on the private address space. This is unfortunate but for simplicity as it's the case for the two targets we care about. It was already being made, but in a less obvious way. There are ways of loosening this assumption if we ever needed to but it would currently complicate the code for untested scenarios. --- libclc/CMakeLists.txt | 28 +++++--- libclc/generic/include/clc/clc.h | 8 +++ libclc/generic/include/clc/math/fract.inc | 2 +- libclc/generic/include/clc/math/frexp.inc | 2 +- libclc/generic/include/clc/math/modf.inc | 2 +- libclc/generic/include/clc/math/remquo.h | 2 +- libclc/generic/include/clc/math/sincos.inc | 2 +- libclc/generic/include/clc/shared/vload.h | 4 +- libclc/generic/include/clc/shared/vstore.h | 2 +- libclc/generic/include/spirv/spirv.h | 8 +++ libclc/generic/include/spirv/spirv_builtins.h | 12 ++-- libclc/generic/lib/math/fract.inc | 2 +- libclc/generic/lib/math/frexp.cl | 2 +- libclc/generic/lib/math/modf.inc | 2 +- libclc/generic/lib/math/remquo.cl | 2 +- libclc/generic/lib/math/sincos.inc | 2 +- libclc/generic/lib/shared/vload.cl | 4 +- libclc/generic/lib/shared/vload_half.inc | 4 +- libclc/generic/lib/shared/vstore.cl | 6 +- libclc/generic/lib/shared/vstore_half.inc | 4 +- libclc/generic/libspirv/float16.cl | 72 +++++++++---------- libclc/generic/libspirv/math/fract.inc | 2 +- libclc/generic/libspirv/math/frexp.cl | 2 +- libclc/generic/libspirv/math/lgamma_r.cl | 2 +- libclc/generic/libspirv/math/modf.inc | 2 +- libclc/generic/libspirv/math/remquo.cl | 2 +- libclc/generic/libspirv/math/sincos.inc | 2 +- libclc/generic/libspirv/shared/vload.cl | 6 +- libclc/generic/libspirv/shared/vstore.cl | 6 +- .../generic/libspirv/shared/vstore_half.inc | 4 +- 30 files changed, 112 insertions(+), 88 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index e698f48065702..c2d4d7dec7736 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -346,7 +346,19 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) message( STATUS " device: ${d} ( ${${d}_aliases} )" ) + # Note: when declaring builtins, we must consider that even if a target + # formally/nominally supports the generic address space, in practice that + # target may map it to the same target address space as another address + # space (often the private one). In such cases we must be careful not to + # multiply-define a builtin in a single target address space, as it would + # result in a mangling clash. + # For this reason we must consider the target support of the generic + # address space separately from the *implementation* decision about whether + # to declare certain builtins in that address space. set ( supports_generic_addrspace TRUE ) + # Note: we assume that if there is no distinct generic address space, it + # maps to the private address space. + set ( has_distinct_generic_addrspace TRUE ) if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 ) set( opt_flags -O3 ) set( spvflags --spirv-max-version=1.1 ) @@ -354,19 +366,12 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) set( opt_flags -O3 ) elseif( ARCH STREQUAL nvptx OR ARCH STREQUAL nvptx64 ) set( opt_flags -O3 "--nvvm-reflect-enable=false" ) - # Note: when declaring builtins, we don't consider NVIDIA as supporting - # the generic address space. This is because it maps to the same target - # address space as the private address space, resulting in a mangling - # clash. - # Since we can't declare builtins overloaded on both address spaces - # simultaneously, we choose declare the builtins using the private space, - # which will also work for the generic address space. - set( supports_generic_addrspace FALSE ) + set( has_distinct_generic_addrspace FALSE ) elseif( ARCH STREQUAL amdgcn ) set( opt_flags -O3 --amdgpu-oclc-reflect-enable=false ) elseif( ARCH STREQUAL x86_64) set( opt_flags ) - set( supports_generic_addrspace FALSE ) + set( has_distinct_generic_addrspace FALSE ) else() set( opt_flags -O3 ) endif() @@ -387,8 +392,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) "+__opencl_c_3d_image_writes," "+__opencl_c_images," "+cl_khr_3d_image_writes") - if(supports_generic_addrspace) + if( supports_generic_addrspace ) string( APPEND CL_3_0_EXTENSIONS ",+__opencl_c_generic_address_space" ) + if( has_distinct_generic_addrspace ) + list(APPEND flags -DLIBCLC_DISTINCT_GENERIC_ADDRSPACE) + endif() else() # Explictly disable opencl_c_generic_address_space (it may be enabled # by default on some targets). We also disable opencl_c_pipes and diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h index e17bd97c5b900..e05243d1ad438 100644 --- a/libclc/generic/include/clc/clc.h +++ b/libclc/generic/include/clc/clc.h @@ -18,8 +18,16 @@ (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \ defined(__opencl_c_generic_address_space)) #define _CLC_GENERIC_AS_SUPPORTED 1 +// Note that we hard-code the assumption that a non-distinct address space means +// that the target maps the generic address space to the private one. +#if LIBCLC_DISTINCT_GENERIC_ADDRSPACE +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 +#else +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif #else #define _CLC_GENERIC_AS_SUPPORTED 0 +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 #endif /* Function Attributes */ diff --git a/libclc/generic/include/clc/math/fract.inc b/libclc/generic/include/clc/math/fract.inc index 73f88dd81a7d1..dd6ccda7bf399 100644 --- a/libclc/generic/include/clc/math/fract.inc +++ b/libclc/generic/include/clc/math/fract.inc @@ -23,6 +23,6 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fract(__CLC_GENTYPE x, generic __CLC_GENTYPE *iptr); #endif diff --git a/libclc/generic/include/clc/math/frexp.inc b/libclc/generic/include/clc/math/frexp.inc index d9194d1178ffc..41c097fa87404 100644 --- a/libclc/generic/include/clc/math/frexp.inc +++ b/libclc/generic/include/clc/math/frexp.inc @@ -1,6 +1,6 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, global __CLC_INTN *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, local __CLC_INTN *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, private __CLC_INTN *iptr); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE frexp(__CLC_GENTYPE x, generic __CLC_INTN *iptr); #endif diff --git a/libclc/generic/include/clc/math/modf.inc b/libclc/generic/include/clc/math/modf.inc index 05c1038fa1cb8..a74635d30b44b 100644 --- a/libclc/generic/include/clc/math/modf.inc +++ b/libclc/generic/include/clc/math/modf.inc @@ -23,6 +23,6 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, global __CLC_GENTYPE *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, local __CLC_GENTYPE *iptr); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE modf(__CLC_GENTYPE x, generic __CLC_GENTYPE *iptr); #endif diff --git a/libclc/generic/include/clc/math/remquo.h b/libclc/generic/include/clc/math/remquo.h index e05e66c3d4815..bba4726a93286 100644 --- a/libclc/generic/include/clc/math/remquo.h +++ b/libclc/generic/include/clc/math/remquo.h @@ -15,7 +15,7 @@ #include #undef __CLC_ADDRESS_SPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_BODY #define __CLC_ADDRESS_SPACE generic #include diff --git a/libclc/generic/include/clc/math/sincos.inc b/libclc/generic/include/clc/math/sincos.inc index 05a2b1360638f..c3e52d6ab035a 100644 --- a/libclc/generic/include/clc/math/sincos.inc +++ b/libclc/generic/include/clc/math/sincos.inc @@ -1,6 +1,6 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, global __CLC_GENTYPE * cosval); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, local __CLC_GENTYPE * cosval); _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, private __CLC_GENTYPE * cosval); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE sincos (__CLC_GENTYPE x, generic __CLC_GENTYPE * cosval); #endif diff --git a/libclc/generic/include/clc/shared/vload.h b/libclc/generic/include/clc/shared/vload.h index c558a1e2f5eea..386868365c149 100644 --- a/libclc/generic/include/clc/shared/vload.h +++ b/libclc/generic/include/clc/shared/vload.h @@ -9,7 +9,7 @@ _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \ _CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define _CLC_VECTOR_VLOAD_GENERIC_DECL _CLC_VECTOR_VLOAD_DECL #else // The generic address space isn't available, so make the macro do nothing @@ -61,7 +61,7 @@ _CLC_VLOAD_DECL(a_half, half, float, , __global) _CLC_VLOAD_DECL(a_half, half, float, , __local) _CLC_VLOAD_DECL(a_half, half, float, , __private) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_VLOAD_DECL(_half, half, float, , __generic) _CLC_VLOAD_DECL(a_half, half, float, , __generic) #endif diff --git a/libclc/generic/include/clc/shared/vstore.h b/libclc/generic/include/clc/shared/vstore.h index d4aac11b8d63e..6d270178193b3 100644 --- a/libclc/generic/include/clc/shared/vstore.h +++ b/libclc/generic/include/clc/shared/vstore.h @@ -9,7 +9,7 @@ _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE, RND) \ _CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE, RND) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define _CLC_VSTORE_GENERIC_DECL _CLC_VSTORE_DECL #define _CLC_VECTOR_VSTORE_GENERIC_DECL _CLC_VECTOR_VSTORE_DECL #else diff --git a/libclc/generic/include/spirv/spirv.h b/libclc/generic/include/spirv/spirv.h index 419a46f85b539..ec24136fd62d4 100644 --- a/libclc/generic/include/spirv/spirv.h +++ b/libclc/generic/include/spirv/spirv.h @@ -24,8 +24,16 @@ (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \ defined(__opencl_c_generic_address_space)) #define _CLC_GENERIC_AS_SUPPORTED 1 +// Note that we hard-code the assumption that a non-distinct address space means +// that the target maps the generic address space to the private address space. +#if LIBCLC_DISTINCT_GENERIC_ADDRSPACE +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 +#else +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 +#endif #else #define _CLC_GENERIC_AS_SUPPORTED 0 +#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 #endif /* Function Attributes */ diff --git a/libclc/generic/include/spirv/spirv_builtins.h b/libclc/generic/include/spirv/spirv_builtins.h index adb0b14b690f9..5812039a0e73b 100644 --- a/libclc/generic/include/spirv/spirv_builtins.h +++ b/libclc/generic/include/spirv/spirv_builtins.h @@ -14476,7 +14476,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_fract(__clc_vec16_fp16_t, __clc_vec16_fp16_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_fract(__clc_fp32_t, __clc_fp32_t __generic *); @@ -14637,7 +14637,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_frexp(__clc_vec16_fp16_t, __clc_vec16_int32_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_frexp(__clc_fp32_t, __clc_int32_t __generic *); _CLC_OVERLOAD _CLC_DECL __clc_vec2_fp32_t @@ -15218,7 +15218,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_lgamma_r(__clc_vec16_fp16_t, __clc_vec16_int32_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_lgamma_r(__clc_fp32_t, __clc_int32_t __generic *); _CLC_OVERLOAD _CLC_DECL __clc_vec2_fp32_t @@ -15767,7 +15767,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_modf(__clc_vec16_fp16_t, __clc_vec16_fp16_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_modf(__clc_fp32_t, __clc_fp32_t __generic *); _CLC_OVERLOAD _CLC_DECL __clc_vec2_fp32_t @@ -16752,7 +16752,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_remquo( __clc_vec16_fp16_t, __clc_vec16_fp16_t, __clc_vec16_int32_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_remquo(__clc_fp32_t, __clc_fp32_t, __clc_int32_t __generic *); _CLC_OVERLOAD _CLC_DECL __clc_vec2_fp32_t __spirv_ocl_remquo( @@ -19016,7 +19016,7 @@ _CLC_OVERLOAD _CLC_DECL __clc_vec16_fp16_t __spirv_ocl_sincos(__clc_vec16_fp16_t, __clc_vec16_fp16_t __global *); #endif -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DECL __clc_fp32_t __spirv_ocl_sincos(__clc_fp32_t, __clc_fp32_t __generic *); _CLC_OVERLOAD _CLC_DECL __clc_vec2_fp32_t diff --git a/libclc/generic/lib/math/fract.inc b/libclc/generic/lib/math/fract.inc index 0abe269d13ab9..92bc00feee201 100644 --- a/libclc/generic/lib/math/fract.inc +++ b/libclc/generic/lib/math/fract.inc @@ -39,7 +39,7 @@ FRACT_DEF(private); FRACT_DEF(local); FRACT_DEF(global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FRACT_DEF(generic); #endif diff --git a/libclc/generic/lib/math/frexp.cl b/libclc/generic/lib/math/frexp.cl index 1213a72c6a2df..fec133c7cd10a 100644 --- a/libclc/generic/lib/math/frexp.cl +++ b/libclc/generic/lib/math/frexp.cl @@ -16,7 +16,7 @@ #include #undef __CLC_ADDRESS_SPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_BODY #define __CLC_ADDRESS_SPACE generic #include diff --git a/libclc/generic/lib/math/modf.inc b/libclc/generic/lib/math/modf.inc index ae71ac7e07667..a9a4e16461093 100644 --- a/libclc/generic/lib/math/modf.inc +++ b/libclc/generic/lib/math/modf.inc @@ -43,7 +43,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE modf(__CLC_GENTYPE x, private __CLC_GENTYPE MODF_DEF(local); MODF_DEF(global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED MODF_DEF(generic); #endif diff --git a/libclc/generic/lib/math/remquo.cl b/libclc/generic/lib/math/remquo.cl index 0efe1cde509b7..a05ddacd32bbc 100644 --- a/libclc/generic/lib/math/remquo.cl +++ b/libclc/generic/lib/math/remquo.cl @@ -16,7 +16,7 @@ #include #undef __CLC_ADDRESS_SPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_BODY #define __CLC_ADDRESS_SPACE generic #include diff --git a/libclc/generic/lib/math/sincos.inc b/libclc/generic/lib/math/sincos.inc index d917f2854d425..177e74e605c51 100644 --- a/libclc/generic/lib/math/sincos.inc +++ b/libclc/generic/lib/math/sincos.inc @@ -8,7 +8,7 @@ __CLC_DECLARE_SINCOS(global, __CLC_GENTYPE) __CLC_DECLARE_SINCOS(local, __CLC_GENTYPE) __CLC_DECLARE_SINCOS(private, __CLC_GENTYPE) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED __CLC_DECLARE_SINCOS(generic, __CLC_GENTYPE) #endif diff --git a/libclc/generic/lib/shared/vload.cl b/libclc/generic/lib/shared/vload.cl index 0d33d1f0ec305..62151a958773c 100644 --- a/libclc/generic/lib/shared/vload.cl +++ b/libclc/generic/lib/shared/vload.cl @@ -27,7 +27,7 @@ return *((const ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##16*) (&x[16*offset])); \ } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define VLOAD_VECTORIZE_GENERIC VLOAD_VECTORIZE #else // The generic address space isn't available, so make the macro do nothing @@ -70,7 +70,7 @@ float __clc_vload_half_float_helper__constant(const __constant half *); float __clc_vload_half_float_helper__global(const __global half *); float __clc_vload_half_float_helper__local(const __local half *); float __clc_vload_half_float_helper__private(const __private half *); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED float __clc_vload_half_float_helper__generic(const __generic half *); #endif diff --git a/libclc/generic/lib/shared/vload_half.inc b/libclc/generic/lib/shared/vload_half.inc index da98741fc5589..09ecd8798afad 100644 --- a/libclc/generic/lib/shared/vload_half.inc +++ b/libclc/generic/lib/shared/vload_half.inc @@ -12,7 +12,7 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local); FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global); FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __constant); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __generic); #endif @@ -22,7 +22,7 @@ FUNC(, 1, 1, __CLC_GENTYPE, __local); FUNC(, 1, 1, __CLC_GENTYPE, __global); FUNC(, 1, 1, __CLC_GENTYPE, __constant); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC(, 1, 1, __CLC_GENTYPE, __generic); #endif #endif diff --git a/libclc/generic/lib/shared/vstore.cl b/libclc/generic/lib/shared/vstore.cl index 2ffe21eee87ee..f72a965419702 100644 --- a/libclc/generic/lib/shared/vstore.cl +++ b/libclc/generic/lib/shared/vstore.cl @@ -28,7 +28,7 @@ *((ADDR_SPACE less_aligned_##ADDR_SPACE##PRIM_TYPE##16*) (&mem[16*offset])) = vec; \ } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define VSTORE_VECTORIZE_GENERIC VSTORE_VECTORIZE #else // The generic address space isn't available, so make the macro do nothing @@ -75,7 +75,7 @@ _CLC_DEF void __clc_vstore_half_##STYPE##_helper##AS(STYPE s, AS half *d) \ DECLARE_HELPER(float, __private, __builtin_store_halff); DECLARE_HELPER(float, __global, __builtin_store_halff); DECLARE_HELPER(float, __local, __builtin_store_halff); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED DECLARE_HELPER(float, __generic, __builtin_store_halff); #endif @@ -83,7 +83,7 @@ DECLARE_HELPER(float, __generic, __builtin_store_halff); DECLARE_HELPER(double, __private, __builtin_store_half); DECLARE_HELPER(double, __global, __builtin_store_half); DECLARE_HELPER(double, __local, __builtin_store_half); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED DECLARE_HELPER(double, __generic, __builtin_store_half); #endif #endif diff --git a/libclc/generic/lib/shared/vstore_half.inc b/libclc/generic/lib/shared/vstore_half.inc index a53da770dfbc6..2e6f1170639c6 100644 --- a/libclc/generic/lib/shared/vstore_half.inc +++ b/libclc/generic/lib/shared/vstore_half.inc @@ -11,7 +11,7 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __private); FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __local); FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __generic); #endif @@ -20,7 +20,7 @@ FUNC(, 1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __private); FUNC(, 1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __local); FUNC(, 1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC(, 1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __generic); #endif #endif diff --git a/libclc/generic/libspirv/float16.cl b/libclc/generic/libspirv/float16.cl index 41c2dcc8573fb..4bd36c175eb71 100644 --- a/libclc/generic/libspirv/float16.cl +++ b/libclc/generic/libspirv/float16.cl @@ -4735,7 +4735,7 @@ __spirv_ocl_fract(__clc_float16_t args_0, __clc_float16_t __global *args_1) { return __spirv_ocl_fract(as_half(args_0), (__clc_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_fract(__clc_float16_t args_0, __clc_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half(args_0), (__clc_fp16_t __generic *)(args_1)); @@ -4760,7 +4760,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_fract( (__clc_vec2_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_fract( __clc_vec2_float16_t args_0, __clc_vec2_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half2(args_0), @@ -4786,7 +4786,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_fract( (__clc_vec3_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_fract( __clc_vec3_float16_t args_0, __clc_vec3_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half3(args_0), @@ -4812,7 +4812,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_fract( (__clc_vec4_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_fract( __clc_vec4_float16_t args_0, __clc_vec4_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half4(args_0), @@ -4838,7 +4838,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_fract( (__clc_vec8_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_fract( __clc_vec8_float16_t args_0, __clc_vec8_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half8(args_0), @@ -4864,7 +4864,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_fract( (__clc_vec16_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_fract( __clc_vec16_float16_t args_0, __clc_vec16_float16_t __generic *args_1) { return __spirv_ocl_fract(as_half16(args_0), @@ -4887,7 +4887,7 @@ __spirv_ocl_frexp(__clc_float16_t args_0, __clc_int32_t __global *args_1) { return __spirv_ocl_frexp(as_half(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_frexp(__clc_float16_t args_0, __clc_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half(args_0), args_1); @@ -4909,7 +4909,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_frexp( return __spirv_ocl_frexp(as_half2(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_frexp( __clc_vec2_float16_t args_0, __clc_vec2_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half2(args_0), args_1); @@ -4931,7 +4931,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_frexp( return __spirv_ocl_frexp(as_half3(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_frexp( __clc_vec3_float16_t args_0, __clc_vec3_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half3(args_0), args_1); @@ -4953,7 +4953,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_frexp( return __spirv_ocl_frexp(as_half4(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_frexp( __clc_vec4_float16_t args_0, __clc_vec4_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half4(args_0), args_1); @@ -4975,7 +4975,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_frexp( return __spirv_ocl_frexp(as_half8(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_frexp( __clc_vec8_float16_t args_0, __clc_vec8_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half8(args_0), args_1); @@ -4997,7 +4997,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_frexp( return __spirv_ocl_frexp(as_half16(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_frexp( __clc_vec16_float16_t args_0, __clc_vec16_int32_t __generic *args_1) { return __spirv_ocl_frexp(as_half16(args_0), args_1); @@ -5189,7 +5189,7 @@ __spirv_ocl_lgamma_r(__clc_float16_t args_0, __clc_int32_t __global *args_1) { return __spirv_ocl_lgamma_r(as_half(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_lgamma_r(__clc_float16_t args_0, __clc_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half(args_0), args_1); @@ -5211,7 +5211,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_lgamma_r( return __spirv_ocl_lgamma_r(as_half2(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_lgamma_r( __clc_vec2_float16_t args_0, __clc_vec2_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half2(args_0), args_1); @@ -5233,7 +5233,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_lgamma_r( return __spirv_ocl_lgamma_r(as_half3(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_lgamma_r( __clc_vec3_float16_t args_0, __clc_vec3_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half3(args_0), args_1); @@ -5255,7 +5255,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_lgamma_r( return __spirv_ocl_lgamma_r(as_half4(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_lgamma_r( __clc_vec4_float16_t args_0, __clc_vec4_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half4(args_0), args_1); @@ -5277,7 +5277,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_lgamma_r( return __spirv_ocl_lgamma_r(as_half8(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_lgamma_r( __clc_vec8_float16_t args_0, __clc_vec8_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half8(args_0), args_1); @@ -5299,7 +5299,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_lgamma_r( return __spirv_ocl_lgamma_r(as_half16(args_0), args_1); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_lgamma_r( __clc_vec16_float16_t args_0, __clc_vec16_int32_t __generic *args_1) { return __spirv_ocl_lgamma_r(as_half16(args_0), args_1); @@ -5603,7 +5603,7 @@ __spirv_ocl_modf(__clc_float16_t args_0, __clc_float16_t __global *args_1) { return __spirv_ocl_modf(as_half(args_0), (__clc_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_modf(__clc_float16_t args_0, __clc_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half(args_0), (__clc_fp16_t __generic *)(args_1)); @@ -5628,7 +5628,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_modf( (__clc_vec2_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_modf( __clc_vec2_float16_t args_0, __clc_vec2_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half2(args_0), @@ -5654,7 +5654,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_modf( (__clc_vec3_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_modf( __clc_vec3_float16_t args_0, __clc_vec3_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half3(args_0), @@ -5680,7 +5680,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_modf( (__clc_vec4_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_modf( __clc_vec4_float16_t args_0, __clc_vec4_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half4(args_0), @@ -5706,7 +5706,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_modf( (__clc_vec8_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_modf( __clc_vec8_float16_t args_0, __clc_vec8_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half8(args_0), @@ -5731,7 +5731,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_modf( (__clc_vec16_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_modf( __clc_vec16_float16_t args_0, __clc_vec16_float16_t __generic *args_1) { return __spirv_ocl_modf(as_half16(args_0), @@ -5993,7 +5993,7 @@ __spirv_ocl_remquo(__clc_float16_t args_0, __clc_float16_t args_1, return __spirv_ocl_remquo(as_half(args_0), as_half(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_remquo(__clc_float16_t args_0, __clc_float16_t args_1, __clc_int32_t __generic *args_2) { @@ -6019,7 +6019,7 @@ __spirv_ocl_remquo(__clc_vec2_float16_t args_0, __clc_vec2_float16_t args_1, return __spirv_ocl_remquo(as_half2(args_0), as_half2(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_remquo(__clc_vec2_float16_t args_0, __clc_vec2_float16_t args_1, __clc_vec2_int32_t __generic *args_2) { @@ -6045,7 +6045,7 @@ __spirv_ocl_remquo(__clc_vec3_float16_t args_0, __clc_vec3_float16_t args_1, return __spirv_ocl_remquo(as_half3(args_0), as_half3(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_remquo(__clc_vec3_float16_t args_0, __clc_vec3_float16_t args_1, __clc_vec3_int32_t __generic *args_2) { @@ -6071,7 +6071,7 @@ __spirv_ocl_remquo(__clc_vec4_float16_t args_0, __clc_vec4_float16_t args_1, return __spirv_ocl_remquo(as_half4(args_0), as_half4(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_remquo(__clc_vec4_float16_t args_0, __clc_vec4_float16_t args_1, __clc_vec4_int32_t __generic *args_2) { @@ -6097,7 +6097,7 @@ __spirv_ocl_remquo(__clc_vec8_float16_t args_0, __clc_vec8_float16_t args_1, return __spirv_ocl_remquo(as_half8(args_0), as_half8(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_remquo(__clc_vec8_float16_t args_0, __clc_vec8_float16_t args_1, __clc_vec8_int32_t __generic *args_2) { @@ -6123,7 +6123,7 @@ __spirv_ocl_remquo(__clc_vec16_float16_t args_0, __clc_vec16_float16_t args_1, return __spirv_ocl_remquo(as_half16(args_0), as_half16(args_1), args_2); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_remquo(__clc_vec16_float16_t args_0, __clc_vec16_float16_t args_1, __clc_vec16_int32_t __generic *args_2) { @@ -6573,7 +6573,7 @@ __spirv_ocl_sincos(__clc_float16_t args_0, __clc_float16_t __global *args_1) { return __spirv_ocl_sincos(as_half(args_0), (__clc_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_fp16_t __spirv_ocl_sincos(__clc_float16_t args_0, __clc_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half(args_0), @@ -6597,7 +6597,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_sincos( return __spirv_ocl_sincos(as_half2(args_0), (__clc_vec2_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec2_fp16_t __spirv_ocl_sincos( __clc_vec2_float16_t args_0, __clc_vec2_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half2(args_0), (__clc_vec2_fp16_t __generic *)(args_1)); @@ -6621,7 +6621,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_sincos( (__clc_vec3_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec3_fp16_t __spirv_ocl_sincos( __clc_vec3_float16_t args_0, __clc_vec3_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half3(args_0), (__clc_vec3_fp16_t __generic *)(args_1)); @@ -6646,7 +6646,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_sincos( (__clc_vec4_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec4_fp16_t __spirv_ocl_sincos(__clc_vec4_float16_t args_0, __clc_vec4_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half4(args_0), @@ -6672,7 +6672,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_sincos( (__clc_vec8_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec8_fp16_t __spirv_ocl_sincos( __clc_vec8_float16_t args_0, __clc_vec8_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half8(args_0), @@ -6698,7 +6698,7 @@ _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_sincos( (__clc_vec16_fp16_t __global *)(args_1)); } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED _CLC_OVERLOAD _CLC_DEF __clc_vec16_fp16_t __spirv_ocl_sincos( __clc_vec16_float16_t args_0, __clc_vec16_float16_t __generic *args_1) { return __spirv_ocl_sincos(as_half16(args_0), diff --git a/libclc/generic/libspirv/math/fract.inc b/libclc/generic/libspirv/math/fract.inc index 512efc3f8e885..4af2a8049deee 100644 --- a/libclc/generic/libspirv/math/fract.inc +++ b/libclc/generic/libspirv/math/fract.inc @@ -46,7 +46,7 @@ __spirv_ocl_fract(__CLC_GENTYPE x, private __CLC_GENTYPE *iptr) { FRACT_DEF(local); FRACT_DEF(global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FRACT_DEF(generic); #endif diff --git a/libclc/generic/libspirv/math/frexp.cl b/libclc/generic/libspirv/math/frexp.cl index 4df1e827cfa76..6b05fe88832b4 100644 --- a/libclc/generic/libspirv/math/frexp.cl +++ b/libclc/generic/libspirv/math/frexp.cl @@ -24,7 +24,7 @@ #include #undef __CLC_ADDRESS_SPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_BODY #define __CLC_ADDRESS_SPACE generic #include diff --git a/libclc/generic/libspirv/math/lgamma_r.cl b/libclc/generic/libspirv/math/lgamma_r.cl index a84e9e6442c45..920cce8635dc4 100644 --- a/libclc/generic/libspirv/math/lgamma_r.cl +++ b/libclc/generic/libspirv/math/lgamma_r.cl @@ -659,7 +659,7 @@ _CLC_V_V_VP_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, half, __spirv_ocl_lgamma_r, half, #include #undef __CLC_ADDRSPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_ADDRSPACE generic #define __CLC_BODY #include diff --git a/libclc/generic/libspirv/math/modf.inc b/libclc/generic/libspirv/math/modf.inc index 887fde2151f03..9add4e7304503 100644 --- a/libclc/generic/libspirv/math/modf.inc +++ b/libclc/generic/libspirv/math/modf.inc @@ -41,7 +41,7 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __spirv_ocl_modf(__CLC_GENTYPE x, MODF_DEF(local); MODF_DEF(global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED MODF_DEF(generic); #endif diff --git a/libclc/generic/libspirv/math/remquo.cl b/libclc/generic/libspirv/math/remquo.cl index 23d2a15d534aa..7a5a58298cc05 100644 --- a/libclc/generic/libspirv/math/remquo.cl +++ b/libclc/generic/libspirv/math/remquo.cl @@ -25,7 +25,7 @@ #include #undef __CLC_ADDRESS_SPACE -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define __CLC_BODY #define __CLC_ADDRESS_SPACE generic #include diff --git a/libclc/generic/libspirv/math/sincos.inc b/libclc/generic/libspirv/math/sincos.inc index 0f2e859392963..dde178ee719e0 100644 --- a/libclc/generic/libspirv/math/sincos.inc +++ b/libclc/generic/libspirv/math/sincos.inc @@ -16,7 +16,7 @@ __CLC_DECLARE_SINCOS(global, __CLC_GENTYPE) __CLC_DECLARE_SINCOS(local, __CLC_GENTYPE) __CLC_DECLARE_SINCOS(private, __CLC_GENTYPE) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED __CLC_DECLARE_SINCOS(generic, __CLC_GENTYPE) #endif diff --git a/libclc/generic/libspirv/shared/vload.cl b/libclc/generic/libspirv/shared/vload.cl index 228df353f6806..0752b0aa8b665 100644 --- a/libclc/generic/libspirv/shared/vload.cl +++ b/libclc/generic/libspirv/shared/vload.cl @@ -59,7 +59,7 @@ *)(&x[16 * offset])); \ } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define VLOAD_VECTORIZE_GENERIC VLOAD_VECTORIZE #else // The generic address space isn't available, so make the macro do nothing @@ -107,7 +107,7 @@ float __clc_vload_half_float_helper__global(const __global half *); float __clc_vload_half_float_helper__local(const __local half *); float __clc_vload_half_float_helper__private(const __private half *); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED float __clc_vload_half_float_helper__generic(const __generic half *); #endif @@ -170,7 +170,7 @@ GEN_VLOAD_HALF(__global) GEN_VLOAD_HALF(__local) GEN_VLOAD_HALF(__constant) -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED GEN_VLOAD_HALF(__generic) #endif diff --git a/libclc/generic/libspirv/shared/vstore.cl b/libclc/generic/libspirv/shared/vstore.cl index a769d43a3ff3d..eb85d35f8d4ca 100644 --- a/libclc/generic/libspirv/shared/vstore.cl +++ b/libclc/generic/libspirv/shared/vstore.cl @@ -58,7 +58,7 @@ *)(&mem[16 * offset])) = vec; \ } -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED #define VSTORE_VECTORIZE_GENERIC VSTORE_VECTORIZE #else // The generic address space isn't available, so make the macro do nothing @@ -105,7 +105,7 @@ VSTORE_ADDR_SPACES(half) DECLARE_HELPER(float, __private, __builtin_store_halff); DECLARE_HELPER(float, __global, __builtin_store_halff); DECLARE_HELPER(float, __local, __builtin_store_halff); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED DECLARE_HELPER(float, __generic, __builtin_store_halff); #endif @@ -113,7 +113,7 @@ DECLARE_HELPER(float, __generic, __builtin_store_halff); DECLARE_HELPER(double, __private, __builtin_store_half); DECLARE_HELPER(double, __global, __builtin_store_half); DECLARE_HELPER(double, __local, __builtin_store_half); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED DECLARE_HELPER(double, __generic, __builtin_store_half); #endif #endif diff --git a/libclc/generic/libspirv/shared/vstore_half.inc b/libclc/generic/libspirv/shared/vstore_half.inc index 55a367897ff1c..2cc716b1f74ed 100644 --- a/libclc/generic/libspirv/shared/vstore_half.inc +++ b/libclc/generic/libspirv/shared/vstore_half.inc @@ -22,7 +22,7 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __local, n); FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __global, n); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __generic, n); #endif @@ -32,7 +32,7 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, FUNC_SCALAR(1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __private); FUNC_SCALAR(1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __local); FUNC_SCALAR(1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __global); -#if _CLC_GENERIC_AS_SUPPORTED +#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED FUNC_SCALAR(1, 1, __CLC_GENTYPE, __CLC_SCALAR_GENTYPE, __generic); #endif #endif From 2a2ee47bdf007ecc2015cca65f43f754b012b012 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 15 May 2024 16:57:56 +0100 Subject: [PATCH 2/3] fix def --- libclc/generic/include/clc/clc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h index e05243d1ad438..4d4c0ae8f87c9 100644 --- a/libclc/generic/include/clc/clc.h +++ b/libclc/generic/include/clc/clc.h @@ -20,7 +20,7 @@ #define _CLC_GENERIC_AS_SUPPORTED 1 // Note that we hard-code the assumption that a non-distinct address space means // that the target maps the generic address space to the private one. -#if LIBCLC_DISTINCT_GENERIC_ADDRSPACE +#ifdef LIBCLC_DISTINCT_GENERIC_ADDRSPACE #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 #else #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 From 5f88dd709bef31a6c110d82299787b6c570eb342 Mon Sep 17 00:00:00 2001 From: Fraser Cormack Date: Wed, 15 May 2024 17:50:16 +0100 Subject: [PATCH 3/3] fix cmdline flag order; rename macro --- libclc/CMakeLists.txt | 5 ++--- libclc/generic/include/clc/clc.h | 4 ++-- libclc/generic/include/spirv/spirv.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index c2d4d7dec7736..b55f6c3adce1f 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -384,7 +384,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} ) # OpenCL 3.0 extensions - list( APPEND flags -cl-std=CL3.0 "-Xclang" ) string(CONCAT CL_3_0_EXTENSIONS "-cl-ext=" "+cl_khr_fp64," @@ -395,7 +394,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) if( supports_generic_addrspace ) string( APPEND CL_3_0_EXTENSIONS ",+__opencl_c_generic_address_space" ) if( has_distinct_generic_addrspace ) - list(APPEND flags -DLIBCLC_DISTINCT_GENERIC_ADDRSPACE) + list( APPEND flags -D__CLC_DISTINCT_GENERIC_ADDRSPACE__ ) endif() else() # Explictly disable opencl_c_generic_address_space (it may be enabled @@ -405,7 +404,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} ) string( APPEND CL_3_0_EXTENSIONS ",-__opencl_c_pipes" ) string( APPEND CL_3_0_EXTENSIONS ",-__opencl_c_device_enqueue" ) endif() - list( APPEND flags ${CL_3_0_EXTENSIONS}) + list( APPEND flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} ) # Add platform specific flags if(WIN32) diff --git a/libclc/generic/include/clc/clc.h b/libclc/generic/include/clc/clc.h index 4d4c0ae8f87c9..e01947c4680c0 100644 --- a/libclc/generic/include/clc/clc.h +++ b/libclc/generic/include/clc/clc.h @@ -19,8 +19,8 @@ defined(__opencl_c_generic_address_space)) #define _CLC_GENERIC_AS_SUPPORTED 1 // Note that we hard-code the assumption that a non-distinct address space means -// that the target maps the generic address space to the private one. -#ifdef LIBCLC_DISTINCT_GENERIC_ADDRSPACE +// that the target maps the generic address space to the private address space. +#ifdef __CLC_DISTINCT_GENERIC_ADDRSPACE__ #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 #else #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0 diff --git a/libclc/generic/include/spirv/spirv.h b/libclc/generic/include/spirv/spirv.h index ec24136fd62d4..a22c376e5263e 100644 --- a/libclc/generic/include/spirv/spirv.h +++ b/libclc/generic/include/spirv/spirv.h @@ -26,7 +26,7 @@ #define _CLC_GENERIC_AS_SUPPORTED 1 // Note that we hard-code the assumption that a non-distinct address space means // that the target maps the generic address space to the private address space. -#if LIBCLC_DISTINCT_GENERIC_ADDRSPACE +#if __CLC_DISTINCT_GENERIC_ADDRSPACE__ #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1 #else #define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0