Skip to content

Commit 94142d9

Browse files
authored
[libclc] Support the generic address space (#137183)
This commit provides definitions of builtins with the generic address space. One concept to consider is the difference between supporting the generic address space from the user's perspective and the requirement for libclc as a compiler implementation detail to define separate generic address space builtins. In practice a target (like NVPTX) might notionally support the generic address space, but it's mapped to the same LLVM target address space as another address space (often the private one). In such cases libclc must be careful not to define both private and generic overloads of the same builtin. We track these two concepts separately, and make the assumption that if the generic address space does clash with another, it's with the private one. We track the concepts separately because there are some builtins such as atomics that are defined for the generic address space but not the private address space.
1 parent d997b4f commit 94142d9

21 files changed

+177
-4
lines changed

libclc/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,40 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
420420
-D${CLC_TARGET_DEFINE}
421421
# All libclc builtin libraries see CLC headers
422422
-I${CMAKE_CURRENT_SOURCE_DIR}/clc/include
423+
# Error on undefined macros
424+
-Werror=undef
423425
)
424426

425427
if( NOT "${cpu}" STREQUAL "" )
426428
list( APPEND build_flags -mcpu=${cpu} )
427429
endif()
428430

431+
# Generic address space support.
432+
# Note: when declaring builtins, we must consider that even if a target
433+
# formally/nominally supports the generic address space, in practice that
434+
# target may map it to the same target address space as another address
435+
# space (often the private one). In such cases we must be careful not to
436+
# multiply-define a builtin in a single target address space, as it would
437+
# result in a mangling clash.
438+
# For this reason we must consider the target support of the generic
439+
# address space separately from the *implementation* decision about whether
440+
# to declare certain builtins in that address space.
441+
# Note: we assume that if there is no distinct generic address space, it
442+
# maps to the private address space.
443+
set ( private_addrspace_val 0 )
444+
set ( generic_addrspace_val 0 )
445+
if( ARCH STREQUAL amdgcn OR ARCH STREQUAL r600 OR ARCH STREQUAL amdgcn-amdhsa )
446+
set ( private_addrspace_val 5 )
447+
endif()
448+
if( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64
449+
OR ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
450+
set ( generic_addrspace_val 4 )
451+
endif()
452+
list( APPEND build_flags
453+
-D__CLC_PRIVATE_ADDRSPACE_VAL=${private_addrspace_val}
454+
-D__CLC_GENERIC_ADDRSPACE_VAL=${generic_addrspace_val}
455+
)
456+
429457
set( clc_build_flags ${build_flags} -DCLC_INTERNAL )
430458

431459
add_libclc_builtin_set(

libclc/clc/include/clc/clcfunc.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,18 @@
2323
#define _CLC_DEF __attribute__((always_inline))
2424
#endif
2525

26+
#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 || \
27+
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
28+
defined(__opencl_c_generic_address_space))
29+
#define _CLC_GENERIC_AS_SUPPORTED 1
30+
#if __CLC_PRIVATE_ADDRSPACE_VAL != __CLC_GENERIC_ADDRSPACE_VAL
31+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1
32+
#else
33+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0
34+
#endif
35+
#else
36+
#define _CLC_GENERIC_AS_SUPPORTED 0
37+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0
38+
#endif
39+
2640
#endif // __CLC_CLCFUNC_H_

libclc/clc/include/clc/math/remquo_decl.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1717
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1818
__CLC_GENTYPE y,
1919
local __CLC_INTN *q);
20+
#if _CLC_GENERIC_AS_SUPPORTED
21+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
22+
__CLC_GENTYPE y,
23+
generic __CLC_INTN *q);
24+
#endif

libclc/clc/include/clc/math/unary_decl_with_int_ptr.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1212
local __CLC_INTN *iptr);
1313
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1414
private __CLC_INTN *iptr);
15+
#if _CLC_GENERIC_AS_SUPPORTED
16+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
17+
generic __CLC_INTN *iptr);
18+
#endif

libclc/clc/include/clc/math/unary_decl_with_ptr.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1212
local __CLC_GENTYPE *ptr);
1313
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE
1414
__CLC_FUNCTION(__CLC_GENTYPE x, private __CLC_GENTYPE *ptr);
15+
16+
#if _CLC_GENERIC_AS_SUPPORTED
17+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE
18+
__CLC_FUNCTION(__CLC_GENTYPE x, generic __CLC_GENTYPE *ptr);
19+
#endif

