mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Move reading env vars to DriverImp
- add requirePerContextMemorySpace flag to ExecEnv Related-To: NEO-4637 Change-Id: I3968bedd9cfd1b1e41e79b63939b7a9bf25e7ff5 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
74ac02e1f3
commit
073a40c14c
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/os_interface/debug_env_reader.h"
|
||||
#include "shared/source/os_interface/device_factory.h"
|
||||
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
@@ -26,14 +27,25 @@ uint32_t driverCount = 1;
|
||||
void DriverImp::initialize(bool *result) {
|
||||
*result = false;
|
||||
|
||||
NEO::EnvironmentVariableReader envReader;
|
||||
L0EnvVariables envVariables = {};
|
||||
envVariables.affinityMask =
|
||||
envReader.getSetting("ZE_AFFINITY_MASK", std::string(""));
|
||||
envVariables.programDebugging =
|
||||
envReader.getSetting("ZET_ENABLE_PROGRAM_DEBUGGING", false);
|
||||
|
||||
auto executionEnvironment = new NEO::ExecutionEnvironment();
|
||||
UNRECOVERABLE_IF(nullptr == executionEnvironment);
|
||||
|
||||
if (envVariables.programDebugging) {
|
||||
executionEnvironment->setPerContextMemorySpace();
|
||||
}
|
||||
|
||||
executionEnvironment->incRefInternal();
|
||||
auto neoDevices = NEO::DeviceFactory::createDevices(*executionEnvironment);
|
||||
executionEnvironment->decRefInternal();
|
||||
if (!neoDevices.empty()) {
|
||||
GlobalDriverHandle = DriverHandle::create(std::move(neoDevices));
|
||||
GlobalDriverHandle = DriverHandle::create(std::move(neoDevices), envVariables);
|
||||
if (GlobalDriverHandle != nullptr) {
|
||||
*result = true;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ struct _ze_driver_handle_t {
|
||||
|
||||
namespace L0 {
|
||||
struct Device;
|
||||
struct L0EnvVariables;
|
||||
|
||||
struct DriverHandle : _ze_driver_handle_t {
|
||||
virtual ze_result_t getDevice(uint32_t *pCount, ze_device_handle_t *phDevices) = 0;
|
||||
@@ -65,7 +66,7 @@ struct DriverHandle : _ze_driver_handle_t {
|
||||
DriverHandle &operator=(const DriverHandle &) = delete;
|
||||
DriverHandle &operator=(DriverHandle &&) = delete;
|
||||
|
||||
static DriverHandle *create(std::vector<std::unique_ptr<NEO::Device>> devices);
|
||||
static DriverHandle *create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables);
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#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/debugger/debugger_l0.h"
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
#include "level_zero/core/source/driver/driver_imp.h"
|
||||
|
||||
#include "driver_version_l0.h"
|
||||
|
||||
@@ -176,15 +176,12 @@ ze_result_t DriverHandleImp::initialize(std::vector<std::unique_ptr<NEO::Device>
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> devices) {
|
||||
DriverHandle *DriverHandle::create(std::vector<std::unique_ptr<NEO::Device>> devices, const L0EnvVariables &envVariables) {
|
||||
DriverHandleImp *driverHandle = new DriverHandleImp;
|
||||
UNRECOVERABLE_IF(nullptr == driverHandle);
|
||||
|
||||
NEO::EnvironmentVariableReader envReader;
|
||||
driverHandle->affinityMaskString =
|
||||
envReader.getSetting("ZE_AFFINITY_MASK", driverHandle->affinityMaskString);
|
||||
driverHandle->enableProgramDebugging =
|
||||
envReader.getSetting("ZET_ENABLE_PROGRAM_DEBUGGING", driverHandle->enableProgramDebugging);
|
||||
driverHandle->affinityMaskString = envVariables.affinityMask;
|
||||
driverHandle->enableProgramDebugging = envVariables.programDebugging;
|
||||
|
||||
ze_result_t res = driverHandle->initialize(std::move(devices));
|
||||
if (res != ZE_RESULT_SUCCESS) {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "level_zero/core/source/driver/driver.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace L0 {
|
||||
|
||||
@@ -23,4 +24,10 @@ class DriverImp : public Driver {
|
||||
std::once_flag initDriverOnce;
|
||||
static bool initStatus;
|
||||
};
|
||||
|
||||
struct L0EnvVariables {
|
||||
std::string affinityMask;
|
||||
bool programDebugging;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
|
||||
Reference in New Issue
Block a user