Skip to content

Rework constructHipPath so HIP_PATH env var is lower priority. #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: amd-staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions amd/hipcc/src/hipBin_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,34 @@ void HipBinBase::readEnvVariables() {

// constructs the HIP path
void HipBinBase::constructHipPath() {
// we need to use --hip-path option
// The --hip-path argument option takes precedence over all other settings.
string hip_path_name = gethip_pathOption();
if (!hip_path_name.empty()) {
variables_.hipPathEnv_ = hip_path_name;
} else if (envVariables_.hipPathEnv_.empty()) {
fs::path full_path(hipcc::utils::getSelfPath());
variables_.hipPathEnv_ = (full_path.parent_path()).string();
} else {
return;
}

fs::path full_path(hipcc::utils::getSelfPath());
fs::path parent_path = full_path.parent_path();

// Next, check for `../lib/llvm/bin/`, the standard ROCm install structure.
fs::path llvm_path = parent_path / "lib" / "llvm" / "bin";
if (fs::exists(llvm_path)) {
variables_.hipPathEnv_ = parent_path.string();
return;
}

// Otherwise, check the HIP_PATH environment variable from the HIP SDK.
// Normally an environment variable setting could take precedence over an
// implicit path, but this environment variable is set by system-wide installs
// and self-contained builds/installs should not be reading that global state.
if (!envVariables_.hipPathEnv_.empty()) {
variables_.hipPathEnv_ = envVariables_.hipPathEnv_;
return;
}

// Finally, fallback to the parent path (the standard ROCm install structure).
variables_.hipPathEnv_ = parent_path.string();
}


Expand Down
Loading