Add PrintOsContextInitializations debug flag

Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
This commit is contained in:
Maciej Dziuban
2021-05-17 15:22:49 +00:00
committed by Compute-Runtime-Automation
parent fa944d296c
commit 4ffe456d85
10 changed files with 140 additions and 17 deletions

View File

@@ -53,11 +53,15 @@ struct DeferredOsContextCreationTests : ::testing::Test {
DeviceFactory::prepareDeviceEnvironments(*device->getExecutionEnvironment());
}
void expectContextCreation(EngineTypeUsage engineTypeUsage, bool defaultEngine, bool expectedImmediate) {
std::unique_ptr<OsContext> createOsContext(EngineTypeUsage engineTypeUsage, bool defaultEngine) {
OSInterface *osInterface = device->getRootDeviceEnvironment().osInterface.get();
std::unique_ptr<OsContext> osContext{OsContext::create(osInterface, 0, 0, engineTypeUsage, PreemptionMode::Disabled, false)};
EXPECT_FALSE(osContext->isInitialized());
return osContext;
}
void expectContextCreation(EngineTypeUsage engineTypeUsage, bool defaultEngine, bool expectedImmediate) {
auto osContext = createOsContext(engineTypeUsage, defaultEngine);
const bool immediate = osContext->isImmediateContextInitializationEnabled(defaultEngine);
EXPECT_EQ(expectedImmediate, immediate);
if (immediate) {
@@ -141,3 +145,18 @@ TEST_F(DeferredOsContextCreationTests, givenEnsureContextInitializeCalledMultipl
EXPECT_TRUE(osContext.isInitialized());
EXPECT_EQ(1u, osContext.initializeContextCalled);
}
TEST_F(DeferredOsContextCreationTests, givenPrintOsContextInitializationsIsSetWhenOsContextItIsInitializedThenInfoIsLoggedToStdout) {
DebugManagerStateRestore restore{};
DebugManager.flags.DeferOsContextInitialization.set(1);
DebugManager.flags.PrintOsContextInitializations.set(1);
testing::internal::CaptureStdout();
auto osContext = createOsContext(engineTypeUsageRegular, false);
EXPECT_EQ(std::string{}, testing::internal::GetCapturedStdout());
testing::internal::CaptureStdout();
osContext->ensureContextInitialized();
std::string expectedMessage = "OsContext initialization: contextId=0 usage=Regular type=RCS isRootDevice=0\n";
EXPECT_EQ(expectedMessage, testing::internal::GetCapturedStdout());
}

View File

@@ -233,6 +233,7 @@ UseBindlessDebugSip = 0
OverrideSlmAllocationSize = -1
OverrideSlmSize = -1
UseCyclesPerSecondTimer = 0
PrintOsContextInitializations = 0
WaitLoopCount = -1
DebuggerLogBitmask = 0
GTPinAllocateBufferInSharedMemory = -1

View File

@@ -101,6 +101,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideTimestampPacketSize, -1, "-1: default, >
/*LOGGING FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")
DECLARE_DEBUG_VARIABLE(bool, PrintOsContextInitializations, false, "print initialized OsContexts to standard output")
DECLARE_DEBUG_VARIABLE(bool, PrintDeviceAndEngineIdOnSubmission, false, "print submissions device and engine IDs to standard output")
DECLARE_DEBUG_VARIABLE(bool, PrintExecutionBuffer, false, "print execution buffer information to standard output")
DECLARE_DEBUG_VARIABLE(bool, PrintBOsForSubmit, false, "print all BOs passed to submission")

View File

@@ -36,7 +36,8 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dirty_state_helpers.h
${CMAKE_CURRENT_SOURCE_DIR}/engine_control.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/engine_node_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/engine_node_helper_extra.cpp
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/extendable_enum.h
${CMAKE_CURRENT_SOURCE_DIR}/file_io.cpp

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,18 +7,35 @@
#include "shared/source/helpers/engine_node_helper.h"
namespace NEO {
namespace EngineHelpers {
bool isCcs(aub_stream::EngineType engineType) {
return engineType == aub_stream::ENGINE_CCS;
namespace NEO::EngineHelpers {
std::string engineUsageToString(EngineUsage usage) {
switch (usage) {
case EngineUsage::Regular:
return "Regular";
case EngineUsage::LowPriority:
return "LowPriority";
case EngineUsage::Internal:
return "Internal";
default:
return "Unknown";
}
}
bool isBcs(aub_stream::EngineType engineType) {
return engineType == aub_stream::ENGINE_BCS;
std::string engineTypeToString(aub_stream::EngineType engineType) {
switch (engineType) {
case aub_stream::EngineType::ENGINE_RCS:
return "RCS";
case aub_stream::EngineType::ENGINE_BCS:
return "BCS";
case aub_stream::EngineType::ENGINE_VCS:
return "VCS";
case aub_stream::EngineType::ENGINE_VECS:
return "VECS";
case aub_stream::EngineType::ENGINE_CCS:
return "CCS";
default:
return engineTypeToStringAdditional(engineType);
}
}
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, std::atomic<uint32_t> &selectorCopyEngine) {
return aub_stream::EngineType::ENGINE_BCS;
}
} // namespace EngineHelpers
} // namespace NEO
} // namespace NEO::EngineHelpers

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -10,6 +10,7 @@
#include "engine_node.h"
#include <atomic>
#include <string>
#include <utility>
namespace NEO {
@@ -18,7 +19,9 @@ struct HardwareInfo;
enum class EngineUsage : uint32_t {
Regular,
LowPriority,
Internal
Internal,
EngineUsageCount,
};
using EngineTypeUsage = std::pair<aub_stream::EngineType, EngineUsage>;
@@ -27,5 +30,10 @@ namespace EngineHelpers {
bool isCcs(aub_stream::EngineType engineType);
bool isBcs(aub_stream::EngineType engineType);
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, std::atomic<uint32_t> &selectorCopyEngine);
std::string engineTypeToString(aub_stream::EngineType engineType);
std::string engineTypeToStringAdditional(aub_stream::EngineType engineType);
std::string engineUsageToString(EngineUsage usage);
}; // namespace EngineHelpers
} // namespace NEO

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/engine_node_helper.h"
namespace NEO {
namespace EngineHelpers {
bool isCcs(aub_stream::EngineType engineType) {
return engineType == aub_stream::ENGINE_CCS;
}
bool isBcs(aub_stream::EngineType engineType) {
return engineType == aub_stream::ENGINE_BCS;
}
aub_stream::EngineType getBcsEngineType(const HardwareInfo &hwInfo, std::atomic<uint32_t> &selectorCopyEngine) {
return aub_stream::EngineType::ENGINE_BCS;
}
std::string engineTypeToStringAdditional(aub_stream::EngineType engineType) {
return "Unknown";
}
} // namespace EngineHelpers
} // namespace NEO

View File

@@ -40,6 +40,14 @@ bool OsContext::isImmediateContextInitializationEnabled(bool isDefaultEngine) co
void OsContext::ensureContextInitialized() {
std::call_once(contextInitializedFlag, [this] {
if (DebugManager.flags.PrintOsContextInitializations.get()) {
printf("OsContext initialization: contextId=%d usage=%s type=%s isRootDevice=%d\n",
contextId,
EngineHelpers::engineUsageToString(engineUsage).c_str(),
EngineHelpers::engineTypeToString(engineType).c_str(),
static_cast<int>(rootDevice));
}
initializeContext();
contextInitialized = true;
});

View File

@@ -15,6 +15,7 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.inl
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_flags_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/hw_helper_extended_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/engine_node_helper.h"
#include "test.h"
using namespace NEO;
TEST(EngineNodeHelperTests, givenValidEngineUsageWhenGettingStringRepresentationThenItIsCorrect) {
EXPECT_EQ(std::string{"Regular"}, EngineHelpers::engineUsageToString(EngineUsage::Regular));
EXPECT_EQ(std::string{"Internal"}, EngineHelpers::engineUsageToString(EngineUsage::Internal));
EXPECT_EQ(std::string{"LowPriority"}, EngineHelpers::engineUsageToString(EngineUsage::LowPriority));
}
TEST(EngineNodeHelperTests, givenInValidEngineUsageWhenGettingStringRepresentationThenReturnUnknown) {
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(EngineUsage::EngineUsageCount));
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineUsageToString(static_cast<EngineUsage>(0xcc)));
}
TEST(EngineNodeHelperTests, givenValidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) {
#define CHECK_ENGINE(type) EXPECT_EQ(std::string{#type}, EngineHelpers::engineTypeToString(aub_stream::EngineType::ENGINE_##type))
CHECK_ENGINE(RCS);
CHECK_ENGINE(BCS);
CHECK_ENGINE(VCS);
CHECK_ENGINE(VECS);
CHECK_ENGINE(CCS);
#undef CHECK_ENGINE
}
TEST(EngineNodeHelperTests, givenInvalidEngineTypeWhenGettingStringRepresentationThenItIsCorrect) {
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(aub_stream::EngineType::NUM_ENGINES));
EXPECT_EQ(std::string{"Unknown"}, EngineHelpers::engineTypeToString(static_cast<aub_stream::EngineType>(0xcc)));
}