L0Debug - add debug message when ZE_AFFINITY_MASK is used
Related-To: NEO-6980 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
parent
ec1de69fee
commit
eb0273d6ff
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include "level_zero/tools/source/debug/debug_handlers.h"
|
||||
|
||||
#include "shared/source/os_interface/debug_env_reader.h"
|
||||
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
#include "level_zero/tools/source/debug/debug_session.h"
|
||||
|
||||
|
@ -22,6 +24,14 @@ ze_result_t debugAttach(zet_device_handle_t hDevice, const zet_debug_config_t *c
|
|||
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
|
||||
}
|
||||
|
||||
NEO::EnvironmentVariableReader envReader;
|
||||
auto affinityMask = envReader.getSetting("ZE_AFFINITY_MASK", std::string(""));
|
||||
|
||||
if (!affinityMask.empty()) {
|
||||
NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stdout,
|
||||
"%s", "ZE_AFFINITY_MASK is not recommended while using program debug API\n");
|
||||
}
|
||||
|
||||
auto session = L0::Device::fromHandle(hDevice)->getDebugSession(*config);
|
||||
|
||||
std::unique_lock<std::mutex> lock(debugSessionMutex);
|
||||
|
|
|
@ -5,7 +5,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/mock_sip.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
|
@ -313,7 +316,7 @@ TEST(DebugSessionTest, givenDeviceWithDebugSessionWhenRemoveCalledThenSessionIsN
|
|||
EXPECT_EQ(nullptr, deviceImp.debugSession.get());
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenSubDeviceWhenCreateingSessionThenNullptrReturned) {
|
||||
TEST(DebugSessionTest, givenSubDeviceWhenCreatingSessionThenNullptrReturned) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
|
@ -328,7 +331,7 @@ TEST(DebugSessionTest, givenSubDeviceWhenCreateingSessionThenNullptrReturned) {
|
|||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
}
|
||||
|
||||
TEST(DebugSessionTest, givenRootDeviceWhenCreateingSessionThenResultReturnedIsCorrect) {
|
||||
TEST(DebugSessionTest, givenRootDeviceWhenCreatingSessionThenResultReturnedIsCorrect) {
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
|
@ -348,5 +351,27 @@ TEST(DebugSessionTest, givenRootDeviceWhenCreateingSessionThenResultReturnedIsCo
|
|||
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result);
|
||||
}
|
||||
|
||||
TEST_F(DebugApiTest, givenZeAffinityMaskAndEnabledDebugMessagesWhenDebugAttachCalledThenMessageIsPrinted) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.PrintDebugMessages.set(1);
|
||||
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_AFFINITY_MASK", "0.1"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
zet_debug_config_t config = {};
|
||||
config.pid = 0x1234;
|
||||
|
||||
Mock<L0::DeviceImp> deviceImp(neoDevice, neoDevice->getExecutionEnvironment());
|
||||
deviceImp.debugSession.reset(new DebugSessionMock(config, &deviceImp));
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
zet_debug_session_handle_t debugSession = nullptr;
|
||||
zetDebugAttach(deviceImp.toHandle(), &config, &debugSession);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(std::string("ZE_AFFINITY_MASK is not recommended while using program debug API\n"), output);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
|
Loading…
Reference in New Issue