[llvm] [OFFLOAD][L0] Implement Event APIs (PR #201306)

Nick Sarnie via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 3 08:06:24 PDT 2026


================
@@ -0,0 +1,93 @@
+//===--- Level Zero Target RTL Implementation -----------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Level Zero Event and Event Pool implementations.
+//
+//===----------------------------------------------------------------------===//
+
+#include "L0Event.h"
+#include "L0Device.h"
+#include "L0Trace.h"
+
+namespace llvm::omp::target::plugin {
+
+Expected<ze_event_handle_t> EventPoolTy::getEventLocked() {
+  if (Events.empty()) {
+    // Need to create a new L0 pool.
+    ze_event_pool_desc_t Desc{ZE_STRUCTURE_TYPE_EVENT_POOL_DESC, nullptr, 0, 0};
+    Desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE | Flags;
+    Desc.count = PoolSize;
+    ze_event_pool_handle_t Pool;
+    CALL_ZE_RET_ERROR(zeEventPoolCreate, Context, &Desc, 0, nullptr, &Pool);
+    Pools.push_back(Pool);
+
+    // Create events.
+    ze_event_desc_t EventDesc{ZE_STRUCTURE_TYPE_EVENT_DESC, nullptr, 0, 0, 0};
+    EventDesc.wait = 0;
+    EventDesc.signal = ZE_EVENT_SCOPE_FLAG_HOST;
+    uint32_t CreatedEvents = 0;
+    for (uint32_t I = 0; I < PoolSize; I++) {
----------------
sarnex wrote:

```suggestion
    for (uint32_t EventIdx = 0; EventIdx  < PoolSize; EventIdx ++) {
```

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


More information about the llvm-commits mailing list