Skip to content

Commit e600d79

Browse files
[SYCL] Improve diagnostic for nd_item passed to parallel_for with range (#10905)
1 parent 2fb0b14 commit e600d79

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

sycl/include/sycl/handler.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,10 @@ class __SYCL_EXPORT handler {
10371037
std::is_integral<LambdaArgType>::value && Dims == 1, item<Dims>,
10381038
typename TransformUserItemType<Dims, LambdaArgType>::type>;
10391039

1040+
static_assert(!std::is_same_v<TransformedArgType, sycl::nd_item<Dims>>,
1041+
"Kernel argument cannot have a sycl::nd_item type in "
1042+
"sycl::parallel_for with sycl::range");
1043+
10401044
// TODO: Properties may change the kernel function, so in order to avoid
10411045
// conflicts they should be included in the name.
10421046
using NameT =
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: not %clangxx -fsycl -fsyntax-only %s 2>&1 | FileCheck %s
2+
3+
#include <sycl/sycl.hpp>
4+
5+
using namespace sycl;
6+
7+
int main() {
8+
queue q;
9+
q.submit([&](handler &cgh) {
10+
// CHECK: Kernel argument cannot have a sycl::nd_item type in sycl::parallel_for with sycl::range
11+
cgh.parallel_for<class MyKernel>(43, [=](nd_item<1> item) {});
12+
});
13+
}

0 commit comments

Comments
 (0)