Skip to content

Commit 03dc51e

Browse files
committed
[L0] Enable Sysman Thru Env by default and have zesInit be optional
- Enable ZES_ENABLE_SYSMAN=1 by default unless UR_L0_ENABLE_SYSMAN_ENV_DEFAULT==0. - Allows for Sysman support thru zeInit() without user input. - Added UR_L0_ENABLE_ZESINIT_DEFAULT to allow for a customer to enable zesInit over sysman env init if the env allows it. - NOTE: UR_L0_ENABLE_ZESINIT_DEFAULT=1 requires UR_L0_ENABLE_SYSMAN_ENV_DEFAULT==0 due to the env overwriting the zesInit support. Signed-off-by: Neil R. Spruit <[email protected]>
1 parent eddfd8e commit 03dc51e

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

source/adapters/level_zero/adapter.cpp

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
169169
return;
170170
}
171171

172+
// Check if the user has disabled the default L0 Env initialization.
173+
const int UrSysManEnvInitEnabled = [] {
174+
const char *UrRet = std::getenv("UR_L0_ENABLE_SYSMAN_ENV_DEFAULT");
175+
if (!UrRet)
176+
return 1;
177+
return std::atoi(UrRet);
178+
}();
179+
172180
// initialize level zero only once.
173181
if (GlobalAdapter->ZeResult == std::nullopt) {
174182
// Setting these environment variables before running zeInit will enable
@@ -196,6 +204,11 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
196204
if (UrL0InitAllDrivers) {
197205
L0InitFlags |= ZE_INIT_FLAG_VPU_ONLY;
198206
}
207+
208+
// Set ZES_ENABLE_SYSMAN by default if the user has not set it.
209+
if (UrSysManEnvInitEnabled) {
210+
setEnvVar("ZES_ENABLE_SYSMAN", "1");
211+
}
199212
logger::debug("\nzeInit with flags value of {}\n",
200213
static_cast<int>(L0InitFlags));
201214
GlobalAdapter->ZeResult = ZE_CALL_NOCHECK(zeInit, (L0InitFlags));
@@ -223,15 +236,29 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
223236
#else
224237
HMODULE processHandle = nullptr;
225238
#endif
226-
GlobalAdapter->getDeviceByUUIdFunctionPtr =
227-
(zes_pfnDriverGetDeviceByUuidExp_t)ur_loader::LibLoader::getFunctionPtr(
228-
processHandle, "zesDriverGetDeviceByUuidExp");
229-
GlobalAdapter->getSysManDriversFunctionPtr =
230-
(zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr(
231-
processHandle, "zesDriverGet");
232-
GlobalAdapter->sysManInitFunctionPtr =
233-
(zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr(processHandle,
234-
"zesInit");
239+
240+
// Check if the user has enabled the default L0 SysMan initialization.
241+
const int UrSysmanZesinitEnable = [] {
242+
const char *UrRet = std::getenv("UR_L0_ENABLE_ZESINIT_DEFAULT");
243+
if (!UrRet)
244+
return 0;
245+
return std::atoi(UrRet);
246+
}();
247+
248+
// Enable zesInit by default only if ZES_ENABLE_SYSMAN has not been set by
249+
// default and UrSysmanZesinitEnable is true.
250+
if (UrSysmanZesinitEnable && !UrSysManEnvInitEnabled) {
251+
GlobalAdapter->getDeviceByUUIdFunctionPtr =
252+
(zes_pfnDriverGetDeviceByUuidExp_t)
253+
ur_loader::LibLoader::getFunctionPtr(
254+
processHandle, "zesDriverGetDeviceByUuidExp");
255+
GlobalAdapter->getSysManDriversFunctionPtr =
256+
(zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr(
257+
processHandle, "zesDriverGet");
258+
GlobalAdapter->sysManInitFunctionPtr =
259+
(zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr(processHandle,
260+
"zesInit");
261+
}
235262
if (GlobalAdapter->getDeviceByUUIdFunctionPtr &&
236263
GlobalAdapter->getSysManDriversFunctionPtr &&
237264
GlobalAdapter->sysManInitFunctionPtr) {

0 commit comments

Comments
 (0)