2

I have a collection of thousands of SYCL kernels to execute. Once each of these kernels has finished, I need to execute a function on a cl::sycl::buffer written to by said kernel.

The methods I'm aware of for achieving this are:

  • by using RAII; the requisite global memory is copied back to the host upon destruction of the cl::sycl::buffer
  • by constructing a host cl::sycl::accessor (with cl::sycl::access::target::host_buffer)

Both of these methods are synchronous and blocking. Is it possible to instead attach an asynchronous callback/continuation when submitting kernels to a cl::sycl::queue that executes as soon as the kernel has finished? Or even better, can the same functionality be achieved with C++2a coroutines? If not, is such a feature planned for SYCL?

invexed
  • 645
  • 3
  • 10

1 Answers1

3

The feature to attach callbacks or execute on the host from a SYCL queue did not make the cut for SYCL 1.2.1.

There are some proposals being discussed at the moment to bring that feature into the next version of the standard, but everything is still internal to the SYCL group.

In the meantime, if you use ComputeCpp, you can use the host_handler extension, which allows you to execute a lambda on the host based on dependencies from the device. The open source compiler doesn't have that feature yet that I've seen.

Ruyk
  • 775
  • 5
  • 11
  • Thanks for your answer. Unfortunately I'm not using ComputeCpp so for now I spawn a thread which maintains and periodically polls a collection of ```sycl::event```s (returned when submitting to the ```sycl::queue```) to determine when the ```info::event::command_execution_status``` becomes ```info::event_command_status::complete```. – invexed Dec 13 '19 at 14:27
  • SYCL 2020 has now a "Host tasks" feature, See Section "4.11 Host tasks" of the [SYCL 2020 Provisional specification](https://www.khronos.org/registry/SYCL/specs/sycl-2020-provisional.pdf ). This has been implemented in DPC++, Intel's implementation of SYCL. – Ruyk Feb 02 '21 at 13:56