Improve Wddm Residency logging

Related-To: NEO-4338

Change-Id: I5fefa1da6188befe27928b6bbfcc7bac89a6aef2
Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2020-03-23 16:37:41 +01:00
committed by sys_ocldev
parent d96e462754
commit 4bc680477c
11 changed files with 79 additions and 29 deletions

View File

@ -5,7 +5,7 @@
*
*/
#include "mock_gdi.h"
#include "opencl/test/unit_test/mock_gdi/mock_gdi.h"
#include "shared/source/memory_manager/memory_constants.h"

View File

@ -278,7 +278,9 @@ D3DGPU_VIRTUAL_ADDRESS WddmMock::reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS
}
uint64_t *WddmMock::getPagingFenceAddress() {
getPagingFenceAddressResult.called++;
if (NEO::residencyLoggingAvailable) {
getPagingFenceAddressResult.called++;
}
mockPagingFence++;
return &mockPagingFence;
}

View File

@ -13,10 +13,19 @@ struct MockWddmResidencyLogger : public WddmResidencyLogger {
using WddmResidencyLogger::endTime;
using WddmResidencyLogger::enterWait;
using WddmResidencyLogger::makeResidentCall;
using WddmResidencyLogger::makeResidentPagingFence;
using WddmResidencyLogger::pagingLog;
using WddmResidencyLogger::pendingMakeResident;
using WddmResidencyLogger::pendingTime;
using WddmResidencyLogger::startWaitPagingFence;
using WddmResidencyLogger::waitStartTime;
using WddmResidencyLogger::WddmResidencyLogger;
void startWaitTime(UINT64 startWaitPagingFence) override {
WddmResidencyLogger::startWaitTime(startWaitPagingFence);
startWaitPagingFenceSave = this->startWaitPagingFence;
}
UINT64 startWaitPagingFenceSave = 0ull;
};
} // namespace NEO

View File

@ -8,13 +8,19 @@
#pragma once
#include "shared/source/os_interface/windows/wddm_allocation.h"
#include "opencl/test/unit_test/mock_gdi/mock_gdi.h"
namespace NEO {
class MockWddmAllocation : public WddmAllocation {
public:
MockWddmAllocation() : WddmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, nullptr, MemoryPool::MemoryNull), gpuPtr(gpuAddress), handle(handles[0]) {
for (uint32_t i = 0; i < EngineLimits::maxHandleCount; i++) {
handles[i] = ALLOCATION_HANDLE;
}
}
using WddmAllocation::cpuPtr;
using WddmAllocation::handles;
using WddmAllocation::memoryPool;
using WddmAllocation::size;

View File

@ -880,11 +880,11 @@ TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeReside
}
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentThenWaitForCurrentPagingFenceValue) {
wddm->mockPagingFence = 0u;
wddm->currentPagingFenceValue = 3u;
wddm->temporaryResources->makeResidentResource(ALLOCATION_HANDLE, 0x1000);
UINT64 expectedCallNumber = NEO::residencyLoggingAvailable ? MockGdi::pagingFenceReturnValue + 1 : 0ull;
EXPECT_EQ(1u, wddm->makeResidentResult.called);
EXPECT_EQ(3u, wddm->mockPagingFence);
EXPECT_EQ(3u, wddm->getPagingFenceAddressResult.called);
EXPECT_EQ(MockGdi::pagingFenceReturnValue + 1, wddm->mockPagingFence);
EXPECT_EQ(expectedCallNumber, wddm->getPagingFenceAddressResult.called);
}
TEST_F(WddmLockWithMakeResidentTests, givenAllocationWhenApplyBlockingMakeResidentAndMakeResidentCallFailsThenEvictTemporaryResourcesAndRetry) {
MockWddmAllocation allocation;
@ -1272,13 +1272,14 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentSuccessThenExpectSi
EXPECT_NE(nullptr, wddm->residencyLogger.get());
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
D3DKMT_HANDLE handle = 0x10;
D3DKMT_HANDLE handle = ALLOCATION_HANDLE;
uint64_t bytesToTrim = 0;
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
//2 - one for open log, second for allocation size
EXPECT_EQ(2u, NEO::ResLog::mockVfptrinfCalled);
EXPECT_TRUE(logger->makeResidentCall);
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->makeResidentPagingFence);
}
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentFailThenExpectTrimReport) {
@ -1297,7 +1298,7 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentFailThenExpectTrimR
EXPECT_NE(nullptr, wddm->residencyLogger.get());
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
D3DKMT_HANDLE handle = static_cast<D3DKMT_HANDLE>(-1);
D3DKMT_HANDLE handle = INVALID_HANDLE;
uint64_t bytesToTrim = 0;
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
@ -1342,19 +1343,21 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenEx
EXPECT_NE(nullptr, wddm->residencyLogger.get());
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
D3DKMT_HANDLE handle = 0x10;
D3DKMT_HANDLE handle = ALLOCATION_HANDLE;
uint64_t bytesToTrim = 0;
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
//2 - one for open log, second for allocation size
EXPECT_EQ(2u, NEO::ResLog::mockVfptrinfCalled);
EXPECT_TRUE(logger->makeResidentCall);
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->makeResidentPagingFence);
logger->enterWait = true;
wddm->waitOnPagingFenceFromCpu();
EXPECT_EQ(4u, NEO::ResLog::mockVfptrinfCalled);
EXPECT_EQ(5u, NEO::ResLog::mockVfptrinfCalled);
EXPECT_FALSE(logger->makeResidentCall);
EXPECT_FALSE(logger->enterWait);
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->startWaitPagingFenceSave);
}
TEST(DiscoverDevices, whenDriverInfoHasIncompatibleDriverStoreThenHwDeviceIdIsNotCreated) {