Skip to content

Commit

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

* use clang not amdclang

* remove compiler from install script

* remove redundant toolchain argument

* Switch back to amdclang

* Update to correct flag behaviour

* Update CI script
  • Loading branch information
lawruble13 authored Mar 20, 2024
1 parent 508d397 commit 684c56c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 44 deletions.
3 changes: 1 addition & 2 deletions .jenkins/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def runCompileCommand(platform, project, jobName, boolean debug=false)
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 Down Expand Up @@ -74,4 +74,3 @@ def runPackageCommand(platform, project)
}

return this

13 changes: 5 additions & 8 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,8 @@ fi
# Configure rocPRIM, setup options for your system.
# See README.md under "Build and Install" for options and defaults.

compiler="hipcc"

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

benchmark="OFF"
if [[ "${build_benchmark}" == true ]]; then
Expand Down Expand Up @@ -188,18 +186,17 @@ if [[ "${build_codecoverage}" == true ]]; then
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} -DBUILD_BENCHMARK=${benchmark} \
-DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hip" \
-DBUILD_BENCHMARK=${benchmark} -DBUILD_TEST=${clients} \
-DCMAKE_MODULE_PATH="${rocm_path}/lib/cmake/hip ${rocm_path}/hip/cmake" \
"${static_libs}" \
../../. # or cmake-gui ../.
else
CXX=${rocm_path}/bin/${compiler} ${cmake_executable} ${cmake_common_options} -DBUILD_BENCHMARK=${benchmark} \
-DBUILD_TEST=${clients} -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_CODE_COVERAGE=${codecoverage} \
"${static_libs}" \
../../. # or cmake-gui ../.
${cmake_executable} ${cmake_common_options} -DBUILD_BENCHMARK=${benchmark} \
-DBUILD_TEST=${clients} -DCMAKE_BUILD_TYPE=${build_type} -DBUILD_CODE_COVERAGE=${codecoverage} ../../. # or cmake-gui ../.

fi

# Build
Expand Down
53 changes: 19 additions & 34 deletions toolchain-linux.cmake
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
#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}/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")

#set(CMAKE_CXX_LINKER "hipcc" )

# TODO remove, just to speed up slow cmake
# set(CMAKE_C_COMPILER_WORKS 1)
# set(CMAKE_CXX_COMPILER_WORKS 1)
#

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -IC:/hip/include -IC:/hip/lib/clang/12.0.0 -DWIN32 -D_CRT_SECURE_NO_WARNINGS")

# flags for clang direct use
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fms-extensions -fms-compatibility")
# -Wno-ignored-attributes to avoid warning: __declspec attribute 'dllexport' is not supported [-Wignored-attributes] which is used by msvc compiler
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fms-extensions -fms-compatibility -Wno-ignored-attributes")

# flags for clang direct use with hip
# -x hip causes linker error
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -x hip -IC:/hip/include/hip -D__HIP_PLATFORM_AMD__ -D__HIP_ROCclr__")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -IC:/hip/include/hip -D__HIP_PLATFORM_AMD__ -D__HIP_ROCclr__")


# set(GTEST_DIR "C:/rocm/Utils/GTestMSVC")
# set(GTEST_INCLUDE_DIR "${GTEST_DIR}/include")
# set(GTEST_LIBRARY "${GTEST_DIR}/lib/Release/gtest.lib")
# set(GTEST_MAIN_LIBRARY "${GTEST_DIR}/lib/Release/gtest_main.lib")
# set(GTEST_LIBRARIES "${GTEST_DIR}/lib/Release/gtest.lib;${GTEST_DIR}/lib/Release/gtest_main.lib")
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 684c56c

Please sign in to comment.