From 1296f54a8349a89187dee9795c03c821d07a6703 Mon Sep 17 00:00:00 2001 From: Lauren Wrubleski Date: Fri, 2 Feb 2024 13:05:23 -0700 Subject: [PATCH 1/2] Switch from using hipcc to clang on non-CUDA --- .jenkins/common.groovy | 9 ++++----- install | 7 +++---- toolchain-linux.cmake | 24 +++++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index 049cfc3..a10014a 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -22,11 +22,11 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s String cmake = platform.jenkinsLabel.contains('centos') ? 'cmake3' : 'cmake' //Set CI node's gfx arch as target if PR, otherwise use default targets of the library String amdgpuTargets = env.BRANCH_NAME.startsWith('PR-') ? '-DAMDGPU_TARGETS=\$gfx_arch' : '' - String compiler = '/opt/rocm/bin/hipcc' + String toolchainOrCompiler="--toolchain=toolchain-linux.cmake" String useCUDA = '' if (platform.jenkinsLabel.contains('cuda')) { - compiler = 'g++' + compiler = '-DCMAKE_CXX_COMPILER=g++' useCUDA = '-DBUILD_WITH_LIB=CUDA' amdgpuTargets = '' } @@ -39,7 +39,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s # gfxTargetParser reads gfxarch and adds target features such as xnack ${auxiliary.gfxTargetParser()} echo "ROCM_PATH = \${ROCM_PATH}" - ${cmake} -DCMAKE_CXX_COMPILER=${compiler} ${useCUDA} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. + ${cmake} --toolchain=toolchain-linux.cmake ${useCUDA} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. make -j\$(nproc) """ @@ -49,7 +49,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s def runTestCommand (platform, project) { String sudo = auxiliary.sudo(platform.jenkinsLabel) - + def extraArgs = platform.jenkinsLabel.contains('cuda') ? "-E test_hiprand_linkage" : "" def testCommand = "ctest ${extraArgs} --output-on-failure" @@ -72,4 +72,3 @@ def runPackageCommand(platform, project) } return this - diff --git a/install b/install index 405977c..77bd86b 100755 --- a/install +++ b/install @@ -125,6 +125,7 @@ else mkdir -p debug; cd debug fi +cmake_common_options="--toolchain=toolchain-linux.cmake" # build type if [[ "${build_release}" == true ]]; then cmake_common_options="${cmake_common_options} -DCMAKE_BUILD_TYPE=Release" @@ -142,8 +143,6 @@ fi # before 'cmake' or setting cmake option 'CMAKE_CXX_COMPILER' to path to the HIPCC compiler. # -compiler="hipcc" - cmake_executable="cmake" if($build_clients); then @@ -159,7 +158,7 @@ cmake_common_options="${cmake_common_options} -DDEPENDENCIES_FORCE_DOWNLOAD=ON" fi if [[ "${build_relocatable}" == true ]]; then - CXX=${rocm_path}/bin/$compiler ${cmake_executable} -DCMAKE_INSTALL_PREFIX="${rocm_path}" \ + ${cmake_executable} -DCMAKE_INSTALL_PREFIX="${rocm_path}" \ -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ${cmake_common_options} \ -DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hip" \ -DCMAKE_SHARED_LINKER_FLAGS="${rocm_rpath}" \ @@ -167,7 +166,7 @@ if [[ "${build_relocatable}" == true ]]; then -DCMAKE_MODULE_PATH="${rocm_path}/hip/cmake" \ ../../. # or cmake-gui ../. else - CXX=${rocm_path}/bin/$compiler ${cmake_executable} ${clients} ${cmake_common_options} ../../. # or cmake-gui ../. + ${cmake_executable} ${clients} ${cmake_common_options} ../../. # or cmake-gui ../. fi check_exit_code "$?" diff --git a/toolchain-linux.cmake b/toolchain-linux.cmake index 6a3cb78..1974879 100644 --- a/toolchain-linux.cmake +++ b/toolchain-linux.cmake @@ -1,17 +1,19 @@ -#set(CMAKE_MAKE_PROGRAM "nmake.exe") -#set(CMAKE_GENERATOR "Ninja") -# Ninja doesn't support platform -#set(CMAKE_GENERATOR_PLATFORM x64) if (DEFINED ENV{ROCM_PATH}) - set(rocm_bin "$ENV{ROCM_PATH}/hip/bin") + set(rocm_bin "$ENV{ROCM_PATH}/bin") else() - set(rocm_bin "/opt/rocm/hip/bin") + set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to the ROCm installation.") + set(rocm_bin "/opt/rocm/bin") endif() +if (NOT DEFINED ENV{CXX}) + set(CMAKE_CXX_COMPILER "${rocm_bin}/amdclang++") +else() + set(CMAKE_CXX_COMPILER "$ENV{CXX}") +endif() -# set(CMAKE_CXX_COMPILER "hipcc") -# set(CMAKE_C_COMPILER "hipcc") -set(CMAKE_CXX_COMPILER "${rocm_bin}/hipcc") -set(CMAKE_C_COMPILER "${rocm_bin}/hipcc") - +if (NOT DEFINED ENV{CC}) + set(CMAKE_C_COMPILER "${rocm_bin}/amdclang") +else() + set(CMAKE_C_COMPILER "$ENV{CC}") +endif() From f7e693fcd639b354a32c8aa89293d28770247529 Mon Sep 17 00:00:00 2001 From: Lauren Wrubleski Date: Wed, 13 Mar 2024 11:49:56 -0600 Subject: [PATCH 2/2] Update flag behaviour --- .jenkins/common.groovy | 4 ++-- toolchain-linux.cmake | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.jenkins/common.groovy b/.jenkins/common.groovy index a10014a..3093e3a 100644 --- a/.jenkins/common.groovy +++ b/.jenkins/common.groovy @@ -26,7 +26,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s String useCUDA = '' if (platform.jenkinsLabel.contains('cuda')) { - compiler = '-DCMAKE_CXX_COMPILER=g++' + toolchainOrCompiler = '-DCMAKE_CXX_COMPILER=g++' useCUDA = '-DBUILD_WITH_LIB=CUDA' amdgpuTargets = '' } @@ -39,7 +39,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s # gfxTargetParser reads gfxarch and adds target features such as xnack ${auxiliary.gfxTargetParser()} echo "ROCM_PATH = \${ROCM_PATH}" - ${cmake} --toolchain=toolchain-linux.cmake ${useCUDA} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. + ${cmake} ${toolchainOrCompiler} ${useCUDA} ${buildTypeArg} ${buildStatic} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../.. make -j\$(nproc) """ diff --git a/toolchain-linux.cmake b/toolchain-linux.cmake index 1974879..6a8b6d0 100644 --- a/toolchain-linux.cmake +++ b/toolchain-linux.cmake @@ -7,13 +7,21 @@ else() endif() if (NOT DEFINED ENV{CXX}) - set(CMAKE_CXX_COMPILER "${rocm_bin}/amdclang++") + set(CMAKE_CXX_COMPILER "${rocm_bin}/amdclang++" CACHE PATH "Path to the C++ compiler") + set(CMAKE_CXX_FLAGS_INIT "-mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false") + if (DEFINED ENV{HIPCC_COMPILE_FLAGS_APPEND}) + set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} $ENV{HIPCC_COMPILE_FLAGS_APPEND}") + endif() else() - set(CMAKE_CXX_COMPILER "$ENV{CXX}") + set(CMAKE_CXX_COMPILER "$ENV{CXX}" CACHE PATH "Path to the C++ compiler") endif() if (NOT DEFINED ENV{CC}) - set(CMAKE_C_COMPILER "${rocm_bin}/amdclang") + set(CMAKE_C_COMPILER "${rocm_bin}/amdclang" CACHE PATH "Path to the C compiler") + set(CMAKE_C_FLAGS_INIT "-mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false") + if (DEFINED ENV{HIPCC_COMPILE_FLAGS_APPEND}) + set(CMAKE_C_FLAGS_INIT "${CMAKE_C_FLAGS_INIT} $ENV{HIPCC_COMPILE_FLAGS_APPEND}") + endif() else() - set(CMAKE_C_COMPILER "$ENV{CC}") + set(CMAKE_C_COMPILER "$ENV{CC}" CACHE PATH "Path to the C compiler") endif()