mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Detect enable program debugging env variable
Resolves: NEO-4713 Change-Id: Id9ce30b84943c4b364f7756a430d58df2614a28b Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
dadbd5a09f
commit
d55a0ae5c6
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/debug_env_reader.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
@@ -161,7 +162,9 @@ DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> dev
|
||||
DriverHandleImp *driverHandle = new DriverHandleImp;
|
||||
UNRECOVERABLE_IF(nullptr == driverHandle);
|
||||
|
||||
driverHandle->getEnv("ZE_AFFINITY_MASK", driverHandle->affinityMask);
|
||||
NEO::EnvironmentVariableReader envReader;
|
||||
driverHandle->affinityMask = envReader.getSetting("ZE_AFFINITY_MASK", static_cast<int32_t>(driverHandle->affinityMask));
|
||||
driverHandle->enableProgramDebugging = envReader.getSetting("ZET_ENABLE_PROGRAM_DEBUGGING", driverHandle->enableProgramDebugging);
|
||||
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -58,16 +58,6 @@ struct DriverHandleImp : public DriverHandle {
|
||||
size_t size,
|
||||
bool *allocationRangeCovered) override;
|
||||
|
||||
template <typename T>
|
||||
bool getEnv(const char *varName, T &varValue) {
|
||||
char *varChar = getenv(varName);
|
||||
if (varChar) {
|
||||
varValue = static_cast<T>(atoi(varChar));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t numDevices = 0;
|
||||
std::unordered_map<std::string, void *> extensionFunctionsLookupMap;
|
||||
std::vector<Device *> devices;
|
||||
@@ -75,6 +65,7 @@ struct DriverHandleImp : public DriverHandle {
|
||||
NEO::SVMAllocsManager *svmAllocsManager = nullptr;
|
||||
|
||||
uint32_t affinityMask = std::numeric_limits<uint32_t>::max();
|
||||
bool enableProgramDebugging = false;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -21,10 +21,11 @@ namespace L0 {
|
||||
namespace ult {
|
||||
|
||||
template <>
|
||||
struct WhiteBox<::L0::DriverHandleImp> : public ::L0::DriverHandleImp {
|
||||
struct WhiteBox<::L0::DriverHandle> : public ::L0::DriverHandleImp {
|
||||
using ::L0::DriverHandleImp::enableProgramDebugging;
|
||||
};
|
||||
|
||||
using DriverHandle = WhiteBox<::L0::DriverHandleImp>;
|
||||
using DriverHandle = WhiteBox<::L0::DriverHandle>;
|
||||
|
||||
template <>
|
||||
struct Mock<DriverHandle> : public DriverHandleImp {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/os_interface/hw_info_config.h"
|
||||
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_io_functions.h"
|
||||
#include "test.h"
|
||||
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
@@ -60,6 +61,40 @@ TEST(DriverTestFamilySupport, whenInitializingDriverOnNotSupportedFamilyThenDriv
|
||||
EXPECT_EQ(nullptr, driverHandle);
|
||||
}
|
||||
|
||||
TEST(DriverTest, givenNullEnvVariableWhenCreatingDriverThenEnableProgramDebuggingIsFalse) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
hwInfo.capabilityTable.levelZeroSupported = true;
|
||||
|
||||
NEO::MockDevice *neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
|
||||
auto driverHandle = whitebox_cast(DriverHandle::create(std::move(devices)));
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
|
||||
EXPECT_FALSE(driverHandle->enableProgramDebugging);
|
||||
|
||||
delete driverHandle;
|
||||
}
|
||||
|
||||
TEST(DriverTest, givenEnvVariableNonZeroWhenCreatingDriverThenEnableProgramDebuggingIsSetTrue) {
|
||||
NEO::HardwareInfo hwInfo = *NEO::defaultHwInfo.get();
|
||||
hwInfo.capabilityTable.levelZeroSupported = true;
|
||||
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&IoFunctions::returnMockEnvValue, true);
|
||||
|
||||
NEO::MockDevice *neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo);
|
||||
NEO::DeviceVector devices;
|
||||
devices.push_back(std::unique_ptr<NEO::Device>(neoDevice));
|
||||
|
||||
auto driverHandle = whitebox_cast(DriverHandle::create(std::move(devices)));
|
||||
EXPECT_NE(nullptr, driverHandle);
|
||||
|
||||
EXPECT_TRUE(driverHandle->enableProgramDebugging);
|
||||
|
||||
delete driverHandle;
|
||||
}
|
||||
|
||||
struct DriverTestMultipleFamilySupport : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
VariableBackup<bool> mockDeviceFlagBackup(&MockDevice::createSingleDevice, false);
|
||||
|
||||
Reference in New Issue
Block a user