Skip to content

Commit

Permalink
add workaround for issue #739
Browse files Browse the repository at this point in the history
  • Loading branch information
franz committed Jan 8, 2024
1 parent f234d18 commit f90bbe7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ CHIP_DUMP_SPIRV=<ON/OFF(default)> # Dumps the generated SPIR-V cod
CHIP_JIT_FLAGS=<flags> # String to override the default JIT flags. Defaults to -cl-kernel-arg-info -cl-std=CL3.0
CHIP_L0_COLLECT_EVENTS_TIMEOUT=<N(30s default)> # Timeout in seconds for collecting Level Zero events
CHIP_L0_IMM_CMD_LISTS=<ON(default)/OFF> # Use immediate command lists in Level Zero
CHIP_SKIP_UNINIT=<ON/OFF(default)> # If enabled, skips the uninitialization of chipStar's backend objects at program termination
```

Example:
Expand Down
5 changes: 5 additions & 0 deletions docs/release_notes/chipStar_1.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 4 additions & 0 deletions src/CHIPDriver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
6 changes: 6 additions & 0 deletions src/CHIPDriver.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_; }
Expand All @@ -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())
Expand Down Expand Up @@ -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");
}
};

Expand Down

0 comments on commit f90bbe7

Please sign in to comment.