libclc/clc/include/clc/math/unary_def_with_int_ptr.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
2626
local __CLC_INTN *iptr) {
2727
return __CLC_FUNCTION(FUNCTION)(x, iptr);
2828
}
29+
30+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
31+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
32+
generic __CLC_INTN *iptr) {
33+
return __CLC_FUNCTION(FUNCTION)(x, iptr);
34+
}
35+
#endif

libclc/clc/include/clc/math/unary_def_with_ptr.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
2626
local __CLC_GENTYPE *ptr) {
2727
return __CLC_FUNCTION(FUNCTION)(x, ptr);
2828
}
29+
30+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
31+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE FUNCTION(__CLC_GENTYPE x,
32+
generic __CLC_GENTYPE *ptr) {
33+
return __CLC_FUNCTION(FUNCTION)(x, ptr);
34+
}
35+
#endif

libclc/clc/lib/generic/math/clc_fract.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x,
3434

3535
FRACT_DEF(local);
3636
FRACT_DEF(global);
37+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
38+
FRACT_DEF(generic);
39+
#endif
3740

3841
#undef MIN_CONSTANT

libclc/clc/lib/generic/math/clc_frexp.cl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <clc/clc_convert.h>
10+
#include <clc/clcfunc.h>
1011
#include <clc/internal/clc.h>
1112
#include <clc/math/math.h>
1213
#include <clc/relational/clc_isinf.h>
@@ -28,3 +29,10 @@
2829
#define __CLC_ADDRESS_SPACE local
2930
#include <clc/math/gentype.inc>
3031
#undef __CLC_ADDRESS_SPACE
32+
33+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
34+
#define __CLC_BODY <clc_frexp.inc>
35+
#define __CLC_ADDRESS_SPACE generic
36+
#include <clc/math/gentype.inc>
37+
#undef __CLC_ADDRESS_SPACE
38+
#endif

libclc/clc/lib/generic/math/clc_modf.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_modf(__CLC_GENTYPE x,
2323
CLC_MODF_DEF(local);
2424
CLC_MODF_DEF(global);
2525

26+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
27+
CLC_MODF_DEF(generic);
28+
#endif
29+
2630
#undef CLC_MODF_DEF

libclc/clc/lib/generic/math/clc_remquo.cl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@
2929
#define __CLC_ADDRESS_SPACE local
3030
#include <clc_remquo.inc>
3131
#undef __CLC_ADDRESS_SPACE
32+
33+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
34+
#define __CLC_ADDRESS_SPACE generic
35+
#include <clc_remquo.inc>
36+
#undef __CLC_ADDRESS_SPACE
37+
#endif

libclc/clc/lib/generic/math/clc_sincos.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
__CLC_DECLARE_SINCOS(global, __CLC_GENTYPE)
1616
__CLC_DECLARE_SINCOS(local, __CLC_GENTYPE)
1717
__CLC_DECLARE_SINCOS(private, __CLC_GENTYPE)
18+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
19+
__CLC_DECLARE_SINCOS(generic, __CLC_GENTYPE)
20+
#endif
1821

1922
#undef __CLC_DECLARE_SINCOS

libclc/opencl/include/clc/opencl/math/remquo.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,11 @@
1111
#define __CLC_BODY <clc/math/remquo_decl.inc>
1212
#include <clc/math/gentype.inc>
1313

14+
#if _CLC_GENERIC_AS_SUPPORTED
15+
#define __CLC_BODY <clc/math/remquo_decl.inc>
16+
#define __CLC_ADDRESS_SPACE generic
17+
#include <clc/math/gentype.inc>
18+
#undef __CLC_ADDRESS_SPACE
19+
#endif
20+
1421
#undef __CLC_FUNCTION

libclc/opencl/include/clc/opencl/shared/vload.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,19 @@
1717
_CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
1818
_CLC_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
1919

20+
#if _CLC_GENERIC_AS_SUPPORTED
21+
#define _CLC_VECTOR_VLOAD_GENERIC_DECL _CLC_VECTOR_VLOAD_DECL
22+
#else
23+
// The generic address space isn't available, so make the macro do nothing
24+
#define _CLC_VECTOR_VLOAD_GENERIC_DECL(X, Y, Z, W)
25+
#endif
26+
2027
#define _CLC_VECTOR_VLOAD_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE) \
2128
_CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private) \
2229
_CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local) \
2330
_CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __constant) \
24-
_CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global)
31+
_CLC_VECTOR_VLOAD_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global) \
32+
_CLC_VECTOR_VLOAD_GENERIC_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __generic)
2533

