@@ -506,72 +506,71 @@ ur_adapter_handle_t_::ur_adapter_handle_t_()
506506 bool forceLoadedAdapter = ur_getenv (" UR_ADAPTERS_FORCE_LOAD" ).has_value ();
507507 if (!forceLoadedAdapter) {
508508#ifdef UR_ADAPTER_LEVEL_ZERO_V2
509- auto [useV2, reason] = shouldUseV2Adapter ();
510- if (!useV2) {
511- UR_LOG (INFO, " Skipping L0 V2 adapter: {}" , reason);
512- return ;
513- }
509+ auto [useV2, reason] = shouldUseV2Adapter ();
510+ if (!useV2) {
511+ UR_LOG (INFO, " Skipping L0 V2 adapter: {}" , reason);
512+ return ;
513+ }
514514#else
515- auto [useV1, reason] = shouldUseV1Adapter ();
516- if (!useV1) {
517- UR_LOG (INFO, " Skipping L0 V1 adapter: {}" , reason);
518- return ;
519- }
515+ auto [useV1, reason] = shouldUseV1Adapter ();
516+ if (!useV1) {
517+ UR_LOG (INFO, " Skipping L0 V1 adapter: {}" , reason);
518+ return ;
519+ }
520520#endif
521521 }
522522
523- // Check if the user has enabled the default L0 SysMan initialization.
524- const int UrSysmanZesinitEnable = [&UserForcedSysManInit] {
525- const char *UrRet = std::getenv (" UR_L0_ENABLE_ZESINIT_DEFAULT" );
526- if (!UrRet)
527- return 0 ;
528- UserForcedSysManInit &= 2 ;
529- return std::atoi (UrRet);
530- }();
531-
532- bool ZesInitNeeded = UrSysmanZesinitEnable && !UrSysManEnvInitEnabled;
533- // Unless the user has forced the SysMan init, we will check the device
534- // version to see if the zesInit is needed.
535- if (UserForcedSysManInit == 0 && checkDeviceIntelGPUIpVersionOrNewer (
536- 0x05004000 ) == UR_RESULT_SUCCESS) {
537- if (UrSysManEnvInitEnabled) {
538- setEnvVar (" ZES_ENABLE_SYSMAN" , " 0" );
539- }
540- ZesInitNeeded = true ;
541- }
542- if (ZesInitNeeded) {
523+ // Check if the user has enabled the default L0 SysMan initialization.
524+ const int UrSysmanZesinitEnable = [&UserForcedSysManInit] {
525+ const char *UrRet = std::getenv (" UR_L0_ENABLE_ZESINIT_DEFAULT" );
526+ if (!UrRet)
527+ return 0 ;
528+ UserForcedSysManInit &= 2 ;
529+ return std::atoi (UrRet);
530+ }();
531+
532+ bool ZesInitNeeded = UrSysmanZesinitEnable && !UrSysManEnvInitEnabled;
533+ // Unless the user has forced the SysMan init, we will check the device
534+ // version to see if the zesInit is needed.
535+ if (UserForcedSysManInit == 0 &&
536+ checkDeviceIntelGPUIpVersionOrNewer ( 0x05004000 ) == UR_RESULT_SUCCESS) {
537+ if (UrSysManEnvInitEnabled) {
538+ setEnvVar (" ZES_ENABLE_SYSMAN" , " 0" );
539+ }
540+ ZesInitNeeded = true ;
541+ }
542+ if (ZesInitNeeded) {
543543#ifdef UR_STATIC_LEVEL_ZERO
544- getDeviceByUUIdFunctionPtr = zesDriverGetDeviceByUuidExp;
545- getSysManDriversFunctionPtr = zesDriverGet;
546- sysManInitFunctionPtr = zesInit;
544+ getDeviceByUUIdFunctionPtr = zesDriverGetDeviceByUuidExp;
545+ getSysManDriversFunctionPtr = zesDriverGet;
546+ sysManInitFunctionPtr = zesInit;
547547#else
548- getDeviceByUUIdFunctionPtr = (zes_pfnDriverGetDeviceByUuidExp_t)
549- ur_loader::LibLoader::getFunctionPtr (processHandle,
550- " zesDriverGetDeviceByUuidExp" );
551- getSysManDriversFunctionPtr =
552- (zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr (
553- processHandle, " zesDriverGet" );
554- sysManInitFunctionPtr =
555- (zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr (processHandle,
556- " zesInit" );
548+ getDeviceByUUIdFunctionPtr =
549+ (zes_pfnDriverGetDeviceByUuidExp_t)ur_loader::LibLoader::getFunctionPtr (
550+ processHandle, " zesDriverGetDeviceByUuidExp" );
551+ getSysManDriversFunctionPtr =
552+ (zes_pfnDriverGet_t)ur_loader::LibLoader::getFunctionPtr (
553+ processHandle, " zesDriverGet" );
554+ sysManInitFunctionPtr = (zes_pfnInit_t)ur_loader::LibLoader::getFunctionPtr (
555+ processHandle, " zesInit" );
557556#endif
558- }
559- if (getDeviceByUUIdFunctionPtr && getSysManDriversFunctionPtr &&
560- sysManInitFunctionPtr) {
561- ze_init_flags_t L0ZesInitFlags = 0 ;
562- UR_LOG (DEBUG, " \n zesInit with flags value of {}\n " ,
563- static_cast <int >(L0ZesInitFlags));
564- ZesResult = ZE_CALL_NOCHECK (sysManInitFunctionPtr, (L0ZesInitFlags));
565- } else {
566- ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
567- }
557+ }
558+ if (getDeviceByUUIdFunctionPtr && getSysManDriversFunctionPtr &&
559+ sysManInitFunctionPtr) {
560+ ze_init_flags_t L0ZesInitFlags = 0 ;
561+ UR_LOG (DEBUG, " \n zesInit with flags value of {}\n " ,
562+ static_cast <int >(L0ZesInitFlags));
563+ ZesResult = ZE_CALL_NOCHECK (sysManInitFunctionPtr, (L0ZesInitFlags));
564+ } else {
565+ ZesResult = ZE_RESULT_ERROR_UNINITIALIZED;
566+ }
568567
569- ur_result_t err = initPlatforms (this , platforms, ZesResult);
570- if (err == UR_RESULT_SUCCESS) {
571- Platforms = std::move (platforms);
572- } else {
573- throw err;
574- }
568+ ur_result_t err = initPlatforms (this , platforms, ZesResult);
569+ if (err == UR_RESULT_SUCCESS) {
570+ Platforms = std::move (platforms);
571+ } else {
572+ throw err;
573+ }
575574}
576575
577576void globalAdapterOnDemandCleanup () {
0 commit comments