From bcde1af59d0a3c9c6f596c9144b89e61f30ce40f Mon Sep 17 00:00:00 2001 From: Wenju He Date: Tue, 21 Jul 2026 02:20:16 -0700 Subject: [PATCH] [OFFLOAD][L0] Fix PatternSize assert in L0QueueTy::memoryFill (#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. --- 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 f9c5bf11286c..767c84ff80fe 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);