Skip to content

[SYCL] Fix a race condition when enqueueing an interop kernel #8111

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 3 commits into from
Jan 27, 2023

Conversation

sergey-semenov
Copy link
Contributor

piKernelSetArg isn't supposed to be called from different threads on the same kernel.

piKernelSetArg isn't supposed to be called from different threads
on the same kernel.
@sergey-semenov sergey-semenov requested a review from a team as a code owner January 26, 2023 15:27
@sergey-semenov sergey-semenov temporarily deployed to aws January 26, 2023 15:52 — with GitHub Actions Inactive
@sergey-semenov sergey-semenov temporarily deployed to aws January 26, 2023 16:24 — with GitHub Actions Inactive
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

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

LGTM!

@bader
Copy link
Contributor

bader commented Jan 27, 2023

Failed Tests (1):
SYCL :: dword_atomic_smoke.cpp

@sergey-semenov sergey-semenov requested a review from bader January 27, 2023 11:50
@sergey-semenov sergey-semenov temporarily deployed to aws January 27, 2023 12:17 — with GitHub Actions Inactive
@sergey-semenov sergey-semenov temporarily deployed to aws January 27, 2023 13:22 — with GitHub Actions Inactive
@sergey-semenov sergey-semenov merged commit adebd42 into intel:sycl Jan 27, 2023
@sergey-semenov sergey-semenov deleted the fixinteropracecond branch January 27, 2023 16:54
// cache, others (e.g. interoperability kernels) share a single mutex.
// TODO consider adding a PiKernel -> mutex map for allowing to enqueue
// different PiKernel's in parallel.
static std::mutex NoncacheableEnqueueMutex;
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be probably better to have an std::mutexstored in kernel_impl. So, we do not serialize submission of different sycl::kernels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@romanovvlad I tend to agree, although wouldn't this mutex need to be tied to pi_kernel like described in the comment above? Otherwise we will run into issues if two interop sycl::kernel are created with the same native kernel.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds reasonable.

sergey-semenov added a commit to sergey-semenov/llvm that referenced this pull request Jan 31, 2023
Switch from using a single mutex to one per kernel when enqueueing
interoperability kernels. Compared to the original solution (intel#8111),
this allows to enqueue different interop SYCL kernels in parallel, but
leaves out an edge case where two SYCL kernels were created with the
same native handle.
sergey-semenov added a commit that referenced this pull request Feb 2, 2023
Switch from using a single mutex to one per kernel when enqueueing
interoperability kernels. Compared to the original solution (#8111),
this allows to enqueue different interop SYCL kernels in parallel, but
leaves out an edge case where two SYCL kernels were created with the
same native handle.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants