Skip to content

Commit

Permalink
levelzero: remove the setting of ZES_ENABLE_SYSMAN=1
Browse files Browse the repository at this point in the history
Now that zesInit() is widely available, remove all the stuff trying
to set ZES_ENABLE_SYSMAN=1 in the environment early.
If people really cannot use a recent runtime with zesInit(),
they should take care of setting ZES_ENABLE_SYSMAN=1.

Signed-off-by: Brice Goglin <[email protected]>
  • Loading branch information
bgoglin committed Jun 12, 2023
1 parent c6645e8 commit f04d462
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 69 deletions.
18 changes: 0 additions & 18 deletions hwloc/topology-levelzero.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,24 +533,6 @@ hwloc_levelzero_discover(struct hwloc_backend *backend, struct hwloc_disc_status
}
return 0;
}
#else /* !HWLOC_HAVE_ZESINIT */
/* Tell L0 to create sysman devices.
* If somebody already initialized L0 without Sysman,
* zesDeviceGetProperties() will fail and warn in hwloc__levelzero_properties_get().
* The lib constructor and Windows DllMain tried to set ZES_ENABLE_SYSMAN=1 early (see topology.c),
* we try again in case they didn't.
*/
{
char *env = getenv("ZES_ENABLE_SYSMAN");
if (!env) {
/* setenv() is safer than putenv() but not available on Windows */
#ifdef HWLOC_WIN_SYS
putenv("ZES_ENABLE_SYSMAN=1");
#else
setenv("ZES_ENABLE_SYSMAN", "1", 1);
#endif
}
}
#endif /* !HWLOC_HAVE_ZESINIT */

res = zeInit(0);
Expand Down
51 changes: 0 additions & 51 deletions hwloc/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,57 +54,6 @@
#endif


#if (defined HWLOC_HAVE_LEVELZERO) && !(defined HWLOC_HAVE_ZESINIT)
/*
* Define ZES_ENABLE_SYSMAN=1 early so that the LevelZero backend gets Sysman enabled.
* This is only for old releases (<1.5) without zesInit().
*
* Only if the levelzero was enabled in this build so that we don't enable sysman
* for external levelzero users when hwloc doesn't need it. If somebody ever loads
* an external levelzero plugin in a hwloc library built without levelzero (unlikely),
* he may have to manually set ZES_ENABLE_SYSMAN=1.
*
* Use the constructor if supported and/or the Windows DllMain callback.
* Do it in the main hwloc library instead of the levelzero component because
* the latter could be loaded later as a plugin.
*
* L0 seems to be using getenv() to check this variable on Windows
* (at least in the Intel Compute-Runtime of March 2021),
* but setenv() doesn't seem to exist on Windows, hence use putenv() to set the variable.
*
* For the record, Get/SetEnvironmentVariable() is not exactly the same as getenv/putenv():
* - getenv() doesn't see what was set with SetEnvironmentVariable()
* - GetEnvironmentVariable() doesn't see putenv() in cygwin (while it does in MSVC and MinGW).
* Hence, if L0 ever switches from getenv() to GetEnvironmentVariable(),
* it will break in cygwin, we'll have to use both putenv() and SetEnvironmentVariable().
* Hopefully L0 will provide a way to enable Sysman without env vars before it happens.
*/
#if HWLOC_HAVE_ATTRIBUTE_CONSTRUCTOR
static void hwloc_constructor(void) __attribute__((constructor));
static void hwloc_constructor(void)
{
if (!getenv("ZES_ENABLE_SYSMAN"))
#ifdef HWLOC_WIN_SYS
putenv("ZES_ENABLE_SYSMAN=1");
#else
setenv("ZES_ENABLE_SYSMAN", "1", 1);
#endif
}
#endif
#ifdef HWLOC_WIN_SYS
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH) {
if (!getenv("ZES_ENABLE_SYSMAN"))
/* Windows does not have a setenv, so use putenv. */
putenv((char *) "ZES_ENABLE_SYSMAN=1");
}
return TRUE;
}
#endif
#endif /* HWLOC_HAVE_LEVELZERO && !HWLOC_HAVE_ZESINIT */


unsigned hwloc_get_api_version(void)
{
return HWLOC_API_VERSION;
Expand Down

0 comments on commit f04d462

Please sign in to comment.