[llvm] [offload] Add context parameter to olCreateQueue (PR #213057)
Alex Duran via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 07:34:05 PDT 2026
=?utf-8?q?Łukasz?= Plewa <lukasz.plewa at intel.com>,
=?utf-8?q?Łukasz?= Plewa <lukasz.plewa at intel.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/213057 at github.com>
================
@@ -71,70 +71,17 @@ struct ol_device_impl_t {
: DeviceNum(DeviceNum), Device(Device), Platform(Platform),
Info(std::forward<InfoTreeNode>(DevInfo)) {}
- ~ol_device_impl_t() {
- assert(!OutstandingQueues.size() &&
- "Device object dropped with outstanding queues");
- }
-
int DeviceNum;
GenericDeviceTy *Device;
ol_platform_impl_t &Platform;
InfoTreeNode Info;
-
- llvm::SmallVector<__tgt_async_info *> OutstandingQueues;
- std::mutex OutstandingQueuesMutex;
-
- /// If the device has any outstanding queues that are now complete, remove it
- /// from the list and return it.
- ///
- /// Queues may be added to the outstanding queue list by olDestroyQueue if
- /// they are destroyed but not completed.
- __tgt_async_info *getOutstandingQueue() {
- // Not locking the `size()` access is fine here - In the worst case we
- // either miss a queue that exists or loop through an empty array after
- // taking the lock. Both are sub-optimal but not that bad.
- if (OutstandingQueues.size()) {
- std::lock_guard<std::mutex> Lock(OutstandingQueuesMutex);
-
- // As queues are pulled and popped from this list, longer running queues
- // naturally bubble to the start of the array. Hence looping backwards.
- for (auto Q = OutstandingQueues.rbegin(); Q != OutstandingQueues.rend();
- Q++) {
- if (!Device->hasPendingWork(*Q)) {
- auto OutstandingQueue = *Q;
- *Q = OutstandingQueues.back();
- OutstandingQueues.pop_back();
- return OutstandingQueue;
- }
- }
- }
- return nullptr;
- }
-
- /// Complete all pending work for this device and perform any needed cleanup.
- ///
- /// After calling this function, no liboffload functions should be called with
- /// this device handle.
- llvm::Error destroy() {
- llvm::Error Result = Plugin::success();
- for (auto Q : OutstandingQueues)
- if (auto Err = Device->synchronize(Q, /*Release=*/true))
- Result = llvm::joinErrors(std::move(Result), std::move(Err));
- OutstandingQueues.clear();
- return Result;
- }
};
llvm::Error ol_platform_impl_t::destroy() {
- llvm::Error Result = Plugin::success();
- for (auto &D : Devices)
- if (auto Err = D->destroy())
----------------
adurang wrote:
got it, somehow I thought this was the GenericDevice destroy but it's not.
https://github.com/llvm/llvm-project/pull/213057
More information about the llvm-commits
mailing list