Skip to content

Commit 0ddb352

Browse files
committed
Add test for sycl::id type
1 parent a160066 commit 0ddb352

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

sycl/include/CL/sycl/handler.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,13 @@ class __SYCL_EXPORT handler {
918918

919919
template <int Dims, typename LambdaArgType> struct TransformUserItemType {
920920
using type = typename std::conditional_t<
921-
std::is_same_v<id<Dims>, LambdaArgType>, LambdaArgType,
921+
std::is_same<id<Dims>, LambdaArgType>::value, LambdaArgType,
922922
typename std::conditional_t<
923-
std::is_convertible_v<nd_item<Dims>, LambdaArgType>, nd_item<Dims>,
923+
std::is_convertible<nd_item<Dims>, LambdaArgType>::value,
924+
nd_item<Dims>,
924925
typename std::conditional_t<
925-
std::is_convertible_v<item<Dims>, LambdaArgType>, item<Dims>,
926-
LambdaArgType>>>;
926+
std::is_convertible<item<Dims>, LambdaArgType>::value,
927+
item<Dims>, LambdaArgType>>>;
927928
};
928929

929930
/// Defines and invokes a SYCL kernel function for the specified range.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clangxx -fsycl -fsycl-device-only -D__SYCL_INTERNAL_API -O0 -c -emit-llvm -S -o - %s | FileCheck %s
2+
3+
// This test performs basic type check for sycl::id that is used in result type.
4+
5+
#include <CL/sycl.hpp>
6+
#include <iostream>
7+
8+
int main() {
9+
sycl::queue q;
10+
11+
// Initialize data array
12+
const int sz = 16;
13+
int data[sz] = {0};
14+
for (int i = 0; i < sz; ++i) {
15+
data[i] = i;
16+
}
17+
18+
// Check user defined sycl::item wrapper
19+
sycl::buffer<int> data_buf(data, sz);
20+
q.submit([&](sycl::handler &h) {
21+
auto buf_acc = data_buf.get_access<sycl::access::mode::read_write>(h);
22+
h.parallel_for(
23+
sycl::range<1>{sz},
24+
// CHECK: cl{{.*}}sycl{{.*}}detail{{.*}}RoundedRangeKernel{{.*}}id{{.*}}main{{.*}}handler
25+
[=](sycl::id<1> item) { buf_acc[item] += 1; });
26+
});
27+
q.wait();
28+
29+
return 0;
30+
}

0 commit comments

Comments
 (0)