2634
#define _CLC_VECTOR_VLOAD_PRIM1(PRIM_TYPE) \
2735
_CLC_VECTOR_VLOAD_PRIM3(, PRIM_TYPE, PRIM_TYPE)
@@ -61,7 +69,13 @@ _CLC_VLOAD_DECL(a_half, half, float, , __global)
6169
_CLC_VLOAD_DECL(a_half, half, float, , __local)
6270
_CLC_VLOAD_DECL(a_half, half, float, , __private)
6371

72+
#if _CLC_GENERIC_AS_SUPPORTED
73+
_CLC_VLOAD_DECL(_half, half, float, , __generic)
74+
_CLC_VLOAD_DECL(a_half, half, float, , __generic)
75+
#endif
76+
6477
#undef _CLC_VLOAD_DECL
6578
#undef _CLC_VECTOR_VLOAD_DECL
6679
#undef _CLC_VECTOR_VLOAD_PRIM3
6780
#undef _CLC_VECTOR_VLOAD_PRIM1
81+
#undef _CLC_VECTOR_VLOAD_GENERIC_DECL

libclc/opencl/include/clc/opencl/shared/vstore.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,20 @@
1717
_CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE, RND) \
1818
_CLC_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE, RND)
1919

20+
#if _CLC_GENERIC_AS_SUPPORTED
21+
#define _CLC_VSTORE_GENERIC_DECL _CLC_VSTORE_DECL
22+
#define _CLC_VECTOR_VSTORE_GENERIC_DECL _CLC_VECTOR_VSTORE_DECL
23+
#else
24+
// The generic address space isn't available, so make the macros do nothing
25+
#define _CLC_VSTORE_GENERIC_DECL(X, Y, Z, W, V, U)
26+
#define _CLC_VECTOR_VSTORE_GENERIC_DECL(X, Y, Z, W, V)
27+
#endif
28+
2029
#define _CLC_VECTOR_VSTORE_PRIM3(SUFFIX, MEM_TYPE, PRIM_TYPE, RND) \
2130
_CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __private, RND) \
2231
_CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __local, RND) \
23-
_CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global, RND)
32+
_CLC_VECTOR_VSTORE_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __global, RND) \
33+
_CLC_VECTOR_VSTORE_GENERIC_DECL(SUFFIX, MEM_TYPE, PRIM_TYPE, __generic, RND)
2434

2535
#define _CLC_VECTOR_VSTORE_PRIM1(PRIM_TYPE) \
2636
_CLC_VECTOR_VSTORE_PRIM3(, PRIM_TYPE, PRIM_TYPE, )
@@ -29,10 +39,12 @@
2939
_CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __private, RND) \
3040
_CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __local, RND) \
3141
_CLC_VSTORE_DECL(_half, half, PRIM_TYPE, , __global, RND) \
42+
_CLC_VSTORE_GENERIC_DECL(_half, half, PRIM_TYPE, , __generic, RND) \
3243
_CLC_VECTOR_VSTORE_PRIM3(_half, half, PRIM_TYPE, RND) \
3344
_CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __private, RND) \
3445
_CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __local, RND) \
3546
_CLC_VSTORE_DECL(a_half, half, PRIM_TYPE, , __global, RND) \
47+
_CLC_VSTORE_GENERIC_DECL(a_half, half, PRIM_TYPE, , __generic, RND) \
3648
_CLC_VECTOR_VSTORE_PRIM3(a_half, half, PRIM_TYPE, RND)
3749

3850
_CLC_VECTOR_VSTORE_PRIM1(char)
@@ -65,6 +77,8 @@ _CLC_VECTOR_VSTORE_PRIM1(half)
6577
#endif
6678

6779
#undef _CLC_VSTORE_DECL
80+
#undef _CLC_VSTORE_GENERIC_DECL
6881
#undef _CLC_VECTOR_VSTORE_DECL
6982
#undef _CLC_VECTOR_VSTORE_PRIM3
7083
#undef _CLC_VECTOR_VSTORE_PRIM1
84+
#undef _CLC_VECTOR_VSTORE_GENERIC_DECL

libclc/opencl/lib/clspv/shared/vstore_half.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __private);
1414
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __local);
1515
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __global);
16+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
17+
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_GENTYPE, __generic);
18+
#endif
1619

1720
#undef __CLC_OFFSET
1821
#else
1922
FUNC(, 1, __CLC_GENTYPE, __private);
2023
FUNC(, 1, __CLC_GENTYPE, __local);
2124
FUNC(, 1, __CLC_GENTYPE, __global);
25+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
26+
FUNC(, 1, __CLC_GENTYPE, __generic);
27+
#endif
2228
#endif
2329
#endif

