================ @@ -0,0 +1,85 @@ +//===-- Stream.cpp - Kernel language stream state -------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "Stream.h" +#include "OffloadAPI.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/SmallVector.h" + +#include <mutex> +#include <utility> + +using namespace llvm; +using namespace offload; + +static ol_result_t syncAndDestroyEvents(ArrayRef<ol_event_handle_t> Events) { + ol_result_t FirstError = OL_SUCCESS; + for (ol_event_handle_t Event : Events) { + if (!Event) + continue; + + ol_result_t SyncResult = olSyncEvent(Event); + if (FirstError == OL_SUCCESS && SyncResult != OL_SUCCESS) + FirstError = SyncResult; + + ol_result_t DestroyResult = olDestroyEvent(Event); + if (FirstError == OL_SUCCESS && DestroyResult != OL_SUCCESS) + FirstError = DestroyResult; + } + return FirstError; +} + +ol_result_t +StreamTy::waitOnAndTrackDependencyEvents(ArrayRef<ol_event_handle_t> Events) { + if (Events.empty()) + return OL_SUCCESS; + + SmallVector<ol_event_handle_t, 8> MutableEvents(Events.begin(), Events.end()); + std::lock_guard<std::mutex> LG(DependencyEventsLock); ---------------- kevinsala wrote:
Wondering if we really need the mutex acquired to perform the `olWaitEvents`. What is it protecting in this case? https://github.com/llvm/llvm-project/pull/218049 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
