Make work partition allocation resident in LevelZero

Related-To: NEO-5546
Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban 2021-03-17 12:10:42 +00:00 committed by Compute-Runtime-Automation
parent b07f0e81b7
commit 8df7128901
2 changed files with 62 additions and 11 deletions

View File

@ -223,6 +223,10 @@ ze_result_t CommandQueueHw<gfxCoreFamily>::executeCommandLists(
if (globalFenceAllocation) {
residencyContainer.push_back(globalFenceAllocation);
}
const auto workPartitionAllocation = csr->getWorkPartitionAllocation();
if (workPartitionAllocation) {
residencyContainer.push_back(workPartitionAllocation);
}
if (NEO::DebugManager.flags.EnableSWTags.get()) {
NEO::SWTagsManager *tagsManager = neoDevice->getRootDeviceEnvironment().tagsManager.get();

View File

@ -473,10 +473,36 @@ TEST_F(CommandQueueCreate, givenCmdQueueWithBlitCopyWhenExecutingCopyBlitCommand
using CommandQueueDestroySupport = IsAtLeastProduct<IGFX_SKYLAKE>;
using CommandQueueDestroy = Test<DeviceFixture>;
using CommandQueueCommands = Test<DeviceFixture>;
HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHardwareContextIsProgrammedAndGlobalAllocationResident) {
const ze_command_queue_desc_t desc = {};
template <bool multiTile>
struct CommandQueueCommands : DeviceFixture, ::testing::Test {
void SetUp() override {
DebugManager.flags.ForcePreemptionMode.set(static_cast<int>(NEO::PreemptionMode::Disabled));
DebugManager.flags.CreateMultipleSubDevices.set(multiTile ? 2 : 1);
DeviceFixture::SetUp();
}
void TearDown() override {
DeviceFixture::TearDown();
}
template <typename FamilyType>
bool isAllocationInResidencyContainer(MockCsrHw2<FamilyType> &csr, NEO::GraphicsAllocation *graphicsAllocation) {
for (auto alloc : csr.copyOfAllocations) {
if (alloc == graphicsAllocation) {
return true;
}
}
return false;
}
const ze_command_queue_desc_t desc = {};
DebugManagerStateRestore restore{};
VariableBackup<bool> mockDeviceFlagBackup{&NEO::MockDevice::createSingleDevice, false};
};
using CommandQueueCommandsSingleTile = CommandQueueCommands<false>;
using CommandQueueCommandsMultiTile = CommandQueueCommands<true>;
HWTEST_F(CommandQueueCommandsSingleTile, givenCommandQueueWhenExecutingCommandListsThenHardwareContextIsProgrammedAndGlobalAllocationResident) {
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
csr.initializeTagAllocation();
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
@ -497,20 +523,41 @@ HWTEST_F(CommandQueueCommands, givenCommandQueueWhenExecutingCommandListsThenHar
auto globalFence = csr.getGlobalFenceAllocation();
if (globalFence) {
bool found = false;
for (auto alloc : csr.copyOfAllocations) {
if (alloc == globalFence) {
found = true;
break;
}
}
EXPECT_TRUE(found);
EXPECT_TRUE(isAllocationInResidencyContainer(csr, globalFence));
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
EXPECT_TRUE(csr.programHardwareContextCalled);
commandQueue->destroy();
}
HWTEST_F(CommandQueueCommandsMultiTile, givenCommandQueueOnMultiTileWhenExecutingCommandListsThenWorkPartitionAllocationIsMadeResident) {
MockCsrHw2<FamilyType> csr(*neoDevice->getExecutionEnvironment(), 0, neoDevice->getDeviceBitfield());
csr.initializeTagAllocation();
csr.createWorkPartitionAllocation(*neoDevice);
csr.setupContext(*neoDevice->getDefaultEngine().osContext);
ze_result_t returnValue;
L0::CommandQueue *commandQueue = CommandQueue::create(productFamily,
device,
&csr,
&desc,
false,
false,
returnValue);
ASSERT_NE(nullptr, commandQueue);
std::unique_ptr<L0::CommandList> commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::Compute, returnValue));
auto commandListHandle = commandList->toHandle();
auto status = commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false);
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
auto workPartitionAllocation = csr.getWorkPartitionAllocation();
ASSERT_NE(nullptr, workPartitionAllocation);
EXPECT_TRUE(isAllocationInResidencyContainer(csr, workPartitionAllocation));
commandQueue->destroy();
}
using CommandQueueIndirectAllocations = Test<ModuleFixture>;
HWTEST_F(CommandQueueIndirectAllocations, givenCommandQueueWhenExecutingCommandListsThenExpectedIndirectAllocationsAddedToResidencyContainer) {
const ze_command_queue_desc_t desc = {};