performance: add time measurement between make resident and wait on gpu
Related-To: NEO-8211 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
parent
8778a0acca
commit
0d8523c386
|
@ -1052,6 +1052,8 @@ unsigned int Wddm::getEnablePreemptionRegValue() {
|
|||
}
|
||||
|
||||
bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
|
||||
perfLogStartWaitTime(residencyLogger.get(), currentPagingFenceValue);
|
||||
|
||||
D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU waitOnGpu = {};
|
||||
|
||||
waitOnGpu.hContext = context;
|
||||
|
@ -1062,6 +1064,7 @@ bool Wddm::waitOnGPU(D3DKMT_HANDLE context) {
|
|||
waitOnGpu.MonitoredFenceValueArray = &localPagingFenceValue;
|
||||
NTSTATUS status = getGdi()->waitForSynchronizationObjectFromGpu(&waitOnGpu);
|
||||
|
||||
perfLogResidencyWaitPagingeFenceLog(residencyLogger.get(), *getPagingFenceAddress(), true);
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1206,7 @@ void Wddm::waitOnPagingFenceFromCpu() {
|
|||
while (currentPagingFenceValue > *getPagingFenceAddress())
|
||||
perfLogResidencyEnteredWait(residencyLogger.get());
|
||||
|
||||
perfLogResidencyWaitPagingeFenceLog(residencyLogger.get(), *getPagingFenceAddress());
|
||||
perfLogResidencyWaitPagingeFenceLog(residencyLogger.get(), *getPagingFenceAddress(), false);
|
||||
}
|
||||
|
||||
void Wddm::updatePagingFenceValue(uint64_t newPagingFenceValue) {
|
||||
|
|
|
@ -59,7 +59,7 @@ class WddmResidencyLogger {
|
|||
enterWait = true;
|
||||
}
|
||||
|
||||
void waitPagingeFenceLog(UINT64 stopWaitPagingFence) {
|
||||
void waitPagingeFenceLog(UINT64 stopWaitPagingFence, bool gpuWait) {
|
||||
endTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
int64_t timeDiff = 0;
|
||||
|
@ -75,16 +75,23 @@ class WddmResidencyLogger {
|
|||
timeDiff);
|
||||
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(endTime - waitStartTime).count();
|
||||
IoFunctions::fprintf(pagingLog, "waiting: %x delta time wait loop: %lld\n", enterWait, timeDiff);
|
||||
IoFunctions::fprintf(pagingLog, "waiting: %x delta time wait loop: %lld wait on GPU: %d\n", enterWait, timeDiff, gpuWait);
|
||||
|
||||
if (trimBudgetTime != std::chrono::high_resolution_clock::time_point::max()) {
|
||||
timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(endTime - trimBudgetTime).count();
|
||||
IoFunctions::fprintf(pagingLog, "waiting delta time trim to budget: %lld\n", timeDiff);
|
||||
}
|
||||
|
||||
makeResidentCall = false;
|
||||
enterWait = false;
|
||||
makeResidentPagingFence = 0;
|
||||
startWaitPagingFence = 0;
|
||||
trimBudgetTime = std::chrono::high_resolution_clock::time_point::max();
|
||||
}
|
||||
|
||||
void trimRequired(UINT64 numBytesToTrim) {
|
||||
IoFunctions::fprintf(pagingLog, "trimming required: bytes to trim: %llu\n", numBytesToTrim);
|
||||
trimBudgetTime = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void variadicLog(char const *const formatStr, va_list arg) {
|
||||
|
@ -109,6 +116,7 @@ class WddmResidencyLogger {
|
|||
std::chrono::high_resolution_clock::time_point pendingTime;
|
||||
std::chrono::high_resolution_clock::time_point waitStartTime;
|
||||
std::chrono::high_resolution_clock::time_point endTime;
|
||||
std::chrono::high_resolution_clock::time_point trimBudgetTime = std::chrono::high_resolution_clock::time_point::max();
|
||||
|
||||
UINT64 makeResidentPagingFence = 0ull;
|
||||
UINT64 startWaitPagingFence = 0ull;
|
||||
|
@ -152,10 +160,10 @@ inline void perfLogResidencyEnteredWait(WddmResidencyLogger *log) {
|
|||
}
|
||||
}
|
||||
|
||||
inline void perfLogResidencyWaitPagingeFenceLog(WddmResidencyLogger *log, UINT64 stopWaitPagingFence) {
|
||||
inline void perfLogResidencyWaitPagingeFenceLog(WddmResidencyLogger *log, UINT64 stopWaitPagingFence, bool gpuWait) {
|
||||
if constexpr (wddmResidencyLoggingAvailable) {
|
||||
if (log) {
|
||||
log->waitPagingeFenceLog(stopWaitPagingFence);
|
||||
log->waitPagingeFenceLog(stopWaitPagingFence, gpuWait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -520,10 +520,11 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmResidencyEnabledWhenSubmitToGpuThenS
|
|||
|
||||
uint64_t gpuAddress = 0xF000;
|
||||
size_t size = 0xFF000;
|
||||
|
||||
bool ret = wddmDirectSubmission.submit(gpuAddress, size);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(2u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(5u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
}
|
||||
|
|
|
@ -1272,7 +1272,7 @@ TEST_F(WddmCommandStreamTest, givenResidencyLoggingAvailableWhenFlushingCommandB
|
|||
csr->flush(batchBuffer, csr->getResidencyAllocations());
|
||||
|
||||
EXPECT_EQ(1u, NEO::IoFunctions::mockFopenCalled);
|
||||
EXPECT_EQ(3u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(6u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_EQ(0u, NEO::IoFunctions::mockFcloseCalled);
|
||||
|
||||
memoryManager->freeGraphicsMemory(commandBuffer);
|
||||
|
|
|
@ -1523,6 +1523,73 @@ TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingThenEx
|
|||
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->startWaitPagingFenceSave);
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentAndWaitPagingOnGpuThenExpectFlagsOff) {
|
||||
if (!NEO::wddmResidencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::IoFunctions::mockFopenCalled = 0;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
wddm->callBaseMakeResident = true;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
|
||||
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::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_TRUE(logger->makeResidentCall);
|
||||
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->makeResidentPagingFence);
|
||||
|
||||
logger->enterWait = true;
|
||||
wddm->waitOnGPU(osContext->getWddmContextHandle());
|
||||
EXPECT_EQ(5u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
EXPECT_FALSE(logger->enterWait);
|
||||
EXPECT_EQ(MockGdi::pagingFenceReturnValue, logger->startWaitPagingFenceSave);
|
||||
}
|
||||
|
||||
TEST_F(WddmTest, GivenResidencyLoggingEnabledWhenMakeResidentRequiresTrimToBudgetAndWaitPagingOnGpuThenExpectProperLoggingCount) {
|
||||
if (!NEO::wddmResidencyLoggingAvailable) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
NEO::IoFunctions::mockFopenCalled = 0;
|
||||
NEO::IoFunctions::mockVfptrinfCalled = 0;
|
||||
NEO::IoFunctions::mockFcloseCalled = 0;
|
||||
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.WddmResidencyLogger.set(true);
|
||||
wddm->callBaseCreatePagingLogger = false;
|
||||
wddm->callBaseMakeResident = true;
|
||||
|
||||
wddm->createPagingFenceLogger();
|
||||
EXPECT_NE(nullptr, wddm->residencyLogger.get());
|
||||
auto logger = static_cast<MockWddmResidencyLogger *>(wddm->residencyLogger.get());
|
||||
|
||||
D3DKMT_HANDLE handle = INVALID_HANDLE;
|
||||
uint64_t bytesToTrim = 0;
|
||||
wddm->makeResident(&handle, 1, false, &bytesToTrim, 0x1000);
|
||||
|
||||
// 3 - one for open log, second for allocation size, third reporting on trim to budget
|
||||
EXPECT_EQ(3u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
|
||||
logger->enterWait = true;
|
||||
wddm->waitOnGPU(osContext->getWddmContextHandle());
|
||||
// additional 4 wait logs - 3 default and 1 extra for trim to budget delta time
|
||||
EXPECT_EQ(7u, NEO::IoFunctions::mockVfptrinfCalled);
|
||||
EXPECT_FALSE(logger->makeResidentCall);
|
||||
EXPECT_FALSE(logger->enterWait);
|
||||
}
|
||||
|
||||
TEST(VerifyAdapterType, whenAdapterDoesntSupportRenderThenDontCreateHwDeviceId) {
|
||||
auto gdi = std::make_unique<MockGdi>();
|
||||
auto osEnv = std::make_unique<OsEnvironmentWin>();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/mocks/mock_wddm.h"
|
||||
#include "shared/test/common/mocks/mock_wddm_interface23.h"
|
||||
|
@ -183,6 +184,7 @@ TEST_F(Wddm23Tests, givenCurrentPendingFenceValueGreaterThanPendingFenceValueWhe
|
|||
submitArgs.hwQueueHandle = osContext->getHwQueue().handle;
|
||||
submitArgs.monitorFence = &osContext->getResidencyController().getMonitoredFence();
|
||||
|
||||
VariableBackup<uint64_t> pagingFenceBackup(wddm->pagingFenceAddress);
|
||||
*wddm->pagingFenceAddress = 1;
|
||||
wddm->currentPagingFenceValue = 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue