Skip to content

Commit c2ccc43

Browse files
authored
[SYCL][LIBCLC] Change __clc_size_t to unsigned (#4784)
This changes the `__clc_size_t` from a signed 64-bit int to an unsigned 64-bit int. The change results in the correct mangled name for `GroupAsyncCopy` built-ins. This is a proposed solution to issue #4502
1 parent 701e480 commit c2ccc43

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

libclc/generic/include/lp64_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ typedef _Float16 __clc_vec8_float16_t __attribute__((ext_vector_type(8)));
120120
typedef _Float16 __clc_vec16_float16_t __attribute__((ext_vector_type(16)));
121121

122122
#endif
123-
typedef __clc_int64_t __clc_size_t;
123+
typedef __clc_uint64_t __clc_size_t;
124124

125125
typedef event_t __clc_event_t;
126126

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o -
2+
3+
// Test checks for that no compile errors occur for
4+
// builtin async_work_group_copy
5+
#include <sycl/sycl.hpp>
6+
7+
using namespace cl::sycl;
8+
9+
// Define the number of work items to enqueue.
10+
const size_t NElems = 32;
11+
const size_t WorkGroupSize = 8;
12+
const size_t NWorkGroups = NElems / WorkGroupSize;
13+
14+
template <typename T> void async_work_group_test() {
15+
queue Q;
16+
17+
buffer<T, 1> InBuf(NElems);
18+
buffer<T, 1> OutBuf(NElems);
19+
20+
Q.submit([&](handler &CGH) {
21+
auto In = InBuf.template get_access<access::mode::read>(CGH);
22+
auto Out = OutBuf.template get_access<access::mode::write>(CGH);
23+
accessor<T, 1, access::mode::read_write, access::target::local> Local(
24+
range<1>{WorkGroupSize}, CGH);
25+
26+
nd_range<1> NDR{range<1>(NElems), range<1>(WorkGroupSize)};
27+
CGH.parallel_for(NDR, [=](nd_item<1> NDId) {
28+
auto GrId = NDId.get_group_linear_id();
29+
auto Group = NDId.get_group();
30+
size_t Offset = GrId * WorkGroupSize;
31+
auto E = NDId.async_work_group_copy(
32+
Local.get_pointer(), In.get_pointer() + Offset, WorkGroupSize);
33+
E = NDId.async_work_group_copy(Out.get_pointer() + Offset,
34+
Local.get_pointer(), WorkGroupSize);
35+
});
36+
}).wait();
37+
}
38+
39+
template <typename T> void test() {
40+
async_work_group_test<T>();
41+
async_work_group_test<vec<T, 2>>();
42+
async_work_group_test<vec<T, 3>>();
43+
async_work_group_test<vec<T, 4>>();
44+
async_work_group_test<vec<T, 8>>();
45+
async_work_group_test<vec<T, 16>>();
46+
async_work_group_test<detail::make_unsigned_t<T>>();
47+
async_work_group_test<vec<detail::make_unsigned_t<T>, 2>>();
48+
async_work_group_test<vec<detail::make_unsigned_t<T>, 3>>();
49+
async_work_group_test<vec<detail::make_unsigned_t<T>, 4>>();
50+
async_work_group_test<vec<detail::make_unsigned_t<T>, 8>>();
51+
async_work_group_test<vec<detail::make_unsigned_t<T>, 16>>();
52+
}
53+
54+
int main() {
55+
test<int8_t>();
56+
test<int16_t>();
57+
test<int32_t>();
58+
test<int64_t>();
59+
test<cl::sycl::cl_half>();
60+
test<float>();
61+
test<double>();
62+
return 1;
63+
}

0 commit comments

Comments
 (0)