Skip to content

[SYCL] Add SYCL-2020 method handler::host_task() #3837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 36 additions & 24 deletions sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,23 @@ class __SYCL_EXPORT handler {
void setHandlerKernelBundle(
const std::shared_ptr<detail::kernel_bundle_impl> &NewKernelBundleImpPtr);

template <typename FuncT>
detail::enable_if_t<
detail::check_fn_signature<detail::remove_reference_t<FuncT>,
void()>::value ||
detail::check_fn_signature<detail::remove_reference_t<FuncT>,
void(interop_handle)>::value>
host_task_impl(FuncT &&Func) {
throwIfActionIsCreated();

MNDRDesc.set(range<1>(1));
MArgs = std::move(MAssociatedAccesors);

MHostTask.reset(new detail::HostTask(std::move(Func)));

setType(detail::CG::CODEPLAY_HOST_TASK);
}

public:
handler(const handler &) = delete;
handler(handler &&) = delete;
Expand Down Expand Up @@ -1231,31 +1248,26 @@ class __SYCL_EXPORT handler {
}

template <typename FuncT>
detail::enable_if_t<detail::check_fn_signature<
detail::remove_reference_t<FuncT>, void()>::value>
codeplay_host_task(FuncT Func) {
throwIfActionIsCreated();

MNDRDesc.set(range<1>(1));
MArgs = std::move(MAssociatedAccesors);

MHostTask.reset(new detail::HostTask(std::move(Func)));

setType(detail::CG::CODEPLAY_HOST_TASK);
}

__SYCL2020_DEPRECATED(
"codeplay_host_task() is deprecated, use host_task() instead")
detail::enable_if_t<
detail::check_fn_signature<detail::remove_reference_t<FuncT>,
void()>::value ||
detail::check_fn_signature<
detail::remove_reference_t<FuncT>,
void(interop_handle)>::value> codeplay_host_task(FuncT Func) {
host_task_impl(Func);
}

/// Enqueues a command to the SYCL runtime to invoke \p Func once.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment describing enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the code-review!
I copied the comment from SYCL-2020 SPEC, which does not give any additional info other than this.

template <typename FuncT>
detail::enable_if_t<detail::check_fn_signature<
detail::remove_reference_t<FuncT>, void(interop_handle)>::value>
codeplay_host_task(FuncT Func) {
throwIfActionIsCreated();

MNDRDesc.set(range<1>(1));
MArgs = std::move(MAssociatedAccesors);

MHostTask.reset(new detail::HostTask(std::move(Func)));

setType(detail::CG::CODEPLAY_HOST_TASK);
detail::enable_if_t<
detail::check_fn_signature<detail::remove_reference_t<FuncT>,
void()>::value ||
detail::check_fn_signature<detail::remove_reference_t<FuncT>,
void(interop_handle)>::value>
host_task(FuncT &&Func) {
host_task_impl(Func);
}

// replace _KERNELFUNCPARAM(KernelFunc) with KernelType KernelFunc
Expand Down