Skip to content

Commit 9564695

Browse files
committed
Properties fallback for single_task
1 parent f3c0959 commit 9564695

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,17 @@ template <typename KernelName = sycl::detail::auto_name, typename KernelType>
152152
void single_task(queue Q, const KernelType &KernelObj,
153153
const sycl::detail::code_location &CodeLoc =
154154
sycl::detail::code_location::current()) {
155-
/*
156-
submit(
157-
std::move(Q),
158-
[&](handler &CGH) { single_task<KernelName>(CGH, KernelObj); }, CodeLoc);
159-
*/
160-
detail::submit_kernel_direct_single_task<KernelName>(
161-
std::move(Q), empty_properties_t{}, KernelObj, CodeLoc);
155+
if constexpr (!(ext::oneapi::experimental::detail::
156+
HasKernelPropertiesGetMethod<
157+
const KernelType &>::value)) {
158+
detail::submit_kernel_direct_single_task<KernelName>(
159+
std::move(Q), empty_properties_t{}, KernelObj, CodeLoc);
160+
} else {
161+
submit(
162+
std::move(Q),
163+
[&](handler &CGH) { single_task<KernelName>(CGH, KernelObj); },
164+
CodeLoc);
165+
}
162166
}
163167

164168
template <typename... ArgsT>

sycl/include/sycl/khr/free_function_commands.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,15 @@ template <typename KernelType>
314314
void launch_task(const sycl::queue &q, const KernelType &k,
315315
const sycl::detail::code_location &codeLoc =
316316
sycl::detail::code_location::current()) {
317-
//submit(q, [&](handler &h) { launch_task<KernelType>(h, k); }, codeLoc);
318-
detail::submit_kernel_direct_single_task(q,
319-
ext::oneapi::experimental::empty_properties_t{},
320-
k, codeLoc);
317+
if constexpr (!(ext::oneapi::experimental::detail::
318+
HasKernelPropertiesGetMethod<
319+
const KernelType &>::value)) {
320+
detail::submit_kernel_direct_single_task(
321+
q, ext::oneapi::experimental::empty_properties_t{}, k, codeLoc);
322+
} else {
323+
submit(
324+
q, [&](handler &h) { launch_task<KernelType>(h, k); }, codeLoc);
325+
}
321326
}
322327

323328
template <typename... Args>

sycl/include/sycl/queue.hpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,21 +2767,23 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
27672767
void(kernel_handler)>::value),
27682768
"sycl::queue.single_task() requires a kernel instead of command group. "
27692769
"Use queue.submit() instead");
2770-
/*
2771-
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
2772-
return submit(
2773-
[&](handler &CGH) {
2774-
CGH.template single_task<KernelName, KernelType, PropertiesT>(
2775-
Properties, KernelFunc);
2776-
},
2777-
TlsCodeLocCapture.query());
2778-
*/
27792770

2771+
if constexpr (!(ext::oneapi::experimental::detail::
2772+
HasKernelPropertiesGetMethod<
2773+
const KernelType &>::value)) {
27802774
(void)Properties;
27812775
return detail::submit_kernel_direct_single_task<KernelName, true>(
27822776
*this, ext::oneapi::experimental::empty_properties_t{},
27832777
KernelFunc, CodeLoc);
2784-
2778+
} else {
2779+
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
2780+
return submit(
2781+
[&](handler &CGH) {
2782+
CGH.template single_task<KernelName, KernelType, PropertiesT>(
2783+
Properties, KernelFunc);
2784+
},
2785+
TlsCodeLocCapture.query());
2786+
}
27852787
}
27862788

27872789
/// single_task version with a kernel represented as a lambda.

0 commit comments

Comments
 (0)