Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ variables:

before_script:
- $SUDO_CMD apt-get update -qq
- $SUDO_CMD apt-get install -y -qq libnuma-dev libunwind-dev git wget tar xz-utils bzip2 build-essential pkg-config ca-certificates
- $SUDO_CMD apt-get install -y -qq libidn11 libnuma-dev libunwind-dev git wget tar xz-utils bzip2 build-essential pkg-config ca-certificates
- hipconfig
# cmake
- mkdir -p $DEPS_DIR/cmake
Expand All @@ -37,7 +37,7 @@ build:rocm:
script:
- mkdir build
- cd build
- CXX=hipcc cmake -DBUILD_TEST=ON ../.
- CXX=hipcc cmake -DBUILD_TEST=ON -DCMAKE_CXX_FLAGS="-w" ../.
- make -j $(nproc)
- make package
artifacts:
Expand All @@ -46,7 +46,7 @@ build:rocm:
- build/test/test_*
- build/test/CTestTestfile.cmake
- build/testing/test_thrust_*
- build/testing/CTestTestfile.cmake
- build/testing/CTestTestfile.cmake
- build/gtest/
- build/CMakeCache.txt
- build/CTestTestfile.cmake
Expand Down
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE CACHE BOOL "Add paths to linker searc
# Verify that hcc compiler is used on ROCM platform
include(cmake/VerifyCompiler.cmake)

# Build options
# Disable -Werror
option(DISABLE_WERROR "Disable building with Werror" ON)
option(BUILD_TEST "Build tests" OFF)
option(DOWNLOAD_ROCPRIM "Download rocPRIM and do not search for rocPRIM package" OFF)

# Set CXX flags
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-function")

# Build options
option(BUILD_TEST "Build tests" OFF)
option(DOWNLOAD_ROCPRIM "Download rocPRIM and do not search for rocPRIM package" OFF)
if(DISABLE_WERROR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-function")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-function -Werror")
endif()

# Get dependencies
include(cmake/Dependencies.cmake)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ cd rocThrust; mkdir build; cd build

# Configure rocThrust, setup options for your system.
# Build options:
# BUILD_TEST - ON by default,
# DISABLE_WERROR - ON by default, This flag disable the -Werror compiler flag
# BUILD_TEST - OFF by default,
# DOWNLOAD_ROCPRIM - OFF by default and at ON the rocPRIM will be downloaded to build folder,
#
# ! IMPORTANT !
Expand Down
56 changes: 40 additions & 16 deletions cmake/Summary.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
# ########################################################################
# Copyright 2019 Advanced Micro Devices, Inc.
# ########################################################################
# MIT License
#
# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

function(print_configuration_summary)
message(STATUS "******** Summary ********")
message(STATUS "General:")
message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
message(STATUS " HIP ROOT : ${HIP_ROOT_DIR}")
message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS_STRIP)
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS_STRIP}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Install prefix : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "")
message(STATUS " BUILD_TEST : ${BUILD_TEST}")
function (print_configuration_summary)
message(STATUS "")
message(STATUS "******** Summary ********")
message(STATUS "General:")
message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
message(STATUS " HIP ROOT : ${HIP_ROOT_DIR}")
message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS_STRIP)
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS_STRIP}")
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
message(STATUS " Install prefix : ${CMAKE_INSTALL_PREFIX}")
if(HIP_COMPILER STREQUAL "hcc" OR HIP_COMPILER STREQUAL "clang")
message(STATUS " Device targets : ${AMDGPU_TARGETS}")
endif()
message(STATUS "")
message(STATUS " DISABLE_WERROR : ${DISABLE_WERROR}")
message(STATUS " DOWNLOAD_ROCPRIM : ${DOWNLOAD_ROCPRIM}")
message(STATUS " BUILD_TEST : ${BUILD_TEST}")
endfunction()
65 changes: 33 additions & 32 deletions cmake/VerifyCompiler.cmake
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
# ########################################################################
# Copyright 2019 Advanced Micro Devices, Inc.
# ########################################################################
# MIT License
#
# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# Find HIP package
find_package(HIP REQUIRED)
list(APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hip)
find_package(hip REQUIRED CONFIG PATHS /opt/rocm)

if(HIP_PLATFORM STREQUAL "hcc")
if(NOT (CMAKE_CXX_COMPILER MATCHES ".*/hcc$" OR CMAKE_CXX_COMPILER MATCHES ".*/hipcc$"))
message(FATAL_ERROR "On ROCm platform 'hcc' or 'clang' must be used as C++ compiler.")
else()
# Determine if CXX Compiler is hcc, hip-clang or other
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "--version" OUTPUT_VARIABLE CXX_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[A-Za-z]* ?clang version" TMP_CXX_VERSION ${CXX_OUTPUT})
string(REGEX MATCH "[A-Za-z]+" CXX_VERSION_STRING ${TMP_CXX_VERSION})
if(CXX_VERSION_STRING MATCHES "HCC")
set(HIP_COMPILER "hcc" CACHE STRING "HIP Compiler")
elseif(CXX_VERSION_STRING MATCHES "clang")
set(HIP_COMPILER "clang" CACHE STRING "HIP Compiler")
else()
message(FATAL_ERROR "CXX Compiler version ${CXX_VERSION_STRING} unsupported.")
if(HIP_COMPILER STREQUAL "nvcc")
message(FATAL_ERROR "rocThrust does not support the CUDA backend.")
elseif(HIP_COMPILER STREQUAL "hcc" OR HIP_COMPILER STREQUAL "clang")
if(NOT (CMAKE_CXX_COMPILER MATCHES ".*/hcc$" OR CMAKE_CXX_COMPILER MATCHES ".*/hipcc$"))
message(FATAL_ERROR "On ROCm platform 'hcc' or 'clang' must be used as C++ compiler.")
elseif(NOT CXX_VERSION_STRING MATCHES "clang")
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
endif()
message(STATUS "HIP Compiler: " ${HIP_COMPILER})

# Workaround until hcc & hip cmake modules fixes symlink logic in their config files.
# (Thanks to rocBLAS devs for finding workaround for this problem.)
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc /opt/rocm/hip)
# Ignore hcc warning: argument unused during compilation: '-isystem /opt/rocm/hip/include'
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-command-line-argument")
if(HIP_COMPILER STREQUAL "hcc")
list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hcc)
find_package(hcc REQUIRED CONFIG PATHS /opt/rocm)
else()
find_package(hcc QUIET CONFIG PATHS /opt/rocm)
endif()
find_package(hip REQUIRED CONFIG PATHS /opt/rocm)
endif()
else()
message(FATAL_ERROR "HIP_PLATFORM must be 'hcc' (AMD ROCm platform)")
message(FATAL_ERROR "HIP_COMPILER must be 'hcc' or 'clang' (AMD ROCm platform)")
endif()