From 388432384fe03318199ff90fd3c7d26d13efc88f Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Thu, 24 Nov 2022 09:33:05 +0530 Subject: [PATCH] SWDEV-345870 - Correct HIP path for new directory layout and removed the usage of HSA_PATH in hipcc (#3065) With file reorganization, HIP installed in /opt/rocm-ver Use the install path rather than using backward compatible path. HSA_PATH is not at all required in hipcc and removed the same Change-Id: Ia461cb4da2c0e0967703033f5c2c79b67732f5b5 --- bin/hipcc.pl | 10 ---------- bin/hipvars.pm | 7 +++---- hip-lang-config.cmake.in | 15 ++++++--------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/bin/hipcc.pl b/bin/hipcc.pl index 48ed8e1871..71ec5f042a 100755 --- a/bin/hipcc.pl +++ b/bin/hipcc.pl @@ -41,8 +41,6 @@ use Cwd 'abs_path'; # Other environment variable controls: # HIP_PATH : Path to HIP directory, default is one dir level above location of this script. # CUDA_PATH : Path to CUDA SDK (default /usr/local/cuda). Used on NVIDIA platforms only. -# HSA_PATH : Path to HSA dir (defaults to ../../hsa relative to abs_path -# of this script). Used on AMD platforms only. # HIP_ROCCLR_HOME : Path to HIP/ROCclr directory. Used on AMD platforms only. # HIP_CLANG_PATH : Path to HIP-Clang (default to ../../llvm/bin relative to this # script's abs_path). Used on AMD platforms only. @@ -122,7 +120,6 @@ $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; if ($HIP_PLATFORM eq "amd") { @@ -210,13 +207,6 @@ if ($HIP_PLATFORM eq "amd") { ## Allow __fp16 as function parameter and return type. $HIPCXXFLAGS .= " -Xclang -fallow-half-arguments-and-returns -D__HIP_HCC_COMPAT_MODE__=1"; } - - 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"; diff --git a/bin/hipvars.pm b/bin/hipvars.pm index 57ad73b834..bea4ec71ce 100644 --- a/bin/hipvars.pm +++ b/bin/hipvars.pm @@ -74,15 +74,14 @@ $isWindows = ($^O eq 'MSWin32' or $^O eq 'msys'); # ROCM_PATH is defined relative to HIP_PATH else it is hardcoded to /opt/rocm. # $HIP_PATH=$ENV{'HIP_PATH'} // dirname(Cwd::abs_path("$0/../")); # use parent directory of hipcc -if (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { - $ROCM_PATH=$ENV{'ROCM_PATH'} // dirname("$HIP_PATH"); # use parent directory of HIP_PATH ,FILE_REORG -}elsif (-e "$HIP_PATH/bin/rocm_agent_enumerator") { +if (-e "$HIP_PATH/bin/rocm_agent_enumerator") { $ROCM_PATH=$ENV{'ROCM_PATH'} // "$HIP_PATH"; # use HIP_PATH +}elsif (-e "$HIP_PATH/../bin/rocm_agent_enumerator") { # case for backward compatibility + $ROCM_PATH=$ENV{'ROCM_PATH'} // dirname("$HIP_PATH"); # use parent directory of HIP_PATH } else { $ROCM_PATH=$ENV{'ROCM_PATH'} // "/opt/rocm"; } $CUDA_PATH=$ENV{'CUDA_PATH'} // '/usr/local/cuda'; -$HSA_PATH=$ENV{'HSA_PATH'} // "$ROCM_PATH/hsa"; # Windows has a different structure, all binaries are inside hip/bin if ($isWindows) { diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in index 9250a68a07..f31fad1604 100644 --- a/hip-lang-config.cmake.in +++ b/hip-lang-config.cmake.in @@ -65,17 +65,15 @@ find_dependency(amd_comgr) include( "${CMAKE_CURRENT_LIST_DIR}/hip-lang-targets.cmake" ) -# From hip-lang config directory, do three level up -get_filename_component(_DIR "${CMAKE_CURRENT_LIST_DIR}" REALPATH) -get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH) +# Find the hip-lang config file path with symlinks resolved +# RealPath: /opt/rocm-ver/lib/cmake/hip-lang/hip-lang-config.cmake +# Go 4 level up to get IMPORT PREFIX +get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" REALPATH) +get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../../" ABSOLUTE) - -#need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY -file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include") -file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include") +file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/llvm/lib/clang/*/include") find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS} - ${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG} NO_DEFAULT_PATH) get_filename_component(HIP_CLANG_INCLUDE_PATH "${HIP_CLANG_INCLUDE_PATH}" DIRECTORY) @@ -87,7 +85,6 @@ endif() #if HSA is not under ROCm then provide CMAKE_PREFIX_PATH= find_path(HSA_HEADER hsa/hsa.h PATHS - "${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY "${_IMPORT_PREFIX}/include" "${ROCM_PATH}/include" )