Skip to content

Commit 19436ba

Browse files
[SYCL] Add inline to get_local_linear_id (#6302)
* [SYCL] Add inline to get_local_linear_id These changes make sycl::detail::get_local_linear_id and its specializations inline. Signed-off-by: Larsen, Steffen <[email protected]> Co-authored-by: Sergey Semenov <[email protected]>
1 parent 1c813b3 commit 19436ba

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

sycl/include/CL/sycl/group_algorithm.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ get_local_linear_range<ext::oneapi::sub_group>(ext::oneapi::sub_group g) {
6565

6666
// ---- get_local_linear_id
6767
template <typename Group>
68-
typename Group::linear_id_type get_local_linear_id(Group g);
68+
inline typename Group::linear_id_type get_local_linear_id(Group g);
6969

7070
#ifdef __SYCL_DEVICE_ONLY__
7171
#define __SYCL_GROUP_GET_LOCAL_LINEAR_ID(D) \
7272
template <> \
73-
group<D>::linear_id_type get_local_linear_id<group<D>>(group<D>) { \
73+
inline group<D>::linear_id_type get_local_linear_id<group<D>>(group<D>) { \
7474
nd_item<D> it = cl::sycl::detail::Builder::getNDItem<D>(); \
7575
return it.get_local_linear_id(); \
7676
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fPIC -DCASE1 %s -c -o %t.1.o
2+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -fPIC -DCASE2 %s -c -o %t.2.o
3+
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple -shared %t.1.o %t.2.o -o %t.so
4+
5+
// Tests that creating a shared library with multiple object files using joint
6+
// group operations does not cause conflicting definitions.
7+
8+
#include <CL/sycl.hpp>
9+
10+
#ifdef CASE1
11+
#define FNAME test1
12+
#define KNAME kernel1
13+
#else
14+
#define FNAME test2
15+
#define KNAME kernel2
16+
#endif
17+
18+
void FNAME(sycl::queue &Q, bool *In, bool *Out) {
19+
sycl::nd_range<1> WorkRange(sycl::range<1>(8), sycl::range<1>(16));
20+
Q.parallel_for<class KNAME>(WorkRange, [=](sycl::nd_item<1> It) {
21+
sycl::group<1> Group = It.get_group();
22+
size_t I = It.get_global_linear_id();
23+
Out[I] = sycl::joint_any_of(Group, In, In, [](bool B) { return B; });
24+
}).wait();
25+
}

0 commit comments

Comments
 (0)