Skip to content

Commit 8df7128

Browse files
Make work partition allocation resident in LevelZero
Related-To: NEO-5546 Signed-off-by: Maciej Dziuban <[email protected]>
1 parent b07f0e8 commit 8df7128

File tree

2 files changed

+61
-10
lines changed

2 files changed

+61
-10
lines changed

level_zero/core/source/cmdqueue/cmdqueue_hw.inl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
223223
if (globalFenceAllocation) {
224224
residencyContainer.push_back(globalFenceAllocation);
225225
}
226+
const auto workPartitionAllocation = csr->getWorkPartitionAllocation();
227+
if (workPartitionAllocation) {
228+
residencyContainer.push_back(workPartitionAllocation);
229+
}
226230

227231
if (NEO::DebugManager.flags.EnableSWTags.get()) {
228232
NEO::SWTagsManager *tagsManager = neoDevice->getRootDeviceEnvironment().tagsManager.get();

level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,36 @@ TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingCopyBlitCommand
473473
using CommandQueueDestroySupport = IsAtLeastProduct<IGFX_SKYLAKE>;
474474
using CommandQueueDestroy = Test<DeviceFixture>;
475475

476-
using CommandQueueCommands = Test<DeviceFixture>;
477-
HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHardwareContextIsProgrammedAndGlobalAllocationResident) {
476+
template <bool multiTile>
477+
struct CommandQueueCommands : DeviceFixture, ::testing::Test {
478+
void SetUp() override {
479+
DebugManager.flags.ForcePreemptionMode.set(static_cast<int>(NEO::PreemptionMode::Disabled));
480+
DebugManager.flags.CreateMultipleSubDevices.set(multiTile ? 2 : 1);
481+
DeviceFixture::SetUp();
482+
}
483+
484+
void TearDown() override {
485+
DeviceFixture::TearDown();
486+
}
487+
488+
template <typename FamilyType>
489+
bool isAllocationInResidencyContainer(MockCsrHw2<FamilyType> &csr, NEO::GraphicsAllocation *graphicsAllocation) {
490+
for (auto alloc : csr.copyOfAllocations) {
491+
if (alloc == graphicsAllocation) {
492+
return true;
493+
}
494+
}
495+
return false;
496+
}
497+
478498
const ze_command_queue_desc_t desc = {};
499+
DebugManagerStateRestore restore{};
500+
VariableBackup<bool> mockDeviceFlagBackup{&NEO::MockDevice::createSingleDevice, false};
501+
};
502+
using CommandQueueCommandsSingleTile = CommandQueueCommands<false>;
503+
using CommandQueueCommandsMultiTile = CommandQueueCommands<true>;
479504

505+
HWTEST_F(CommandQueueCommandsSingleTile, givenCommandQueueWhenExecutingCommandListsThenHardwareContextIsProgrammedAndGlobalAllocationResident) {
480506
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
481507
csr.initializeTagAllocation();
482508
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
@@ -497,20 +523,41 @@ HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHar
497523

498524
auto globalFence = csr.getGlobalFenceAllocation();
499525
if (globalFence) {
500-
bool found = false;
501-
for (auto alloc : csr.copyOfAllocations) {
502-
if (alloc == globalFence) {
503-
found = true;
504-
break;
505-
}
506-
}
507-
EXPECT_TRUE(found);
526+
EXPECT_TRUE(isAllocationInResidencyContainer(csr, globalFence));
508527
}
509528
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
510529
EXPECT_TRUE(csr.programHardwareContextCalled);
511530
commandQueue->destroy();
512531
}
513532

533+
HWTEST_F(CommandQueueCommandsMultiTile, givenCommandQueueOnMultiTileWhenExecutingCommandListsThenWorkPartitionAllocationIsMadeResident) {
534+
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
535+
csr.initializeTagAllocation();
536+
csr.createWorkPartitionAllocation(*neoDevice);
537+
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
538+
539+
ze_result_t returnValue;
540+
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
541+
device,
542+
&csr,
543+
&desc,
544+
false,
545+
false,
546+
returnValue);
547+
ASSERT_NE(nullptr, commandQueue);
548+
549+
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, returnValue));
550+
auto commandListHandle = commandList->toHandle();
551+
auto status = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
552+
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
553+
554+
auto workPartitionAllocation = csr.getWorkPartitionAllocation();
555+
ASSERT_NE(nullptr, workPartitionAllocation);
556+
EXPECT_TRUE(isAllocationInResidencyContainer(csr, workPartitionAllocation));
557+
558+
commandQueue->destroy();
559+
}
560+
514561
using CommandQueueIndirectAllocations = Test<ModuleFixture>;
515562
HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandListsThenExpectedIndirectAllocationsAddedToResidencyContainer) {
516563
const ze_command_queue_desc_t desc = {};

0 commit comments

Comments
 (0)