mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 15:03:02 +08:00
feature: return error when CB Event is passed to non-inOrder CmdList
Related-To: NEO-8145 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ce5fdf7091
commit
9779f66fde
@@ -191,7 +191,7 @@ struct CommandListCoreFamily : CommandListImp {
|
||||
ze_result_t executeCommandListImmediateImpl(bool performMigration, L0::CommandQueue *cmdQImmediate);
|
||||
size_t getReserveSshSize();
|
||||
void patchInOrderCmds() override;
|
||||
void handleCounterBasedEventTransition(Event *signalEvent);
|
||||
bool handleCounterBasedEventOperations(Event *signalEvent);
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL ze_result_t appendMemoryCopyKernelWithGA(void *dstPtr, NEO::GraphicsAllocation *dstPtrAlloc,
|
||||
|
||||
@@ -363,7 +363,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernel(ze_kernel_h
|
||||
}
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(event);
|
||||
if (!handleCounterBasedEventOperations(event)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto res = appendLaunchKernelWithParams(Kernel::fromHandle(kernelHandle), threadGroupDimensions,
|
||||
event, launchParams);
|
||||
@@ -402,7 +404,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchCooperativeKernel(
|
||||
event->resetKernelCountAndPacketUsedCount();
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(event);
|
||||
if (!handleCounterBasedEventOperations(event)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
CmdListKernelLaunchParams launchParams = {};
|
||||
launchParams.isCooperative = true;
|
||||
@@ -442,7 +446,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchKernelIndirect(ze_
|
||||
launchParams.isHostSignalScopeEvent = event->isSignalScope(ZE_EVENT_SCOPE_FLAG_HOST);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(event);
|
||||
if (!handleCounterBasedEventOperations(event)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(event, true, false);
|
||||
launchParams.isIndirect = true;
|
||||
@@ -482,7 +488,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendLaunchMultipleKernelsInd
|
||||
launchParams.isHostSignalScopeEvent = event->isSignalScope(ZE_EVENT_SCOPE_FLAG_HOST);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(event);
|
||||
if (!handleCounterBasedEventOperations(event)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(event, true, false);
|
||||
auto allocData = device->getDriverHandle()->getSvmAllocsManager()->getSVMAlloc(static_cast<const void *>(pNumLaunchArguments));
|
||||
@@ -580,7 +588,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryRangesBarrier(uint
|
||||
signalEvent = Event::fromHandle(hSignalEvent);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
applyMemoryRangesBarrier(numRanges, pRangeSizes, pRanges);
|
||||
@@ -1240,7 +1250,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopyBlitRegion(Ali
|
||||
return ret;
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
auto &rootDeviceEnvironment = device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()];
|
||||
@@ -1428,7 +1440,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryCopy(void *dstptr,
|
||||
dcFlush = getDcFlushRequired(signalEvent->isSignalScope());
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
launchParams.numKernelsInSplitLaunch = kernelCounter;
|
||||
launchParams.isKernelSplitOperation = kernelCounter > 1;
|
||||
@@ -1847,7 +1861,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendMemoryFill(void *ptr,
|
||||
return res;
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
bool hostPointerNeedsFlush = false;
|
||||
|
||||
@@ -2097,7 +2113,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendBlitFill(void *ptr,
|
||||
return ret;
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto neoDevice = device->getNEODevice();
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
@@ -2342,7 +2360,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendSignalEvent(ze_event_han
|
||||
auto event = Event::fromHandle(hEvent);
|
||||
event->resetKernelCountAndPacketUsedCount();
|
||||
|
||||
handleCounterBasedEventTransition(event);
|
||||
if (!handleCounterBasedEventOperations(event)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
commandContainer.addToResidencyContainer(&event->getAllocation(this->device));
|
||||
NEO::Device *neoDevice = device->getNEODevice();
|
||||
@@ -2642,7 +2662,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWriteGlobalTimestamp(
|
||||
signalEvent = Event::fromHandle(hSignalEvent);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
|
||||
@@ -3161,7 +3183,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendBarrier(ze_event_handle_
|
||||
signalEvent = Event::fromHandle(hSignalEvent);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
|
||||
@@ -3314,7 +3338,9 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendWaitOnMemory(void *desc,
|
||||
handleInOrderImplicitDependencies(false);
|
||||
}
|
||||
|
||||
handleCounterBasedEventTransition(signalEvent);
|
||||
if (!handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
appendEventForProfiling(signalEvent, true, false);
|
||||
|
||||
@@ -3603,18 +3629,26 @@ bool CommandListCoreFamily<gfxCoreFamily>::hasInOrderDependencies() const {
|
||||
}
|
||||
|
||||
template <GFXCORE_FAMILY gfxCoreFamily>
|
||||
void CommandListCoreFamily<gfxCoreFamily>::handleCounterBasedEventTransition(Event *signalEvent) {
|
||||
if (signalEvent && (NEO::DebugManager.flags.EnableImplicitConvertionToCounterBasedEvents.get() == 1)) {
|
||||
if (signalEvent->isCounterBasedExplicitlyEnabled()) {
|
||||
return;
|
||||
bool CommandListCoreFamily<gfxCoreFamily>::handleCounterBasedEventOperations(Event *signalEvent) {
|
||||
if (signalEvent) {
|
||||
if (signalEvent->isCounterBased() && !isInOrderExecutionEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isInOrderExecutionEnabled() && (this->cmdListType == TYPE_IMMEDIATE)) {
|
||||
signalEvent->enableCounterBasedMode(false);
|
||||
} else {
|
||||
signalEvent->disableImplicitCounterBasedMode();
|
||||
if ((NEO::DebugManager.flags.EnableImplicitConvertionToCounterBasedEvents.get() == 1)) {
|
||||
if (signalEvent->isCounterBasedExplicitlyEnabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isInOrderExecutionEnabled() && (this->cmdListType == TYPE_IMMEDIATE)) {
|
||||
signalEvent->enableCounterBasedMode(false);
|
||||
} else {
|
||||
signalEvent->disableImplicitCounterBasedMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -1043,7 +1043,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::performCpuMemcpy(cons
|
||||
if (hSignalEvent) {
|
||||
signalEvent = Event::fromHandle(hSignalEvent);
|
||||
}
|
||||
this->handleCounterBasedEventTransition(signalEvent);
|
||||
this->handleCounterBasedEventOperations(signalEvent);
|
||||
|
||||
const void *cpuMemcpySrcPtr = srcLockPointer ? srcLockPointer : cpuMemCopyInfo.srcPtr;
|
||||
void *cpuMemcpyDstPtr = dstLockPointer ? dstLockPointer : cpuMemCopyInfo.dstPtr;
|
||||
|
||||
@@ -88,7 +88,9 @@ struct BcsSplit {
|
||||
|
||||
auto signalEvent = Event::fromHandle(hSignalEvent);
|
||||
|
||||
cmdList->handleCounterBasedEventTransition(signalEvent);
|
||||
if (!cmdList->handleCounterBasedEventOperations(signalEvent)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
auto totalSize = size;
|
||||
auto engineCount = cmdQsForSplit.size();
|
||||
|
||||
@@ -1678,6 +1678,66 @@ HWTEST2_F(InOrderCmdListTests, givenImmediateCmdListWhenDispatchingWithRegularEv
|
||||
context->freeMem(alloc);
|
||||
}
|
||||
|
||||
HWTEST2_F(InOrderCmdListTests, givenNonInOrderCmdListWhenPassingCounterBasedEventThenReturnError, IsAtLeastXeHpCore) {
|
||||
DebugManager.flags.EnableImplicitConvertionToCounterBasedEvents.set(1);
|
||||
|
||||
auto immCmdList = createImmCmdList<gfxCoreFamily>();
|
||||
immCmdList->inOrderExecInfo.reset();
|
||||
EXPECT_FALSE(immCmdList->isInOrderExecutionEnabled());
|
||||
|
||||
auto copyOnlyCmdList = createCopyOnlyImmCmdList<gfxCoreFamily>();
|
||||
copyOnlyCmdList->inOrderExecInfo.reset();
|
||||
EXPECT_FALSE(copyOnlyCmdList->isInOrderExecutionEnabled());
|
||||
|
||||
auto eventPool = createEvents<FamilyType>(1, true);
|
||||
|
||||
auto eventHandle = events[0]->toHandle();
|
||||
|
||||
ze_copy_region_t region = {0, 0, 0, 1, 1, 1};
|
||||
uint32_t copyData[64] = {};
|
||||
|
||||
void *alloc = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
auto result = context->allocDeviceMem(device->toHandle(), &deviceDesc, 16384u, 4096u, &alloc);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
|
||||
NEO::MockGraphicsAllocation mockAllocation(0, NEO::AllocationType::INTERNAL_HOST_MEMORY,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
|
||||
MemoryPool::System4KBPages, MemoryManager::maxOsContextCount);
|
||||
|
||||
AlignedAllocationData allocationData = {mockAllocation.gpuAddress, 0, &mockAllocation, false};
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendLaunchKernel(kernel->toHandle(), groupCount, eventHandle, 0, nullptr, launchParams, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendLaunchCooperativeKernel(kernel->toHandle(), groupCount, eventHandle, 0, nullptr, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendLaunchKernelIndirect(kernel->toHandle(), *static_cast<ze_group_count_t *>(alloc), eventHandle, 0, nullptr, false));
|
||||
|
||||
size_t rangeSizes = 1;
|
||||
const void **ranges = reinterpret_cast<const void **>(©Data[0]);
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendMemoryRangesBarrier(1, &rangeSizes, ranges, eventHandle, 0, nullptr));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, copyOnlyCmdList->appendMemoryCopyBlitRegion(&allocationData, &allocationData, region, region, {0, 0, 0}, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}, events[0].get(), 0, nullptr, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendMemoryCopy(©Data, ©Data, 1, eventHandle, 0, nullptr, false, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendMemoryFill(alloc, ©Data, 1, 16, eventHandle, 0, nullptr, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, copyOnlyCmdList->appendBlitFill(alloc, ©Data, 1, 16, events[0].get(), 0, nullptr, false));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendSignalEvent(eventHandle));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendWriteGlobalTimestamp(reinterpret_cast<uint64_t *>(copyData), eventHandle, 0, nullptr));
|
||||
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendBarrier(eventHandle, 0, nullptr, false));
|
||||
|
||||
zex_wait_on_mem_desc_t desc;
|
||||
desc.actionFlag = ZEX_WAIT_ON_MEMORY_FLAG_NOT_EQUAL;
|
||||
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, immCmdList->appendWaitOnMemory(reinterpret_cast<void *>(&desc), copyData, 1, eventHandle, false));
|
||||
|
||||
context->freeMem(alloc);
|
||||
}
|
||||
|
||||
HWTEST2_F(InOrderCmdListTests, givenCmdsChainingFromAppendCopyWhenDispatchingKernelThenProgramSemaphoreOnce, IsAtLeastXeHpCore) {
|
||||
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user