From 1b0983d7db2c68be374198e6cf1a5954ab313a93 Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Fri, 25 Sep 2020 09:49:10 +0200 Subject: [PATCH] Debug logs: print tag allocation address. Change-Id: Ia5d8cf16fa42f7b1f567e4ac79fae61bbcb6f13a Signed-off-by: Bartosz Dunajski --- .../command_stream_receiver_tests.cpp | 25 +++++++++++++++++++ .../test/unit_test/test_files/igdrcl.config | 3 ++- .../command_stream_receiver.cpp | 4 +++ .../debug_settings/debug_variables_base.inl | 1 + 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp index 7ed92125bd..9feb49e29d 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -768,6 +768,31 @@ TEST(CommandStreamReceiverSimpleTest, givenNewResourceFlushEnabledWhenProvidingN EXPECT_STREQ("New resource detected of type 0\n", output.c_str()); } +TEST(CommandStreamReceiverSimpleTest, givenPrintfTagAllocationAddressFlagEnabledWhenCreatingTagAllocationThenPrintItsAddress) { + DebugManagerStateRestore restore; + DebugManager.flags.PrintTagAllocationAddress.set(true); + + auto osContext = std::unique_ptr(OsContext::create(nullptr, 0, 0, aub_stream::EngineType::ENGINE_BCS, PreemptionMode::Disabled, false, false, false)); + + MockExecutionEnvironment executionEnvironment; + executionEnvironment.prepareRootDeviceEnvironments(1); + executionEnvironment.initializeMemoryManager(); + MockCommandStreamReceiver csr(executionEnvironment, 0); + csr.setupContext(*osContext); + + testing::internal::CaptureStdout(); + + csr.initializeTagAllocation(); + + std::string output = testing::internal::GetCapturedStdout(); + EXPECT_NE(0u, output.size()); + + char expectedStr[128]; + snprintf(expectedStr, 128, "\nCreated tag allocation %p for engine %u\n", csr.getTagAddress(), csr.getOsContext().getEngineType()); + + EXPECT_THAT(output, testing::HasSubstr(std::string(expectedStr))); +} + TEST(CommandStreamReceiverSimpleTest, givenGpuIdleImplicitFlushCheckDisabledWhenGpuIsIdleThenReturnFalse) { MockExecutionEnvironment executionEnvironment; executionEnvironment.prepareRootDeviceEnvironments(1); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index 241802ba86..735e1b2586 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -195,4 +195,5 @@ PerformImplicitFlushEveryEnqueueCount = -1 PerformImplicitFlushForNewResource = -1 PerformImplicitFlushForIdleGpu = -1 ProvideVerboseImplicitFlush = false -PauseOnGpuMode = -1 \ No newline at end of file +PauseOnGpuMode = -1 +PrintTagAllocationAddress = 0 \ No newline at end of file diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 4ade5569c1..10007086ca 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -432,6 +432,10 @@ bool CommandStreamReceiver::initializeTagAllocation() { *this->tagAddress = DebugManager.flags.EnableNullHardware.get() ? -1 : initialHardwareTag; *this->debugPauseStateAddress = DebugManager.flags.EnableNullHardware.get() ? DebugPauseState::disabled : DebugPauseState::waitingForFirstSemaphore; + PRINT_DEBUG_STRING(DebugManager.flags.PrintTagAllocationAddress.get(), stdout, + "\nCreated tag allocation %p for engine %u\n", + this->tagAddress, static_cast(osContext->getEngineType())); + if (DebugManager.flags.PauseOnEnqueue.get() != -1 || DebugManager.flags.PauseOnBlitCopy.get() != -1) { userPauseConfirmation = Thread::create(CommandStreamReceiver::asyncDebugBreakConfirmation, reinterpret_cast(this)); } diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 9ece2f48d0..1dccd30d33 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -106,6 +106,7 @@ DECLARE_DEBUG_VARIABLE(bool, PrintTimestampPacketContents, false, "prints all ti DECLARE_DEBUG_VARIABLE(bool, WddmResidencyLogger, false, "gather Wddm residency statistics to file") DECLARE_DEBUG_VARIABLE(bool, PrintBOCreateDestroyResult, false, "tracks the result of creation and destruction of BOs") DECLARE_DEBUG_VARIABLE(bool, PrintBOBindingResult, false, "tracks the result of binding and unbinding of BOs") +DECLARE_DEBUG_VARIABLE(bool, PrintTagAllocationAddress, false, "Print tag allocation address for each engine") DECLARE_DEBUG_VARIABLE(bool, ProvideVerboseImplicitFlush, false, "provides verbose messages about implicit flush mechanism") /*PERFORMANCE FLAGS*/