[llvm] [Offload] Implement better level zero dispatch (PR #218367)

Ɓukasz Plewa via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 05:56:31 PDT 2026


================
@@ -52,9 +54,52 @@ Error L0QueueTy::dispatchLaunchKernel(ze_kernel_handle_t Kernel,
                                       ze_event_handle_t *WaitEvents) {
   // Unlock KEnv lock after launching the kernel.
   llvm::scope_exit UnlockGuard([&KEnv]() { KEnv.Lock.unlock(); });
-  return CmdList->appendLaunchKernelWithArgs(
-      Kernel, &KEnv.GroupCounts, &KEnv.GroupSizes, KEnv.ArgPtrs, SignalEvent,
-      NumWaitEvents, WaitEvents, KEnv.IsCooperative);
+
+  bool AppendLaunchKernelWithArgsAvailable =
+      Device.getL0Context().LaunchKernelWithArguments.available();
+
+  if (AppendLaunchKernelWithArgsAvailable &&
+      Device.getL0Context().AppendLaunchKernelSupported.load(
+          std::memory_order_acquire)) {
+    auto Result = CmdList->appendLaunchKernelWithArgs(
+        Kernel, &KEnv.GroupCounts, &KEnv.GroupSizes, KEnv.ArgPtrs, SignalEvent,
+        NumWaitEvents, WaitEvents, KEnv.IsCooperative);
+
+    // Can a context have multiple users?
+    if (!Device.getL0Context().AppendLaunchKernelSupported.load(
+            std::memory_order_acquire)) {
+      // Commandlist failed to launch kernel with arguments, fallback to older
+      // API.
+      consumeError(std::move(Result));
+    } else {
----------------
lplewa wrote:

This else is not needed

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


More information about the llvm-commits mailing list