[llvm] [OFFLOAD][L0] Fix PatternSize assert in L0QueueTy::memoryFill (PR #210867)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 20:07:01 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-offload

Author: Wenju He (wenju-he)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/210867.diff


1 Files Affected:

- (modified) offload/plugins-nextgen/level_zero/src/L0Queue.cpp (+2-2) 


``````````diff
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);

``````````

</details>


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


More information about the llvm-commits mailing list