Merge branch 'amd-master-next' into amd-npi-next

Change-Id: Icd651e93f0c28eb2859f4997377379d0698ce84e
Этот коммит содержится в:
Vlad Sytchenko committed 2020-04-29 18:54:58 -04:00
Коммит d041d30e65
272 files changed
+6952 -24321

No files matched your search

+103 -26
Просмотреть файл
@@ -85,6 +85,7 @@ $HIP_LIB_PATH=$ENV{'HIP_LIB_PATH'};
$HIP_CLANG_PATH=$ENV{'HIP_CLANG_PATH'};
$DEVICE_LIB_PATH=$ENV{'DEVICE_LIB_PATH'};
$HIP_CLANG_HCC_COMPAT_MODE=$ENV{'HIP_CLANG_HCC_COMPAT_MODE'}; # HCC compatibility mode
$HIP_COMPILE_CXX_AS_HIP=$ENV{'HIP_COMPILE_CXX_AS_HIP'} // "1";
if (defined $HIP_VDI_HOME) {
$HIP_INFO_PATH= "$HIP_VDI_HOME/lib/.hipInfo";
@@ -134,6 +135,7 @@ if (defined $HIP_RUNTIME and $HIP_RUNTIME eq "VDI" and !defined $HIP_VDI_HOME) {
$HIP_VDI_HOME = $HIP_PATH; # use HIP_PATH
}
$HIPCXXFLAGS .= "-D__HIP_VDI__";
$HIPCFLAGS .= "-D__HIP_VDI__";
}
if (defined $HIP_VDI_HOME) {
@@ -207,12 +209,10 @@ if ($HIP_PLATFORM eq "clang") {
} else {
$HIPCXXFLAGS .= " -std=c++11";
}
$HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH";
$HIPCXXFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH/..";
$HIPCFLAGS .= " -isystem $HIP_CLANG_INCLUDE_PATH/..";
$HIPLDFLAGS .= " -L$HIP_LIB_PATH";
if (not $isWindows) {
$HIPLDFLAGS .= " -Wl,--rpath-link=$HIP_LIB_PATH";
$HIPLDFLAGS .= " -lhip_hcc";
} else {
if ($isWindows) {
$HIPLDFLAGS .= " -lamdhip64";
}
if ($HIP_CLANG_HCC_COMPAT_MODE) {
@@ -222,8 +222,10 @@ if ($HIP_PLATFORM eq "clang") {
$HSA_PATH=$ENV{'HSA_PATH'} // "$ROCM_PATH/hsa";
$HIPCXXFLAGS .= " -isystem $HSA_PATH/include";
if (!($HIP_RUNTIME eq "HCC")) {
$HIPCXXFLAGS .= " -D__HIP_VDI__ -fhip-new-launch-api";
$HIPCFLAGS .= " -isystem $HSA_PATH/include";
if ($HIP_RUNTIME ne "HCC" ) {
$HIPCXXFLAGS .= " -D__HIP_VDI__";
$HIPCFLAGS .= " -D__HIP_VDI__";
}
} elsif ($HIP_PLATFORM eq "hcc") {
@@ -282,8 +284,11 @@ if ($HIP_PLATFORM eq "clang") {
}
$HIPCXXFLAGS .= " -isystem $HIP_PATH/include/hip/hcc_detail/cuda";
$HIPCFLAGS .= " -isystem $HIP_PATH/include/hip/hcc_detail/cuda";
$HIPCXXFLAGS .= " -isystem $HSA_PATH/include";
$HIPCFLAGS .= " -isystem $HSA_PATH/include";
$HIPCXXFLAGS .= " -Wno-deprecated-register";
$HIPCFLAGS .= " -Wno-deprecated-register";
$HIPLDFLAGS .= " -L$HSA_PATH/lib -L$ROCM_PATH/lib -lhsa-runtime64 -lhc_am ";
# $HIPLDFLAGS .= " -L$HCC_HOME/compiler/lib -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMMC -lLLVMCore -lLLVMSupport ";
@@ -321,6 +326,7 @@ if ($HIP_PLATFORM eq "clang") {
$HIPCC="$CUDA_PATH/bin/nvcc";
$HIPCXXFLAGS .= " -Wno-deprecated-gpu-targets ";
$HIPCXXFLAGS .= " -isystem $CUDA_PATH/include";
$HIPCFLAGS .= " -isystem $CUDA_PATH/include";
$HIPLDFLAGS = " -Wno-deprecated-gpu-targets -lcuda -lcudart -L$CUDA_PATH/lib64";
} else {
@@ -330,19 +336,30 @@ if ($HIP_PLATFORM eq "clang") {
# Add paths to common HIP includes:
$HIPCXXFLAGS .= " -isystem $HIP_INCLUDE_PATH" ;
$HIPCFLAGS .= " -isystem $HIP_INCLUDE_PATH" ;
my $compileOnly = 0;
my $needCXXFLAGS = 0; # need to add CXX flags to compile step
my $needCFLAGS = 0; # need to add C flags to compile step
my $needLDFLAGS = 1; # need to add LDFLAGS to compile step.
my $hasC = 0; # options contain a c-style file (NVCC must force recognition as GPU file)
my $hasC = 0; # options contain a c-style file
my $hasCXX = 0; # options contain a cpp-style file (NVCC must force recognition as GPU file)
my $hasCU = 0; # options contain a cu-style file (HCC must force recognition as GPU file)
my $hasHIP = 0; # options contain a hip-style file (HIP-Clang must pass offloading options)
my $needHipHcc = ($HIP_PLATFORM eq 'hcc'); # set if we need to link hip_hcc.o from src tree. (some builds, ie cmake, provide their own)
my $printHipVersion = 0; # print HIP version
my $printCXXFlags = 0; # print HIPCXXFLAGS
my $printLDFlags = 0; # print HIPLDFLAGS
my $runCmd = 1;
my $buildDeps = 0;
my $linkType = 1;
my $setLinkType = 0;
my $coFormatv3 = 1;
if(defined $HIP_COMPILER and $HIP_COMPILER eq "hcc") {
$coFormatv3 = 0;
}
my $funcSupp = 0; # enable function support
my $rdc = 0; # whether -fgpu-rdc is on
my @options = ();
my @inputs = ();
@@ -392,6 +409,7 @@ my $optArg = ""; # -O args
my $targetOpt = '--amdgpu-target=';
my $targetsStr = "";
my $skipOutputFile = 0; # file followed by -o should not contibute in picking compiler flags
my $prevArg = ""; # previous argument
foreach $arg (@ARGV)
{
@@ -400,12 +418,12 @@ foreach $arg (@ARGV)
my $swallowArg = 0;
if ($arg eq '-c' or $arg eq '--genco') {
$compileOnly = 1;
$needCXXFLAGS = 1;
$needLDFLAGS = 0;
}
if ($skipOutputFile) {
$toolArgs .= " $arg";
$prevArg = $arg;
$skipOutputFile = 0;
next;
}
@@ -457,17 +475,27 @@ foreach $arg (@ARGV)
$printHipVersion = 1;
$runCmd = 0;
}
if($trimarg eq '--cxxflags') {
$printCXXFlags = 1;
$runCmd = 0;
}
if($trimarg eq '--ldflags') {
$printLDFlags = 1;
$runCmd = 0;
}
if($trimarg eq '-M') {
$compileOnly = 1;
$buildDeps = 1;
}
if($trimarg eq '-use_fast_math') {
$HIPCXXFLAGS .= " -DHIP_FAST_MATH ";
$HIPCFLAGS .= " -DHIP_FAST_MATH ";
}
if(($trimarg eq '-use-staticlib') and ($setLinkType eq 0))
{
$linkType = 0;
$setLinkType = 1;
$swallowArg = 1;
}
if(($trimarg eq '-use-sharedlib') and ($setLinkType eq 0))
{
@@ -590,8 +618,15 @@ foreach $arg (@ARGV)
$toolArgs = substr $toolArgs, 0, -8;
chomp $toolArgs;
}
} elsif ($arg eq 'hip' and $prevArg eq '-x') {
$hasHIP = 1;
} elsif ($arg =~ m/^-/) {
# options start with -
if ($arg eq '-fgpu-rdc') {
$rdc = 1;
} elsif ($arg eq '-fno-gpu-rdc') {
$rdc = 0;
}
# Process HIPCC options here:
if ($arg =~ m/^--hipcc/) {
@@ -599,31 +634,45 @@ foreach $arg (@ARGV)
#if $arg eq "--hipcc_profile") { # Example argument here, hipcc
#
#}
if ($arg eq "--hipcc-func-supp") {
$funcSupp = 1;
} elsif ($arg eq "--hipcc-no-func-supp") {
$funcSupp = 0;
}
} else {
push (@options, $arg);
}
#print "O: <$arg>\n";
} else {
} elsif ($prevArg ne '-o') {
# input files and libraries
if (($arg =~ /\.cpp$/) or ($arg =~ /\.cxx$/) or ($arg =~ /\.c$/) or ($arg =~ /\.cc$/) ) {
if ($arg =~ /\.c$/) {
$hasC = 1;
$needCFLAGS = 1;
$toolArgs .= " -x c"
}
elsif (($arg =~ /\.cpp$/) or ($arg =~ /\.cxx$/) or ($arg =~ /\.cc$/) ) {
$needCXXFLAGS = 1;
if ($HIP_PLATFORM eq 'clang') {
$toolArgs .= " -x hip"
if ($HIP_COMPILE_CXX_AS_HIP eq '0' or $HIP_COMPILER ne "clang") {
$hasCXX = 1;
} else {
$hasHIP = 1;
$toolArgs .= " -x hip";
}
}
if (($arg =~ /\.cu$/) or ($arg =~ /\.cuh$/) or ($arg =~ /\.hip$/)) {
$hasCU = 1;
elsif ((($arg =~ /\.cu$/ or $arg =~ /\.cuh$/) and $HIP_COMPILE_CXX_AS_HIP ne '0') or ($arg =~ /\.hip$/)) {
$needCXXFLAGS = 1;
if ($HIP_PLATFORM eq 'clang') {
$toolArgs .= " -x hip"
if ($HIP_COMPILER eq "clang") {
$hasHIP = 1;
$toolArgs .= " -x hip";
} else {
$hasCU = 1;
}
}
push (@inputs, $arg);
#print "I: <$arg>\n";
}
$toolArgs .= " $arg" unless $swallowArg;
$prevArg = $arg;
}
if($HIP_PLATFORM eq "hcc" or $HIP_PLATFORM eq "clang"){
@@ -657,9 +706,9 @@ if($HIP_PLATFORM eq "hcc" or $HIP_PLATFORM eq "clang"){
my $archMacro = ' -D__HIP_ARCH_' . uc($val) . '__=1 ';
# Add the arch option and macro to the compiler options.
$GPU_ARCH_ARG = $GPU_ARCH_OPT . $val;
$HIPLDFLAGS .= $GPU_ARCH_ARG;
$HIPLDARCHFLAGS .= $GPU_ARCH_ARG;
$HIPCXXFLAGS .= $archMacro;
if ($HIP_PLATFORM eq 'clang') {
if ($HIP_PLATFORM eq 'clang' and $hasHIP) {
$HIPCXXFLAGS .= $GPU_ARCH_ARG;
}
@@ -685,7 +734,7 @@ if ($coFormatv3 and $HIP_PLATFORM eq 'hcc') {
$HIPCXXFLAGS .= " -mcode-object-v3";
}
if ($hasC and $HIP_PLATFORM eq 'nvcc') {
if ($hasCXX and $HIP_PLATFORM eq 'nvcc') {
$HIPCXXFLAGS .= " -x cu";
}
if ($hasCU and $HIP_PLATFORM eq 'hcc') {
@@ -694,15 +743,17 @@ if ($hasCU and $HIP_PLATFORM eq 'hcc') {
if ($buildDeps and $HIP_PLATFORM eq 'nvcc') {
$HIPCXXFLAGS .= " -M -D__CUDACC__";
$HIPCFLAGS .= " -M -D__CUDACC__";
}
if ($buildDeps and $HIP_PLATFORM eq 'clang') {
$HIPCXXFLAGS .= " --cuda-host-only";
}
# Add --hip-link only if there are no source files.
if (!$needCXXFLAGS and $HIP_PLATFORM eq 'clang') {
# Add --hip-link only if it is compile only and -fgpu-rdc is on.
if ($rdc and !$compileOnly and $HIP_PLATFORM eq 'clang') {
$HIPLDFLAGS .= " --hip-link";
$HIPLDFLAGS .= $HIPLDARCHFLAGS;
}
if ($setStdLib eq 0 and $HIP_PLATFORM eq 'hcc')
@@ -727,35 +778,55 @@ if ($HIP_PLATFORM eq "clang") {
# Set default optimization level to -O3 for hip-clang.
if ($optArg eq "") {
$HIPCXXFLAGS .= " -O3";
$HIPCFLAGS .= " -O3";
$HIPLDFLAGS .= " -O3";
}
# Do not pass -mllvm on Windows since there is a clang bug causing duplicate -mllvm options in clang -cc1 on Windows.
# ToDo : remove restriction for Windows after clang bug is fixed.
if ($optArg ne "-O0" and not $isWindows) {
if (!$funcSupp and $optArg ne "-O0" and not $isWindows and $hasHIP) {
$HIPCXXFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false";
if ($needLDFLAGS and not $needCXXFLAGS) {
$HIPLDFLAGS .= " -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false";
}
}
$HIP_DEVLIB_FLAGS = " --hip-device-lib-path=$DEVICE_LIB_PATH";
$HIPCXXFLAGS .= " $HIP_DEVLIB_FLAGS";
if ($hasHIP) {
$HIPCXXFLAGS .= " $HIP_DEVLIB_FLAGS";
if ($HIP_RUNTIME ne "HCC") {
$HIPCXXFLAGS .= " -fhip-new-launch-api";
}
}
if (not $isWindows) {
$HIPLDFLAGS .= " -lgcc_s -lgcc -lpthread -lm";
}
}
if (not $isWindows and not $compileOnly) {
if ($linkType eq 0) {
$toolArgs .= " -L$HIP_LIB_PATH -lamdhip64_static -L$ROCM_PATH/lib -lhsa-runtime64 -ldl ";
} else {
$toolArgs .= " -Wl,--enable-new-dtags -Wl,--rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lhip_hcc ";
}
}
}
if ($HIPCC_COMPILE_FLAGS_APPEND) {
$HIPCXXFLAGS .= " $HIPCC_COMPILE_FLAGS_APPEND";
$HIPCFLAGS .= " $HIPCC_COMPILE_FLAGS_APPEND";
}
if ($HIPCC_LINK_FLAGS_APPEND) {
$HIPLDFLAGS .= " $HIPCC_LINK_FLAGS_APPEND";
}
my $CMD="$HIPCC";
if ($needCFLAGS) {
$CMD .= " $HIPCFLAGS";
}
if ($needCXXFLAGS) {
$CMD .= " $HIPCXXFLAGS";
}
if ($needLDFLAGS and not $compileOnly) {
$CMD .= " $HIPLDFLAGS";
}
@@ -771,6 +842,12 @@ if ($printHipVersion) {
}
print $HIP_VERSION, "\n";
}
if ($printCXXFlags) {
print $HIPCXXFLAGS;
}
if ($printLDFlags) {
print $HIPLDFLAGS;
}
if ($runCmd) {
if ($HIP_PLATFORM eq "hcc" and exists($hipConfig{'HCC_VERSION'}) and $HCC_VERSION ne $hipConfig{'HCC_VERSION'}) {
print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") ;