[llvm] [Offload] Implement better level zero dispatch (PR #218367)
Ćukasz Plewa via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 07:36:58 PDT 2026
================
@@ -52,9 +54,62 @@ 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 Err = CmdList->appendLaunchKernelWithArgs(
+ Kernel, &KEnv.GroupCounts, &KEnv.GroupSizes, KEnv.ArgPtrs, SignalEvent,
+ NumWaitEvents, WaitEvents, KEnv.IsCooperative);
+
+ if (!Err)
+ return Plugin::success();
+
+ // Check if Err is ErrorCode::UNSUPPORTED, if so consume it
+ Err = llvm::handleErrors(
+ std::move(Err),
+ [&](std::unique_ptr<error::OffloadError> E) -> llvm::Error {
+ if (E->convertToErrorCode() ==
+ error::make_error_code(error::ErrorCode::UNSUPPORTED))
+ return llvm::Error::success(); // Swallow error
+ return llvm::Error(std::move(E));
+ });
+
+ if (Err) {
+ // Err is still here, so it was not ErrorCode::UNSUPPORTED
+ return Err;
+ }
----------------
lplewa wrote:
```suggestion
// Err is still here, so it was not ErrorCode::UNSUPPORTED
if (Err)
return Err;
```
https://github.com/llvm/llvm-project/pull/218367
More information about the llvm-commits
mailing list