diff --git a/README.md b/README.md index ff204ddb9..b68e07566 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ CHIP_DUMP_SPIRV= # Dumps the generated SPIR-V cod CHIP_JIT_FLAGS= # String to override the default JIT flags. Defaults to -cl-kernel-arg-info -cl-std=CL3.0 CHIP_L0_COLLECT_EVENTS_TIMEOUT= # Timeout in seconds for collecting Level Zero events CHIP_L0_IMM_CMD_LISTS= # Use immediate command lists in Level Zero +CHIP_SKIP_UNINIT= # If enabled, skips the uninitialization of chipStar's backend objects at program termination ``` Example: diff --git a/docs/release_notes/chipStar_1.1.rst b/docs/release_notes/chipStar_1.1.rst index 749443901..77890ad4f 100644 --- a/docs/release_notes/chipStar_1.1.rst +++ b/docs/release_notes/chipStar_1.1.rst @@ -109,3 +109,8 @@ Major Bugfixes * Do not pass ``-x spir`` to clBuildProgram() in OpenCL backend. '-x spir' requests compilation of the old SPIR 1.2/2.0 whereas we use the new SPIR-V which doesn't need the build flag, as long as we call clCreateProgramWithIL(). Passing the flag might fail if the device doesn't support the old SPIR even though it supports the new SPIR-V. +=============== +Known Issues +=============== + +* certain combinations of drivers, hardware and OpenCL backend causes chipStar to crash at exit. As a workaround, the user can set the CHIP_SKIP_UNINIT env variable to skip the uninitialization of the chipStar library. diff --git a/src/CHIPDriver.cc b/src/CHIPDriver.cc index 3c8289bd0..5036aefe0 100644 --- a/src/CHIPDriver.cc +++ b/src/CHIPDriver.cc @@ -126,6 +126,10 @@ extern void CHIPInitialize() { void CHIPUninitializeCallOnce() { logDebug("Uninitializing CHIP..."); + if (ChipEnvVars.getSkipUninit()) { + logWarn("Uninitialization skipped"); + return; + } if (Backend) { if (getSPVRegister().getNumSources()) { logWarn("Program still has unloaded HIP modules at program exit."); diff --git a/src/CHIPDriver.hh b/src/CHIPDriver.hh index 69c13d979..2e585980e 100644 --- a/src/CHIPDriver.hh +++ b/src/CHIPDriver.hh @@ -227,6 +227,7 @@ private: int DeviceIdx_ = 0; BackendType Backend_; bool DumpSpirv_ = false; + bool SkipUninit_ = false; std::string JitFlags_ = CHIP_DEFAULT_JIT_FLAGS; bool L0ImmCmdLists_ = true; int L0CollectEventsTimeout_ = 0; @@ -242,6 +243,7 @@ public: int getDeviceIdx() const { return DeviceIdx_; } BackendType getBackend() const { return Backend_; } bool getDumpSpirv() const { return DumpSpirv_; } + bool getSkipUninit() const { return SkipUninit_; } const std::string &getJitFlags() const { return JitFlags_; } bool getL0ImmCmdLists() const { return L0ImmCmdLists_; } int getL0CollectEventsTimeout() const { return L0CollectEventsTimeout_; } @@ -262,6 +264,9 @@ private: if (!readEnvVar("CHIP_DUMP_SPIRV").empty()) DumpSpirv_ = parseBoolean("CHIP_DUMP_SPIRV"); + if (!readEnvVar("CHIP_SKIP_UNINIT").empty()) + SkipUninit_ = parseBoolean("CHIP_SKIP_UNINIT"); + JitFlags_ = parseJitFlags("CHIP_JIT_FLAGS_OVERRIDE"); if (!readEnvVar("CHIP_L0_IMM_CMD_LISTS").empty()) @@ -308,6 +313,7 @@ private: logDebug("CHIP_JIT_FLAGS_OVERRIDE={}", JitFlags_); logDebug("CHIP_L0_IMM_CMD_LISTS={}", L0ImmCmdLists_ ? "on" : "off"); logDebug("CHIP_L0_COLLECT_EVENTS_TIMEOUT={}", L0CollectEventsTimeout_); + logDebug("CHIP_SKIP_UNINIT={}", SkipUninit_ ? "on" : "off"); } };