mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
KM DAF AubCapture to recapture command streams and heap allocations
This commit introduces a recapture of CS and Heap resources on every submit. Change-Id: I2a5a763e8988de804da1a6c2c8042154b0786b2e
This commit is contained in:
committed by
sys_ocldev
parent
e3b1ba2112
commit
32825e203e
@@ -306,6 +306,109 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledAndThrottleIsToHighThen
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAllocationsForResidencyThenNoneAllocationShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, linearStreamAllocation);
|
||||
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
|
||||
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
|
||||
|
||||
EXPECT_FALSE(wddm->isKmDafEnabled());
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
memManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutAllocationsForResidencyThenNoneAllocationShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
wddm->setKmDafEnabled(true);
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
|
||||
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResidencyAllocationsInMemoryManagerThenLinearStreamAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, linearStreamAllocation);
|
||||
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
|
||||
|
||||
csr->makeResident(*linearStreamAllocation);
|
||||
EXPECT_EQ(1u, memManager->getResidencyAllocations().size());
|
||||
EXPECT_EQ(linearStreamAllocation, memManager->getResidencyAllocations()[0]);
|
||||
|
||||
wddm->setKmDafEnabled(true);
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, nullptr);
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(linearStreamAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
memManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenLinearStreamAllocationsShouldBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
auto linearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, linearStreamAllocation);
|
||||
linearStreamAllocation->setAllocationType(GraphicsAllocation::ALLOCATION_TYPE_LINEAR_STREAM);
|
||||
ResidencyContainer allocationsForResidency = {linearStreamAllocation};
|
||||
|
||||
wddm->setKmDafEnabled(true);
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
EXPECT_EQ(linearStreamAllocation, wddm->kmDafLockResult.lockedAllocations[0]);
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
memManager->freeGraphicsMemory(linearStreamAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllocationsForResidencyThenNonLinearStreamAllocationShouldNotBeKmDafLocked) {
|
||||
GraphicsAllocation *commandBuffer = memManager->allocateGraphicsMemory(4096, 4096);
|
||||
ASSERT_NE(nullptr, commandBuffer);
|
||||
LinearStream cs(commandBuffer);
|
||||
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
|
||||
|
||||
auto nonLinearStreamAllocation = memManager->allocateGraphicsMemory(sizeof(uint32_t), sizeof(uint32_t), false, false);
|
||||
ASSERT_NE(nullptr, nonLinearStreamAllocation);
|
||||
ResidencyContainer allocationsForResidency = {nonLinearStreamAllocation};
|
||||
|
||||
wddm->setKmDafEnabled(true);
|
||||
auto flushStamp = csr->flush(batchBuffer, EngineType::ENGINE_RCS, &allocationsForResidency);
|
||||
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.called);
|
||||
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
|
||||
|
||||
memManager->freeGraphicsMemory(commandBuffer);
|
||||
memManager->freeGraphicsMemory(nonLinearStreamAllocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmCommandStreamTest, makeResident) {
|
||||
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memManager);
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ class WddmMock : public Wddm {
|
||||
std::vector<D3DKMT_HANDLE> handlePack;
|
||||
uint32_t handleCount = 0;
|
||||
};
|
||||
struct KmDafLockCall : public CallResult {
|
||||
std::vector<GraphicsAllocation *> lockedAllocations;
|
||||
};
|
||||
|
||||
public:
|
||||
using Wddm::adapter;
|
||||
@@ -238,6 +241,18 @@ class WddmMock : public Wddm {
|
||||
unlockResult.success = true;
|
||||
Wddm::unlockResource(allocation);
|
||||
}
|
||||
void kmDafLock(WddmAllocation *allocation) override {
|
||||
kmDafLockResult.called++;
|
||||
kmDafLockResult.success = true;
|
||||
kmDafLockResult.lockedAllocations.push_back(allocation);
|
||||
Wddm::kmDafLock(allocation);
|
||||
}
|
||||
bool isKmDafEnabled() override {
|
||||
return kmDafEnabled;
|
||||
}
|
||||
void setKmDafEnabled(bool state) {
|
||||
kmDafEnabled = state;
|
||||
}
|
||||
void setHwContextId(unsigned long hwContextId) {
|
||||
this->hwContextId = hwContextId;
|
||||
}
|
||||
@@ -315,6 +330,7 @@ class WddmMock : public Wddm {
|
||||
CallResult createContextResult;
|
||||
CallResult lockResult;
|
||||
CallResult unlockResult;
|
||||
KmDafLockCall kmDafLockResult;
|
||||
CallResult waitFromCpuResult;
|
||||
CallResult releaseReservedAddressResult;
|
||||
CallResult reserveValidAddressRangeResult;
|
||||
@@ -325,6 +341,7 @@ class WddmMock : public Wddm {
|
||||
bool callBaseMapGpuVa = true;
|
||||
std::set<void *> reservedAddresses;
|
||||
uintptr_t virtualAllocAddress;
|
||||
bool kmDafEnabled = false;
|
||||
};
|
||||
|
||||
class WddmMockReserveAddress : public WddmMock {
|
||||
|
||||
@@ -196,3 +196,17 @@ HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalle
|
||||
EXPECT_EQ(Gmm::decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenKmDafLockIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation;
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
wddmWithKmDafMock->kmDafLock(&allocation);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
||||
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user