Skip to content

Commit

Permalink
Pass HIP version via a commandline argument if .hipVersion is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
awehrfritz committed Sep 11, 2022
1 parent 8da5c50 commit becc136
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit becc136

Please sign in to comment.