From 0f62034e00a8daccf2c95d40cfbb306784f5db8d Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 9 Apr 2019 15:01:50 -0400 Subject: [PATCH 1/2] hip-clang: add include path for hsa headers [ROCm/hip commit: c0e0ea9a1229cd4305e33f5eb2f8b02ea68c0f8b] --- projects/hip/bin/hipcc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index 22bf17f2f5..a7e2c28a45 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -204,6 +204,12 @@ if ($HIP_PLATFORM eq "clang") { ## Allow __fp16 as function parameter and return type. $HIPCXXFLAGS .= " -Xclang -fallow-half-arguments-and-returns -D__HIP_HCC_COMPAT_MODE__=1"; } + + if ($HIP_RUNTIME eq "HCC" ) { + $HSA_PATH=$ENV{'HSA_PATH'} // "/opt/rocm/hsa"; + $HIPCXXFLAGS .= " -isystem $HSA_PATH/include"; + } + } elsif ($HIP_PLATFORM eq "hcc") { $HIP_INCLUDE_PATH = "$HIP_PATH/include"; if (! defined $HIP_LIB_PATH) { From cc4acbdd086f56985283b78534ba1b55d82112a2 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Tue, 9 Apr 2019 22:31:13 -0400 Subject: [PATCH 2/2] hip-clang: fix hipcc options Use -O3 for default optimization level. Fix --hip-device-lib-path for warnings about unused option. [ROCm/hip commit: a31036ab746ac33cf248fd1e56d1e7e2c5b30d20] --- projects/hip/bin/hipcc | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/projects/hip/bin/hipcc b/projects/hip/bin/hipcc index a7e2c28a45..6f020662de 100755 --- a/projects/hip/bin/hipcc +++ b/projects/hip/bin/hipcc @@ -188,12 +188,8 @@ if ($HIP_PLATFORM eq "clang") { print ("DEVICE_LIB_PATH=$DEVICE_LIB_PATH\n"); } - - # By default, hip-clang assumes -fno-gpu-rdc, therefore device lib path - # is required. - $HIP_DEVLIB_FLAGS = " --hip-device-lib-path=$DEVICE_LIB_PATH"; - $HIPCXXFLAGS .= " $HIP_DEVLIB_FLAGS -std=c++11 -isystem $HIP_CLANG_INCLUDE_PATH"; - $HIPLDFLAGS .= " $HIP_DEVLIB_FLAGS -L$HIP_LIB_PATH"; + $HIPCXXFLAGS .= " -std=c++11 -isystem $HIP_CLANG_INCLUDE_PATH"; + $HIPLDFLAGS .= " -L$HIP_LIB_PATH"; if (not $isWindows) { $HIPLDFLAGS .= " -Wl,--rpath=$HIP_LIB_PATH"; $HIPLDFLAGS .= " -lhip_hcc"; @@ -373,6 +369,8 @@ if($HIP_PLATFORM eq "nvcc"){ } my $toolArgs = ""; # arguments to pass to the hcc or nvcc tool +my $optArg = ""; # -O args +my $rdc = 0; foreach $arg (@ARGV) { @@ -464,6 +462,18 @@ foreach $arg (@ARGV) $linkType = 1; $setLinkType = 1; } + if($arg =~ m/^-O/) + { + $optArg = $arg; + } + if($arg =~ /-fgpu-rdc/) + { + $rdc = 1; + } + if($arg =~ /-fno-gpu-rdc/) + { + $rdc = 0; + } ## process linker response file for hip-clang ## extract object files from static library and pass them directly to @@ -788,6 +798,17 @@ if ($needHipHcc) { # pass-through CPP mode. if ($HIP_PLATFORM eq "clang") { + # Set default optimization level to -O3 for hip-clang. + if ($optArg eq "") { + $HIPCXXFLAGS .= " -O3"; + $HIPLDFLAGS .= " -O3"; + } + $HIP_DEVLIB_FLAGS = " --hip-device-lib-path=$DEVICE_LIB_PATH"; + if ($rdc eq 0) { + $HIPCXXFLAGS .= " $HIP_DEVLIB_FLAGS"; + } else { + $HIPLDFLAGS .= " $HIP_DEVLIB_FLAGS"; + } if ($isWindows) { $HIPCXXFLAGS .= " -std=c++14 -fms-extensions -fms-compatibility"; } else {