Skip to content
Draft
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions bin/hipcc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ BEGIN
$HIP_VERSION = $hipvars::HIP_VERSION;
$HSA_PATH = $hipvars::HSA_PATH;
$HIP_ROCCLR_HOME = $hipvars::HIP_ROCCLR_HOME;
$LIB = $hipvars::LIB;

if ($HIP_PLATFORM eq "amd") {
# If using ROCclr runtime, need to find HIP_ROCCLR_HOME
Expand All @@ -113,14 +114,15 @@ BEGIN
}
$HIP_INCLUDE_PATH = "$HIP_ROCCLR_HOME/include";
if (!defined $HIP_LIB_PATH) {
$HIP_LIB_PATH = "$HIP_ROCCLR_HOME/lib";
$HIP_LIB_PATH = "$HIP_ROCCLR_HOME/$LIB";
}

if (!defined $DEVICE_LIB_PATH) {
if (-e "$ROCM_PATH/amdgcn/bitcode") {
$DEVICE_LIB_PATH = "$ROCM_PATH/amdgcn/bitcode";
}
else {
} elsif (-e "$ROCM_PATH/$LIB/amdgcn/bitcode") {
$DEVICE_LIB_PATH = "$ROCM_PATH/$LIB/amdgcn/bitcode";
} else {
# This path is to support an older build of the device library
# TODO: To be removed in the future.
$DEVICE_LIB_PATH = "$ROCM_PATH/lib";
Expand Down Expand Up @@ -166,13 +168,13 @@ BEGIN
$HIP_CLANG_TARGET = chomp($HIP_CLANG_TARGET);

if (! defined $HIP_CLANG_INCLUDE_PATH) {
$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include");
$HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../$LIB/clang/$HIP_CLANG_VERSION/include");
}
if (! defined $HIP_INCLUDE_PATH) {
$HIP_INCLUDE_PATH = "$HIP_PATH/include";
}
if (! defined $HIP_LIB_PATH) {
$HIP_LIB_PATH = "$HIP_PATH/lib";
$HIP_LIB_PATH = "$HIP_PATH/$LIB";
}
if ($verbose & 0x2) {
print ("ROCM_PATH=$ROCM_PATH\n");
Expand All @@ -199,13 +201,11 @@ BEGIN
}

if (not $isWindows) {
$HSA_PATH=$ENV{'HSA_PATH'} // "$ROCM_PATH/hsa";
$HIPCXXFLAGS .= " -isystem $HSA_PATH/include";
$HIPCFLAGS .= " -isystem $HSA_PATH/include";
}

} elsif ($HIP_PLATFORM eq "nvidia") {
$CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda';
$HIP_INCLUDE_PATH = "$HIP_PATH/include";
if ($verbose & 0x2) {
print ("CUDA_PATH=$CUDA_PATH\n");
Expand Down Expand Up @@ -706,16 +706,16 @@ BEGIN

if (not $isWindows and not $compileOnly) {
if ($linkType eq 0) {
$toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
$toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/$LIB -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
} else {
$toolArgs = ${toolArgs} . " -Wl,--enable-new-dtags -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 ";
$toolArgs = ${toolArgs} . " -Wl,--enable-new-dtags -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/$LIB -lamdhip64 ";
}
# To support __fp16 and _Float16, explicitly link with compiler-rt
$HIP_CLANG_BUILTIN_LIB="$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a";
$HIP_CLANG_BUILTIN_LIB="$HIP_CLANG_PATH/../$LIB/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a";
if (-e $HIP_CLANG_BUILTIN_LIB) {
$toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET -lclang_rt.builtins "
$toolArgs .= " -L$HIP_CLANG_PATH/../$LIB/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET -lclang_rt.builtins "
} else {
$toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/linux -lclang_rt.builtins-x86_64 "
$toolArgs .= " -L$HIP_CLANG_PATH/../$LIB/clang/$HIP_CLANG_VERSION/lib/linux -lclang_rt.builtins-x86_64 "
}
}
}
Expand Down
21 changes: 19 additions & 2 deletions bin/hipvars.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,27 @@ if ($isWindows) {
# HIP_ROCCLR_HOME is used by Windows builds
$HIP_ROCCLR_HOME=$ENV{'HIP_ROCCLR_HOME'};

if ($isWindows) {
$LIB = "lib";
} else {
# Look for the AMD HIP library to determine the lib directory name
if (my @libs = glob("$HIP_PATH/lib*/libamdhip64*.so*")) {
# Multi-lib layout (Fedora and others: /usr/lib64)
$LIB = basename(dirname($libs[0]));
} elsif (@libs = glob("$HIP_PATH/lib/*/libamdhip64*.so*")) {
# Multi-arch layout (Debian: /usr/lib/x86_64-linux-gnu)
$LIB = "lib/" . basename(dirname($libs[0]));
} else {
# Set to 'lib' for backwards compatibility with cases that are not
# caught in the above checks
$LIB = "lib";
}
}

if (defined $HIP_ROCCLR_HOME) {
$HIP_INFO_PATH= "$HIP_ROCCLR_HOME/lib/.hipInfo";
$HIP_INFO_PATH= "$HIP_ROCCLR_HOME/$LIB/.hipInfo";
} else {
$HIP_INFO_PATH= "$HIP_PATH/lib/.hipInfo"; # use actual file
$HIP_INFO_PATH= "$HIP_PATH/$LIB/.hipInfo"; # use actual file
}
#---
#HIP_PLATFORM controls whether to use nvidia or amd platform:
Expand Down