libclc/opencl/lib/generic/math/remquo.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y,
2020
local __CLC_INTN *q) {
2121
return __clc_remquo(x, y, q);
2222
}
23+
24+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
25+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE remquo(__CLC_GENTYPE x, __CLC_GENTYPE y,
26+
generic __CLC_INTN *q) {
27+
return __clc_remquo(x, y, q);
28+
}
29+
#endif

libclc/opencl/lib/generic/shared/vload.cl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@
5151
*)(&x[16 * offset])); \
5252
}
5353

54+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
55+
#define VLOAD_VECTORIZE_GENERIC VLOAD_VECTORIZE
56+
#else
57+
// The generic address space isn't available, so make the macro do nothing
58+
#define VLOAD_VECTORIZE_GENERIC(X, Y)
59+
#endif
60+
5461
#define VLOAD_ADDR_SPACES(__CLC_SCALAR_GENTYPE) \
5562
VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __private) \
5663
VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __local) \
5764
VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __constant) \
58-
VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __global)
65+
VLOAD_VECTORIZE(__CLC_SCALAR_GENTYPE, __global) \
66+
VLOAD_VECTORIZE_GENERIC(__CLC_SCALAR_GENTYPE, __generic)
5967

6068
#define VLOAD_TYPES() \
6169
VLOAD_ADDR_SPACES(char) \
@@ -129,3 +137,4 @@ VLOAD_ADDR_SPACES(half)
129137
#undef VLOAD_TYPES
130138
#undef VLOAD_ADDR_SPACES
131139
#undef VLOAD_VECTORIZE
140+
#undef VLOAD_VECTORIZE_GENERIC

libclc/opencl/lib/generic/shared/vload_half.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __private);
2020
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local);
2121
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global);
2222
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __constant);
23+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
24+
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __generic);
25+
#endif
2326

2427
#undef __CLC_OFFSET
2528
#else
2629
FUNC(, 1, 1, __CLC_GENTYPE, __private);
2730
FUNC(, 1, 1, __CLC_GENTYPE, __local);
2831
FUNC(, 1, 1, __CLC_GENTYPE, __global);
2932
FUNC(, 1, 1, __CLC_GENTYPE, __constant);
33+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
34+
FUNC(, 1, 1, __CLC_GENTYPE, __generic);
35+
#endif
3036
#endif
3137
#endif

libclc/opencl/lib/generic/shared/vstore.cl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@
5050
*)(&mem[16 * offset])) = vec; \
5151
}
5252

53+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
54+
#define VSTORE_VECTORIZE_GENERIC VSTORE_VECTORIZE
55+
#else
56+
// The generic address space isn't available, so make the macro do nothing
57+
#define VSTORE_VECTORIZE_GENERIC(X, Y)
58+
#endif
59+
5360
#define VSTORE_ADDR_SPACES(__CLC_SCALAR___CLC_GENTYPE) \
5461
VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __private) \
5562
VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __local) \
56-
VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __global)
63+
VSTORE_VECTORIZE(__CLC_SCALAR___CLC_GENTYPE, __global) \
64+
VSTORE_VECTORIZE_GENERIC(__CLC_SCALAR___CLC_GENTYPE, __generic)
5765

5866
VSTORE_ADDR_SPACES(char)
5967
VSTORE_ADDR_SPACES(uchar)
@@ -248,3 +256,4 @@ _CLC_DEF _CLC_OVERLOAD double __clc_rte(double x) {
248256
#undef DECLARE_HELPER
249257
#undef VSTORE_ADDR_SPACES
250258
#undef VSTORE_VECTORIZE
259+
#undef VSTORE_VECTORIZE_GENERIC

libclc/opencl/lib/generic/shared/vstore_half.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __local,
3131
STORE_HALF_BUILTIN);
3232
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __global,
3333
STORE_HALF_BUILTIN);
34+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
35+
FUNC(__CLC_VECSIZE, __CLC_VECSIZE, __CLC_OFFSET, __CLC_GENTYPE, __generic,
36+
STORE_HALF_BUILTIN);
37+
#endif
3438

3539
#undef __CLC_OFFSET
3640
#else
3741
FUNC(, 1, 1, __CLC_GENTYPE, __private, STORE_HALF_BUILTIN);
3842
FUNC(, 1, 1, __CLC_GENTYPE, __local, STORE_HALF_BUILTIN);
3943
FUNC(, 1, 1, __CLC_GENTYPE, __global, STORE_HALF_BUILTIN);
44+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
45+
FUNC(, 1, 1, __CLC_GENTYPE, __generic, STORE_HALF_BUILTIN);
46+
#endif
4047
#endif
4148

4249
#undef STORE_HALF_BUILTIN

0 commit comments

Comments
 (0)