[llvm] [OFFLOAD][L0] Fix PatternSize assert in L0QueueTy::memoryFill (PR #210867)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 20:06:17 PDT 2026
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/210867
The message was the opposite of the assert condition.
In addition, when PatternSize == Size the caller wants to fill the region with exactly one copy of the pattern, which is a valid operation.
The issue was found by AI.
Also check `Size % PatternSize == 0` per L0 spec.
>From cf5e4040ed0d62c9df702fdb7416a9277ca684fe Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Tue, 21 Jul 2026 05:05:13 +0200
Subject: [PATCH] [OFFLOAD][L0] Fix PatternSize assert in L0QueueTy::memoryFill
The message was the opposite of the assert condition.
In addition, when PatternSize == Size the caller wants to fill the
region with exactly one copy of the pattern, which is a valid operation.
The issue was found by AI.
Also check `Size % PatternSize == 0` per L0 spec.
---
offload/plugins-nextgen/level_zero/src/L0Queue.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/level_zero/src/L0Queue.cpp b/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
index f9c5bf11286c5..767c84ff80fe7 100644
--- a/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
+++ b/offload/plugins-nextgen/level_zero/src/L0Queue.cpp
@@ -65,12 +65,12 @@ Error L0QueueTy::dispatchLaunchKernel(ze_kernel_handle_t Kernel,
Error L0QueueTy::memoryFill(void *Ptr, const void *Pattern, size_t PatternSize,
size_t Size) {
- assert(PatternSize < Size && "PatternSize < Size is unsupported");
+ assert(PatternSize <= Size && "PatternSize > Size is unsupported");
if (Size == 0 || PatternSize == 0)
return Plugin::success();
- if (llvm::isPowerOf2_64(PatternSize) &&
+ if (llvm::isPowerOf2_64(PatternSize) && (Size % PatternSize == 0) &&
PatternSize <= Device.getMaxMemFillPatternSize()) {
// Native L0 memory fill is possible directly.
return memoryFillImpl(Ptr, Pattern, PatternSize, Size);
More information about the llvm-commits
mailing list