From 85a42162f8cff546f49b3a6ff10054021d42ad4b Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Fri, 16 Aug 2024 12:11:18 +0000 Subject: [PATCH] refactor: debug flag to print DirectSubmission semaphore usage Signed-off-by: Bartosz Dunajski --- .../debug_settings/debug_variables_base.inl | 1 + .../direct_submission_hw.inl | 10 +++++++- shared/test/common/test_files/igdrcl.config | 1 + .../direct_submission_tests_2.cpp | 25 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index d88e337ee2..1ab265b2b3 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -436,6 +436,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionRelaxedOrderingForBcs, -1, "-1: DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionRelaxedOrderingQueueSizeLimit, -1, "-1: default, >0: Max gpu queue size. If limit is reached, scheduler wont consume new work") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionRelaxedOrderingMinNumberOfClients, -1, "-1: default, >0: Enables RelaxedOrdering mode only if specified number of clients is assigned to given CSR.") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionMonitorFenceInputPolicy, -1, "-1: default, 0: stalling command flag, 1: explicit monitor fence flag. Selects policy to dispatch monitor fence upon input flag, either for every stalling command or explicit motor fence dispatch") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionPrintSemaphoreUsage, -1, "-1: default, 0: disabled, 1: enabled. If set, print DirectSubmission semaphore programming and unlocking") DECLARE_DEBUG_VARIABLE(bool, DirectSubmissionPrintBuffers, false, "Print address of submitted command buffers") DECLARE_DEBUG_VARIABLE(int32_t, WaitForPagingFenceInController, -1, "Instead of waiting for paging fence on user thread, program additional semaphore which will be signaled by direct submission controller when paging fence reaches required value -1: default, 0 - disable, 1 - enable.") diff --git a/shared/source/direct_submission/direct_submission_hw.inl b/shared/source/direct_submission/direct_submission_hw.inl index 3ee337d7f9..8509103592 100644 --- a/shared/source/direct_submission/direct_submission_hw.inl +++ b/shared/source/direct_submission/direct_submission_hw.inl @@ -86,7 +86,7 @@ DirectSubmissionHw::DirectSubmissionHw(const DirectSubmis int32_t disableCacheFlushKey = debugManager.flags.DirectSubmissionDisableCpuCacheFlush.get(); if (disableCacheFlushKey != -1) { - disableCpuCacheFlush = disableCacheFlushKey == 1 ? true : false; + disableCpuCacheFlush = (disableCacheFlushKey == 1); } isDisablePrefetcherRequired = productHelper.isPrefetcherDisablingInDirectSubmissionRequired(); @@ -430,6 +430,10 @@ inline void DirectSubmissionHw::unblockGpu() { *this->pciBarrierPtr = 0u; } + if (debugManager.flags.DirectSubmissionPrintSemaphoreUsage.get() == 1) { + printf("DirectSubmission semaphore %" PRIx64 " unlocked with value: %u\n", semaphoreGpuVa, currentQueueWorkCount); + } + semaphoreData->queueWorkCount = currentQueueWorkCount; if (sfenceMode == DirectSubmissionSfenceMode::beforeAndAfterSemaphore) { @@ -547,6 +551,10 @@ template inline void DirectSubmissionHw::dispatchSemaphoreSection(uint32_t value) { using COMPARE_OPERATION = typename GfxFamily::MI_SEMAPHORE_WAIT::COMPARE_OPERATION; + if (debugManager.flags.DirectSubmissionPrintSemaphoreUsage.get() == 1) { + printf("DirectSubmission semaphore %" PRIx64 " programmed with value: %u\n", semaphoreGpuVa, value); + } + dispatchDisablePrefetcher(true); if (this->relaxedOrderingEnabled && this->relaxedOrderingSchedulerRequired) { diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 2ce15022cf..597ee00587 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -624,4 +624,5 @@ StandaloneInOrderTimestampAllocationEnabled = -1 ForceComputeWalkerPostSyncFlushWithWrite = -1 DeferStateInitSubmissionToFirstRegularUsage = -1 WaitForPagingFenceInController = -1 +DirectSubmissionPrintSemaphoreUsage = -1 # Please don't edit below this line diff --git a/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp b/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp index 7377213739..a559332a8f 100644 --- a/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp +++ b/shared/test/unit_test/direct_submission/direct_submission_tests_2.cpp @@ -787,6 +787,31 @@ HWTEST_F(DirectSubmissionDispatchBufferTest, givenDirectSubmissionPrintBuffersWh EXPECT_TRUE(pos != std::string::npos); } +HWTEST_F(DirectSubmissionDispatchBufferTest, givenDirectSubmissionPrintSemaphoreWhenDispatchingThenPrintAllData) { + DebugManagerStateRestore restorer; + debugManager.flags.DirectSubmissionPrintSemaphoreUsage.set(1); + + FlushStampTracker flushStamp(true); + MockDirectSubmissionHw> directSubmission(*pDevice->getDefaultEngine().commandStreamReceiver); + + testing::internal::CaptureStdout(); + + bool ret = directSubmission.initialize(false, false); + EXPECT_TRUE(ret); + ret = directSubmission.dispatchCommandBuffer(batchBuffer, flushStamp); + EXPECT_TRUE(ret); + directSubmission.unblockGpu(); + + std::string output = testing::internal::GetCapturedStdout(); + + auto pos = output.find("DirectSubmission semaphore"); + EXPECT_TRUE(pos != std::string::npos); + pos = output.find("unlocked with value:"); + EXPECT_TRUE(pos != std::string::npos); + pos = output.find("programmed with value:"); + EXPECT_TRUE(pos != std::string::npos); +} + HWCMDTEST_F(IGFX_XE_HP_CORE, DirectSubmissionDispatchBufferTest, givenDirectSubmissionRingStartWhenMultiTileSupportedThenExpectMultiTileConfigSetAndWorkPartitionResident) { using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;