[llvm] [Offload] Implement event sync in amdgpu (PR #149300)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 17 07:42:32 PDT 2025


================
@@ -1575,6 +1592,21 @@ struct AMDGPUEventTy {
     return Stream.waitEvent(*this);
   }
 
+  Error sync() {
+    std::lock_guard<std::mutex> Lock(Mutex);
----------------
RossBrunton wrote:

I cribbed this function from `wait` above, which does a similar thing and also protects the event with a mutex. But looking at them both closely, I'm not sure why either need to be guarded. The only way I can see it being required is if you `wait`/`sync` on an event that is in the middle of a `record`... But I'm not sure if that can ever happen. If we do remove the mutex, I think it makes sense to remove it entirely and as a separate change just to make it easier to track down if it does cause issues.

For `synchronizeOn`, I think it is required because another thread (or callback handler) could add, synchronise, wait or finalize an event while `synchronizeOn` is running.

https://github.com/llvm/llvm-project/pull/149300


More information about the llvm-commits mailing list