[llvm-branch-commits] [clang] [llvm] [Offload][Lang] Add blocking to LaunchKernel and Memcpy (PR #218049)
Kevin Sala Penades via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 27 12:03:16 PDT 2026
================
@@ -61,18 +61,77 @@ static inline StreamTy *toInternalStream(Stream_t Stream) {
return reinterpret_cast<StreamTy *>(Stream);
}
-/// Convert a Stream_t to an ol_queue_handle_t.
-static inline Error_t getQueueFromStream(Stream_t Stream,
- ol_queue_handle_t *Queue) {
- if (!Stream)
- return ErrorInvalidValue;
+static inline ol_result_t
+syncAndDestroyEvents(llvm::SmallVectorImpl<ol_event_handle_t> &Events) {
+ ol_result_t FirstError = OL_SUCCESS;
+ for (ol_event_handle_t Event : Events) {
+ if (!Event)
+ continue;
- StreamTy *InternalStream = toInternalStream(Stream);
- if (!StateTy::get().isStreamRegistered(InternalStream))
- return ErrorInvalidResourceHandle;
+ ol_result_t SyncResult = olSyncEvent(Event);
+ if (FirstError == OL_SUCCESS && SyncResult != OL_SUCCESS)
+ FirstError = SyncResult;
- *Queue = InternalStream->Queue;
- return Success;
+ ol_result_t DestroyResult = olDestroyEvent(Event);
+ if (FirstError == OL_SUCCESS && DestroyResult != OL_SUCCESS)
+ FirstError = DestroyResult;
+ }
+ Events.clear();
+ return FirstError;
+}
+
+/// Wait for blocking streams before executing if we are legacy default stream.
+static inline ol_result_t waitOnBlockingStreams() {
----------------
kevinsala wrote:
I recommend passing state and thread state in these functions as reference. For `waitOnBlockingStreams` and `waitOnLegacyDefaultStream`.
https://github.com/llvm/llvm-project/pull/218049
More information about the llvm-branch-commits
mailing list