fix: Reset kernelWithAssertAppended flag

On new append calls, reset flag if previous submissions
are completed.

Related-To: NEO-16184

Signed-off-by: Bellekallu Rajkiran <bellekallu.rajkiran@intel.com>
This commit is contained in:
Bellekallu Rajkiran
2025-09-23 15:28:27 +00:00
committed by Compute-Runtime-Automation
parent cf35f8b40e
commit 9cccbcabe1
4 changed files with 109 additions and 1 deletions

View File

@@ -260,6 +260,7 @@ struct CommandListCoreFamilyImmediate : public CommandListCoreFamily<gfxCoreFami
ze_result_t stagingStatusToL0(const NEO::StagingTransferStatus &status) const;
size_t estimateAdditionalSizeAppendRegularCommandLists(uint32_t numCommandLists, ze_command_list_handle_t *phCommandLists);
void setupFlagsForBcsSplit(CmdListMemoryCopyParams &memoryCopyParams, bool &hasStallingCmds, bool &copyOffloadFlush, const void *srcPtr, void *dstPtr, size_t srcSize, size_t dstSize);
void tryResetKernelWithAssertFlag();
MOCKABLE_VIRTUAL void checkAssert();
ComputeFlushMethodType computeFlushMethod = nullptr;

View File

@@ -547,12 +547,31 @@ bool CommandListCoreFamilyImmediate<gfxCoreFamily>::hasStallingCmdsForRelaxedOrd
return (!relaxedOrderingDispatch && (numWaitEvents > 0 || this->hasInOrderDependencies()));
}
template <GFXCORE_FAMILY gfxCoreFamily>
void CommandListCoreFamilyImmediate<gfxCoreFamily>::tryResetKernelWithAssertFlag() {
if (!this->kernelWithAssertAppended) {
return;
}
auto cmdQueueImp = static_cast<CommandQueueImp *>(this->cmdQImmediate);
auto csr = cmdQueueImp->getCsr();
auto submittedTaskCount = cmdQueueImp->getTaskCount();
auto *tagAddress = csr->getTagAddress();
if (csr->testTaskCountReady(tagAddress, submittedTaskCount)) {
this->kernelWithAssertAppended = false;
}
}
template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernel(
ze_kernel_handle_t kernelHandle, const ze_group_count_t &threadGroupDimensions,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents,
CmdListKernelLaunchParams &launchParams) {
tryResetKernelWithAssertFlag();
bool relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents, false);
bool stallingCmdsForRelaxedOrdering = hasStallingCmdsForRelaxedOrdering(numWaitEvents, relaxedOrderingDispatch);
@@ -603,6 +622,8 @@ template <GFXCORE_FAMILY gfxCoreFamily>
ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendLaunchKernelIndirect(
ze_kernel_handle_t kernelHandle, const ze_group_count_t &pDispatchArgumentsBuffer,
ze_event_handle_t hSignalEvent, uint32_t numWaitEvents, ze_event_handle_t *phWaitEvents, bool relaxedOrderingDispatch) {
tryResetKernelWithAssertFlag();
relaxedOrderingDispatch = isRelaxedOrderingDispatchAllowed(numWaitEvents, false);
checkAvailableSpace(numWaitEvents, relaxedOrderingDispatch, commonImmediateCommandSize, false);

View File

@@ -227,7 +227,7 @@ TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithSyncModeWhenKern
EXPECT_FALSE(commandList->hasKernelWithAssert());
}
TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithASynchronousModeWhenKernelWithAssertAppendedThenHasKernelWithAssertIsSetFalseOnlyAfterSynchronize) {
TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithASynchronousModeWhenKernelWithAssertAppendedThenHasKernelWithAssertIsSetFalseAfterSynchronize) {
auto assertHandler = new MockAssertHandler(device->getNEODevice());
device->getNEODevice()->getRootDeviceEnvironmentRef().assertHandler.reset(assertHandler);
@@ -261,6 +261,84 @@ TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWithASynchronousMode
EXPECT_FALSE(commandList->hasKernelWithAssert());
}
TEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWhenKernelWithAssertAppendedInAsyncModeThenHasKernelWithAssertIsSetFalseWithNextAppendCall) {
auto assertHandler = new MockAssertHandler(device->getNEODevice());
device->getNEODevice()->getRootDeviceEnvironmentRef().assertHandler.reset(assertHandler);
ze_result_t result;
Mock<Module> module(device, nullptr, ModuleType::user);
Mock<KernelImp> kernel;
kernel.module = &module;
ze_command_queue_desc_t desc = {};
desc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
desc.pNext = 0;
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
std::unique_ptr<L0::CommandList> commandList(CommandList::createImmediate(NEO::defaultHwInfo->platform.eProductFamily, device, &desc, false,
NEO::EngineGroupType::renderCompute, result));
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
ze_group_count_t groupCount{1, 1, 1};
kernel.descriptor.kernelAttributes.flags.usesAssert = true;
CmdListKernelLaunchParams launchParams = {};
result = commandList->appendLaunchKernel(kernel.toHandle(), groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_TRUE(commandList->hasKernelWithAssert());
kernel.descriptor.kernelAttributes.flags.usesAssert = false;
result = commandList->appendLaunchKernel(kernel.toHandle(), groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_FALSE(commandList->hasKernelWithAssert());
}
HWTEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListAndKernelWithAssertAppendedWhenLaunchKernelIsAppendedWithPreviousTaskNotCompletedInAsyncModeThenHasKernelWithAssertIsSetTrue) {
auto assertHandler = new MockAssertHandler(device->getNEODevice());
device->getNEODevice()->getRootDeviceEnvironmentRef().assertHandler.reset(assertHandler);
ze_result_t result;
Mock<Module> module(device, nullptr, ModuleType::user);
Mock<KernelImp> kernel;
kernel.module = &module;
ze_command_queue_desc_t desc = {};
desc.stype = ZE_STRUCTURE_TYPE_COMMAND_QUEUE_DESC;
desc.pNext = 0;
desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS;
auto &csr = neoDevice->getUltCommandStreamReceiver<FamilyType>();
MockCommandListImmediateHw<FamilyType::gfxCoreFamily> cmdList;
cmdList.callBaseExecute = true;
cmdList.cmdListType = CommandList::CommandListType::typeImmediate;
cmdList.isSyncModeQueue = false;
auto commandQueue = CommandQueue::create(productFamily, device, &csr, &desc, cmdList.isCopyOnly(false), false, false, result);
cmdList.cmdQImmediate = commandQueue;
result = cmdList.initialize(device, NEO::EngineGroupType::renderCompute, 0u);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
cmdList.getCmdContainer().setImmediateCmdListCsr(&csr);
ze_group_count_t groupCount{1, 1, 1};
kernel.descriptor.kernelAttributes.flags.usesAssert = true;
CmdListKernelLaunchParams launchParams = {};
result = cmdList.appendLaunchKernel(kernel.toHandle(), groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_TRUE(cmdList.hasKernelWithAssert());
kernel.descriptor.kernelAttributes.flags.usesAssert = false;
csr.testTaskCountReadyReturnValue = false;
result = cmdList.appendLaunchKernel(kernel.toHandle(), groupCount, nullptr, 0, nullptr, launchParams);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
EXPECT_TRUE(cmdList.hasKernelWithAssert());
}
HWTEST_F(CommandListImmediateWithAssert, GivenImmediateCmdListWhenCheckingAssertThenPrintMessageAndAbortOnAssertHandlerIsCalled) {
ze_result_t result;
ze_command_queue_desc_t desc = {};