Skip to content

Commit 963df1a

Browse files
committed
A fallback mechanism for kernels with kernel_handler
1 parent dbe0fb9 commit 963df1a

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ void single_task(queue Q, const KernelType &KernelObj,
154154
sycl::detail::code_location::current()) {
155155
if constexpr (!(ext::oneapi::experimental::detail::
156156
HasKernelPropertiesGetMethod<
157-
const KernelType &>::value)) {
157+
const KernelType &>::value) &&
158+
!(detail::KernelLambdaHasKernelHandlerArgT<KernelType,
159+
void>::value)) {
158160
detail::submit_kernel_direct_single_task<KernelName>(
159161
std::move(Q), empty_properties_t{}, KernelObj, CodeLoc);
160162
} else {
@@ -272,7 +274,9 @@ void nd_launch(queue Q, nd_range<Dimensions> Range, const KernelType &KernelObj,
272274
if constexpr (sizeof...(ReductionsT) == 0 &&
273275
!(ext::oneapi::experimental::detail::
274276
HasKernelPropertiesGetMethod<
275-
const KernelType &>::value)) {
277+
const KernelType &>::value) &&
278+
!(detail::KernelLambdaHasKernelHandlerArgT<
279+
KernelType, sycl::nd_item<Dimensions>>::value)) {
276280
detail::submit_kernel_direct_parallel_for<KernelName>(std::move(Q), empty_properties_t{},
277281
Range, KernelObj);
278282
} else {

sycl/include/sycl/khr/free_function_commands.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ void launch_grouped(const queue &q, range<1> r, range<1> size, KernelType &&k,
160160
// TODO The handler-less path does not support kernel function properties yet.
161161
if constexpr (!(ext::oneapi::experimental::detail::
162162
HasKernelPropertiesGetMethod<
163-
const KernelType &>::value)) {
163+
const KernelType &>::value) &&
164+
!(detail::KernelLambdaHasKernelHandlerArgT<
165+
KernelType, sycl::nd_item<1>>::value)) {
164166
detail::submit_kernel_direct_parallel_for(
165167
q, ext::oneapi::experimental::empty_properties_t{},
166168
nd_range<1>(r, size), std::forward<KernelType>(k));
@@ -178,7 +180,9 @@ void launch_grouped(const queue &q, range<2> r, range<2> size, KernelType &&k,
178180
// TODO The handler-less path does not support kernel function properties yet.
179181
if constexpr (!(ext::oneapi::experimental::detail::
180182
HasKernelPropertiesGetMethod<
181-
const KernelType &>::value)) {
183+
const KernelType &>::value) &&
184+
!(detail::KernelLambdaHasKernelHandlerArgT<
185+
KernelType, sycl::nd_item<2>>::value)) {
182186
detail::submit_kernel_direct_parallel_for(
183187
q, ext::oneapi::experimental::empty_properties_t{},
184188
nd_range<2>(r, size), std::forward<KernelType>(k));
@@ -196,7 +200,9 @@ void launch_grouped(const queue &q, range<3> r, range<3> size, KernelType &&k,
196200
// TODO The handler-less path does not support kernel function properties yet.
197201
if constexpr (!(ext::oneapi::experimental::detail::
198202
HasKernelPropertiesGetMethod<
199-
const KernelType &>::value)) {
203+
const KernelType &>::value) &&
204+
!(detail::KernelLambdaHasKernelHandlerArgT<
205+
KernelType, sycl::nd_item<3>>::value)) {
200206
detail::submit_kernel_direct_parallel_for(
201207
q, ext::oneapi::experimental::empty_properties_t{},
202208
nd_range<3>(r, size), std::forward<KernelType>(k));
@@ -316,7 +322,9 @@ void launch_task(const sycl::queue &q, const KernelType &k,
316322
sycl::detail::code_location::current()) {
317323
if constexpr (!(ext::oneapi::experimental::detail::
318324
HasKernelPropertiesGetMethod<
319-
const KernelType &>::value)) {
325+
const KernelType &>::value) &&
326+
!(detail::KernelLambdaHasKernelHandlerArgT<KernelType,
327+
void>::value)) {
320328
detail::submit_kernel_direct_single_task(
321329
q, ext::oneapi::experimental::empty_properties_t{}, k, codeLoc);
322330
} else {

sycl/include/sycl/queue.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,12 +2800,12 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
28002800
"sycl::queue.single_task() requires a kernel instead of command group. "
28012801
"Use queue.submit() instead");
28022802

2803-
if constexpr (std::is_same_v<
2804-
PropertiesT,
2805-
ext::oneapi::experimental::empty_properties_t> &&
2806-
!(ext::oneapi::experimental::detail::
2807-
HasKernelPropertiesGetMethod<
2808-
const KernelType &>::value)) {
2803+
if constexpr (
2804+
std::is_same_v<PropertiesT,
2805+
ext::oneapi::experimental::empty_properties_t> &&
2806+
!(ext::oneapi::experimental::detail::HasKernelPropertiesGetMethod<
2807+
const KernelType &>::value) &&
2808+
!(detail::KernelLambdaHasKernelHandlerArgT<KernelType, void>::value)) {
28092809
(void)Properties;
28102810
return detail::submit_kernel_direct_single_task<KernelName, true>(
28112811
*this, ext::oneapi::experimental::empty_properties_t{},
@@ -3373,7 +3373,9 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
33733373
if constexpr (sizeof...(RestT) == 1 &&
33743374
!(ext::oneapi::experimental::detail::
33753375
HasKernelPropertiesGetMethod<
3376-
const KernelType &>::value)) {
3376+
const KernelType &>::value) &&
3377+
!(detail::KernelLambdaHasKernelHandlerArgT<
3378+
KernelType, sycl::nd_item<Dims>>::value)) {
33773379
return detail::submit_kernel_direct_parallel_for<KernelName, true>(
33783380
*this, ext::oneapi::experimental::empty_properties_t{}, Range,
33793381
Rest...);

0 commit comments

Comments
 (0)