Skip to content

[libomptarget][nextgen-plugin] Add missing mutex lock #83455

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

doru1004
Copy link
Contributor

It looks like there is a potentially missing lock in the waitOnStreamOperation.

@llvmbot
Copy link
Member

llvmbot commented Feb 29, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Gheorghe-Teodor Bercea (doru1004)

Changes

It looks like there is a potentially missing lock in the waitOnStreamOperation.


Full diff: https://github.com/llvm/llvm-project/pull/83455.diff

1 Files Affected:

  • (modified) openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp (+4-1)
diff --git a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
index 81634ae1edc490..92a4b66955c7a5 100644
--- a/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
@@ -1093,7 +1093,10 @@ struct AMDGPUStreamTy {
     if (Queue == nullptr)
       return Plugin::error("Target queue was nullptr");
 
-    /// The signal that we must wait from the other stream.
+    // Guard access to the Slots data structure.
+    std::lock_guard<std::mutex> Lock(Mutex);
+
+    // The signal that we must wait from the other stream.
     AMDGPUSignalTy *OtherSignal = OtherStream.Slots[Slot].Signal;
 
     // Prevent the release of the other stream's signal.

Copy link
Contributor

@jplehr jplehr left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me.

Copy link
Contributor

@dhruvachak dhruvachak left a comment

Choose a reason for hiding this comment

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

In the caller of waitOnStreamOperation, there is below locking. Can you explain why we still need additional locking?


Error AMDGPUStreamTy::waitEvent(const AMDGPUEventTy &Event) {
// Retrieve the recorded stream on the event.
AMDGPUStreamTy &RecordedStream = *Event.RecordedStream;

std::scoped_lock<std::mutex, std::mutex> Lock(Mutex, RecordedStream.Mutex);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants