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 9, 2022
1 parent 8da5c50 commit d62c6f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
37 changes: 26 additions & 11 deletions bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ BEGIN
use lib "$base_dir/";
use hipvars;

$isWindows = $hipvars::isWindows;
$HIP_RUNTIME = $hipvars::HIP_RUNTIME;
$HIP_PLATFORM = $hipvars::HIP_PLATFORM;
$HIP_COMPILER = $hipvars::HIP_COMPILER;
$HIP_CLANG_PATH = $hipvars::HIP_CLANG_PATH;
$CUDA_PATH = $hipvars::CUDA_PATH;
$HIP_PATH = $hipvars::HIP_PATH;
$ROCM_PATH = $hipvars::ROCM_PATH;
$HIP_VERSION = $hipvars::HIP_VERSION;
$HSA_PATH = $hipvars::HSA_PATH;
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;
$isWindows = $hipvars::isWindows;
$HIP_RUNTIME = $hipvars::HIP_RUNTIME;
$HIP_PLATFORM = $hipvars::HIP_PLATFORM;
$HIP_COMPILER = $hipvars::HIP_COMPILER;
$HIP_CLANG_PATH = $hipvars::HIP_CLANG_PATH;
$CUDA_PATH = $hipvars::CUDA_PATH;
$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;

if ($HIP_PLATFORM eq "amd") {
# If using ROCclr runtime, need to find HIP_ROCCLR_HOME
Expand Down Expand Up @@ -165,6 +166,20 @@ BEGIN
$HIP_CLANG_TARGET = `$HIPCC -print-target-triple`;
$HIP_CLANG_TARGET = chomp($HIP_CLANG_TARGET);

# 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.
if (! -f $HIP_VERSION_PATH) {
my $v = (split('-', $HIP_VERSION))[0]; # Remove the git hash
$HIPCXXFLAGS .= " --hip-version=$v";
$HIPCFLAGS .= " --hip-version=$v";
$HIPLDFLAGS .= " --hip-version=$v";
}

if (! defined $HIP_CLANG_INCLUDE_PATH) {
$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/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 d62c6f0

Please sign in to comment.