llvm icon indicating copy to clipboard operation
llvm copied to clipboard

[SYCL] Flush queue on memory operations

Open fabiomestre opened this issue 2 years ago • 3 comments

https://github.com/intel/llvm/pull/9944 introduced a hack in the OpenCL PI plugin which maps PI_EVENT_QUEUED to PI_EVENT_SUBMITTED. This hack is problematic because it will make SYCL-RT assume that an event has been flushed when it might not have been. At the moment, this could result in buggy behaviour on the OpenCL backend when using multiple queues. The OpenCL specification states:

"To use event objects that refer to commands enqueued in a command-queue as event objects to wait on by commands enqueued in a different command-queue, the application must call a clFlush or any blocking commands that perform an implicit flush of the command-queue where the commands that refer to these event objects are enqueued."

This PR, changes SYCL-RT to properly flush user events if they are in the PI_EVENT_QUEUED status. This will allow the hack to be removed from unified runtime.

There was also a couple of tests that had to be updated because they made assumptions about the ordering of calls to the PI plugin layers.

fabiomestre avatar Nov 28 '23 15:11 fabiomestre

I'm not very familiar with the SYCL-RT codebase, so there might be a good reason to do this changes in a different way. It would be great if someone more familiar with the queue implementation could give feedback on this changes.

fabiomestre avatar Dec 27 '23 17:12 fabiomestre

@intel/llvm-reviewers-runtime / @againull could you have a look at these changes?

fabiomestre avatar Jan 22 '24 18:01 fabiomestre

I'm sorry for the delayed review.

againull avatar Jan 23 '24 07:01 againull

Closing this PR. Created a new PR that implements the workaround discussed here: https://github.com/intel/llvm/pull/13024

fabiomestre avatar Mar 14 '24 12:03 fabiomestre