Skip to content
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

Pass HIP version via a commandline argument if .hipVersion is missing #2937

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ BEGIN
$HIP_PATH = $hipvars::HIP_PATH;
$ROCM_PATH = $hipvars::ROCM_PATH;
$HIP_VERSION = $hipvars::HIP_VERSION;
$HIP_VERSION_PATH = $hipvars::HIP_VERSION_PATH;
$HSA_PATH = $hipvars::HSA_PATH;
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;

Expand Down Expand Up @@ -204,6 +205,19 @@ BEGIN
$HIPCFLAGS .= " -isystem $HSA_PATH/include";
}

# Clang requires the HIP version information, passed either via a
# commandline argument or by reading it from the .hipVersion file
# (see clang/lib/Driver/ToolChains/AMDGPU.cpp). Since there is no FHS
# compliant location for .hipVersion where clang will still be able to find
# it, .hipVersion has been omitted in the downstream distribution packages
# (Debian/Fedora) and subsequently the hip version needs to be passed
# explicitly. Subsequently, clang requires the ROCm path to be passed via
# the respective command line argument as well.
if (! -f $HIP_VERSION_PATH) {
my $v = (split('-', $HIP_VERSION))[0]; # Remove the git hash
$HIPCC_COMPILE_FLAGS_APPEND .= " --rocm-path=$ROCM_PATH --hip-version=$v";
$HIPCC_LINK_FLAGS_APPEND .= " --rocm-path=$ROCM_PATH --hip-version=$v";
}
} elsif ($HIP_PLATFORM eq "nvidia") {
$CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda';
$HIP_INCLUDE_PATH = "$HIP_PATH/include";
Expand Down
3 changes: 2 additions & 1 deletion bin/hipvars.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ if ($HIP_COMPILER eq "clang") {
#---
# Read .hipVersion
my %hipVersion = ();
parse_config_file("$hipvars::HIP_PATH/bin/.hipVersion", \%hipVersion);
$HIP_VERSION_PATH = "$HIP_PATH/bin/.hipVersion";
parse_config_file("$HIP_VERSION_PATH", \%hipVersion);
$HIP_VERSION_MAJOR = $hipVersion{'HIP_VERSION_MAJOR'} // $HIP_BASE_VERSION_MAJOR;
$HIP_VERSION_MINOR = $hipVersion{'HIP_VERSION_MINOR'} // $HIP_BASE_VERSION_MINOR;
$HIP_VERSION_PATCH = $hipVersion{'HIP_VERSION_PATCH'} // $HIP_BASE_VERSION_PATCH;
Expand Down