Skip to content

Commit

Permalink
Switch from using hipcc to using Clang compiler (#374)
Browse files Browse the repository at this point in the history
* Change default from hipcc to clang

* Use clang instead of amdclang

* Update install script

* Update CI script

* Switch back to amdclang

* Update flag behaviour
  • Loading branch information
lawruble13 authored Mar 20, 2024
1 parent dbfb8f9 commit 6cb531b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .jenkins/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false, boolean s
cd ${project.paths.project_build_prefix}
mkdir -p build/${buildTypeDir} && cd build/${buildTypeDir}
${auxiliary.gfxTargetParser()}
${cmake} -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
${cmake} --toolchain=toolchain-linux.cmake ${buildTypeArg} ${amdgpuTargets} -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON ../..
make -j\$(nproc)
"""

Expand All @@ -33,13 +33,13 @@ def runTestCommand (platform, project)
def testCommand = "ctest --output-on-failure"
def hmmTestCommand = ''
def excludeRegex = 'reduce_by_key.hip'

if (platform.jenkinsLabel.contains('gfx11'))
{
excludeRegex = /(reduce_by_key.hip|partition.hip|sort.hip|sort_by_key.hip|stable_sort_by_key.hip|stable_sort.hip|async_copy.hip|async_reduce.hip|async_scan.hip|async_sort.hip|async_transform.hip)/
}
testCommandExclude = "--exclude-regex \"${excludeRegex}\""

if (platform.jenkinsLabel.contains('gfx90a'))
{
hmmTestCommand = ""
Expand Down Expand Up @@ -72,4 +72,3 @@ def runPackageCommand(platform, project)
}

return this

9 changes: 3 additions & 6 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,8 @@ fi
# Configure rocThrust, setup options for your system.
# See README.md under "Build And Install" for options and defaults.

# Set compiler
compiler="hipcc"

cmake_executable="cmake"
cmake_common_options=""
cmake_common_options="--toolchain=toolchain-linux.cmake"

if [[ "${build_clients}" == true ]]; then
build_test="-DBUILD_TEST=ON"
Expand All @@ -146,14 +143,14 @@ else
fi

if [[ "${build_relocatable}" == true ]]; then
CXX=$rocm_path/bin/${compiler} ${cmake_executable} ${cmake_common_options} \
${cmake_executable} ${cmake_common_options} \
-DCMAKE_INSTALL_PREFIX=${rocm_path} \
-DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hip" \
-DCMAKE_MODULE_PATH="${rocm_path}/lib/cmake/hip ${rocm_path}/hip/cmake" \
-DROCPRIM_ROOT=${rocm_path}/rocprim ${build_test}\
../../. # or cmake-gui ../.
else
CXX=$rocm_path/bin/${compiler} ${cmake_executable} ${build_test} ${cmake_common_options} \
${cmake_executable} ${build_test} ${cmake_common_options} \
-DCMAKE_BUILD_TYPE=${build_type} ../../. # or cmake-gui ../.
fi
check_exit_code "$?"
Expand Down
23 changes: 19 additions & 4 deletions toolchain-linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@
if (DEFINED ENV{ROCM_PATH})
set(rocm_bin "$ENV{ROCM_PATH}/bin")
else()
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++" 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}" CACHE PATH "Path to the C++ compiler")
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" 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}" CACHE PATH "Path to the C compiler")
endif()

0 comments on commit 6cb531b

Please sign in to comment.