Skip to content

Commit

Permalink
Merge pull request #106 from ROCmSoftwarePlatform/develop_stream_2020…
Browse files Browse the repository at this point in the history
…0821

- Explicitly add AMDGPU_TARGETS
- Add nvcc to compiler exceptions for building googlebenchmark and googletest
- Update readme
- Update CI
  • Loading branch information
saadrahim authored Aug 27, 2020
2 parents 50c169b + 74f5c75 commit 440357f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ variables:
# Local build options
LOCAL_CXXFLAGS: ""
LOCAL_CMAKE_OPTIONS: ""
ROCM_LATEST_PATH: "/opt/rocm-3.5.0/"
ROCM_LATEST_PATH: "/opt/rocm-3.7.0/"

# hipCUB with rocPRIM backend
.rocm:
Expand Down Expand Up @@ -103,6 +103,7 @@ build:rocm:
-D CMAKE_BUILD_TYPE=Release
-D BUILD_TEST=ON
-D BUILD_EXAMPLE=ON
-D AMDGPU_TARGETS="gfx803;gfx900;gfx906"
-B build
../.
- cmake
Expand Down Expand Up @@ -341,6 +342,7 @@ build:nvcc:
- cmake
-G Ninja
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_CXX_COMPILER=nvcc
-D BUILD_TEST=ON
-D BUILD_EXAMPLE=ON
-B build
Expand Down Expand Up @@ -375,8 +377,8 @@ build:nvcc-benchmark:
- cmake
-G Ninja
-D CMAKE_BUILD_TYPE=Release
-D CMAKE_CXX_COMPILER=nvcc
-D BUILD_BENCHMARK=ON
-D CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-8
-B build
../.
- cmake
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Optional:
* [Google Benchmark](https://github.com/google/benchmark)
* Required only for benchmarks. Building benchmarks is off by default.
* It will be automatically downloaded and built by cmake script.
* At nvcc + gcc the google benchmarks require gcc8 or higher version

## Build And Install

Expand All @@ -54,8 +53,8 @@ cd hipCUB; mkdir build; cd build
[CXX=nvcc] cmake -DBUILD_TEST=ON ../. # or cmake-gui ../.
# or
cmake -DBUILD_TEST=ON ../. # or cmake-gui ../.
# To configure to build benchmarks, you should set the C compiler at nvcc build case
cmake -DBUILD_BENCHMARK=ON -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-8
# or to build benchmarks
cmake -DBUILD_BENCHMARK=ON ../.

# Build
make -j4
Expand Down
8 changes: 6 additions & 2 deletions cmake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,17 @@ endif()
if(BUILD_TEST)
# Google Test (https://github.com/google/googletest)
message(STATUS "Downloading and building GTest.")
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$|.*/nvcc$")
# hip-clang cannot compile googletest for some reason
set(COMPILER_OVERRIDE "-DCMAKE_CXX_COMPILER=g++")
endif()
set(GTEST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/gtest CACHE PATH "")
download_project(
PROJ googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.8.1
INSTALL_DIR ${GTEST_ROOT}
CMAKE_ARGS -DBUILD_GTEST=ON -DINSTALL_GTEST=ON -Dgtest_force_shared_crt=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
CMAKE_ARGS -DBUILD_GTEST=ON -DINSTALL_GTEST=ON -Dgtest_force_shared_crt=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> ${COMPILER_OVERRIDE}
LOG_DOWNLOAD TRUE
LOG_CONFIGURE TRUE
LOG_BUILD TRUE
Expand All @@ -114,7 +118,7 @@ endif()
if(BUILD_BENCHMARK)
# Google Benchmark (https://github.com/google/benchmark.git)
message(STATUS "Downloading and building Google Benchmark.")
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$")
if(CMAKE_CXX_COMPILER MATCHES ".*/hipcc$|.*/nvcc$")
# hip-clang cannot compile googlebenchmark for some reason
set(COMPILER_OVERRIDE "-DCMAKE_CXX_COMPILER=g++")
endif()
Expand Down
8 changes: 4 additions & 4 deletions cmake/VerifyCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ if(CMAKE_CXX_COMPILER MATCHES ".*/nvcc$" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL
find_package(hip QUIET CONFIG PATHS /opt/rocm)
if(NOT hip_FOUND)
find_package(HIP REQUIRED)
if((HIP_COMPILER STREQUAL "hcc") AND (HIP_PLATFORM STREQUAL "nvcc"))
# TODO: The HIP package on NVIDIA platform is incorrect at few versions
set(HIP_COMPILER "nvcc" CACHE STRING "HIP Compiler" FORCE)
endif()
endif()
if((HIP_COMPILER STREQUAL "hcc") AND (HIP_PLATFORM STREQUAL "nvcc"))
# TODO: The HIP package on NVIDIA platform is incorrect at few versions
set(HIP_COMPILER "nvcc" CACHE STRING "HIP Compiler" FORCE)
endif()
else()
find_package(hip REQUIRED CONFIG PATHS /opt/rocm)
Expand Down
21 changes: 15 additions & 6 deletions hipcub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,22 @@ install(
)

include(ROCMExportTargetsHeaderOnly)

# Export targets
rocm_export_targets_header_only(
TARGETS hip::hipcub
PREFIX hipcub
DEPENDS PACKAGE rocprim
NAMESPACE hip::
)
if(HIP_COMPILER STREQUAL "hcc" OR HIP_COMPILER STREQUAL "clang")
rocm_export_targets_header_only(
TARGETS hip::hipcub
PREFIX hipcub
DEPENDS PACKAGE rocprim
NAMESPACE hip::
)
else()
rocm_export_targets_header_only(
TARGETS hip::hipcub
PREFIX hipcub
NAMESPACE hip::
)
endif()

# Create symlinks
rocm_install_symlink_subdir(hipcub)

0 comments on commit 440357f

Please sign in to comment.