Skip to content

Commit

Permalink
Update with rapids cmake new features (rapidsai#4175)
Browse files Browse the repository at this point in the history
This combines some general CMake style cleanup and brings new rapids-cmake features to cuml including:

- Usage of `rapids_cmake_write_version_file` to simplify cuml version header writing
- Usage of `rapids_cmake_install_lib_dir` to make sure we install raft correctly on non-debain based distro's ( lib64 ), while also handling conda installation requirements ( always lib no matter the distro )
- Usage of `rapids_cpm` pre-configured pacakges
- Removal of early termination before `rapids_cpm_find` since a better solution now exists ( rapidsai/rapids-cmake#49 )
- Updates the examples to use `find_package(cuml)` since that is best practice.

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#4175
  • Loading branch information
robertmaynard authored Aug 25, 2021
1 parent 980fccb commit 8d1ecb4
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 196 deletions.
29 changes: 14 additions & 15 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ rapids_cuda_init_architectures(CUML)
project(CUML VERSION 21.10.00 LANGUAGES CXX CUDA)

# Write the version header
include(cmake/modules/Version.cmake)
write_version()
rapids_cmake_write_version_file(include/cuml/version_config.hpp)

##############################################################################
# - build type ---------------------------------------------------------------
Expand Down Expand Up @@ -115,12 +114,12 @@ endif()
##############################################################################
# - compiler options ---------------------------------------------------------

if (NOT DISABLE_OPENMP OR NOT ${DISABLE_OPENMP})
if (NOT DISABLE_OPENMP)
find_package(OpenMP)
if(OpenMP_FOUND)
message(STATUS "CUML: OpenMP found in ${OPENMP_INCLUDE_DIRS}")
endif(OpenMP_FOUND)
endif(NOT DISABLE_OPENMP OR NOT ${DISABLE_OPENMP})
endif()
endif()

# * find CUDAToolkit package
# * determine GPU architectures
Expand All @@ -138,15 +137,15 @@ include(cmake/modules/ConfigureCUDA.cmake)
# Enabling libcuml enables building libcuml++
if(BUILD_CUML_C_LIBRARY)
set(BUILD_CUML_CPP_LIBRARY ON)
endif(BUILD_CUML_C_LIBRARY)
endif()

# Disabling libcuml++ disables building algorithm tests and examples
if(NOT BUILD_CUML_CPP_LIBRARY)
set(BUILD_CUML_C_LIBRARY OFF)
set(BUILD_CUML_TESTS OFF)
set(BUILD_CUML_MG_TESTS OFF)
set(BUILD_CUML_EXAMPLES OFF)
endif(NOT BUILD_CUML_CPP_LIBRARY)
endif()

# SingleGPU build disables cumlprims_mg and comms components
if(SINGLEGPU)
Expand All @@ -157,18 +156,18 @@ if(SINGLEGPU)
set(BUILD_CUML_MPI_COMMS OFF)
set(ENABLE_CUMLPRIMS_MG OFF)
set(WITH_UCX OFF)
endif(SINGLEGPU)
endif()

if(BUILD_CUML_MG_TESTS AND NOT SINGLEGPU)
message(STATUS "Detected BUILD_CUML_MG_TESTS set to ON. Enabling BUILD_CUML_MPI_COMMS")
set(BUILD_CUML_MPI_COMMS ON)
endif(BUILD_CUML_MG_TESTS AND NOT SINGLEGPU)
endif()

if(USE_CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ccache)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
set(CMAKE_CUDA_COMPILER_LAUNCHER ccache)
endif(USE_CCACHE)
endif()

##############################################################################
# - Requirements -------------------------------------------------------------
Expand Down Expand Up @@ -292,7 +291,7 @@ if(BUILD_CUML_CPP_LIBRARY)
src/solver/cd_mg.cu
src/tsvd/tsvd_mg.cu
)
endif(NOT SINGLEGPU)
endif()

add_library(cuml::${CUML_CPP_TARGET} ALIAS ${CUML_CPP_TARGET})

Expand Down Expand Up @@ -364,7 +363,7 @@ if(BUILD_CUML_CPP_LIBRARY)
# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(${CUML_CPP_TARGET} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")

endif(BUILD_CUML_CPP_LIBRARY)
endif()

#############################################################################
# - build libcuml C shared library -------------------------------------------
Expand Down Expand Up @@ -416,11 +415,11 @@ endif()

if(BUILD_CUML_EXAMPLES)
add_subdirectory(examples)
endif(BUILD_CUML_EXAMPLES)
endif()

# ###################################################################################################
# # - install targets -------------------------------------------------------------------------------

rapids_cmake_install_lib_dir( lib_dir )
include(CPack)

set(CUML_TARGETS ${CUML_CPP_TARGET})
Expand All @@ -433,7 +432,7 @@ endif()
install(TARGETS
${CUML_TARGETS}
DESTINATION
lib
${lib_dir}
EXPORT
cuml-exports)

Expand Down
4 changes: 2 additions & 2 deletions cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if(BUILD_CUML_BENCH)
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src_prims>
)
endif(BUILD_CUML_BENCH)
endif()

##############################################################################
# - build prims bench executable ----------------------------------------------
Expand Down Expand Up @@ -96,4 +96,4 @@ if(BUILD_CUML_PRIMS_BENCH)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src_prims>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
endif(BUILD_CUML_PRIMS_BENCH)
endif()
18 changes: 0 additions & 18 deletions cpp/cmake/modules/Version.cmake

This file was deleted.

8 changes: 1 addition & 7 deletions cpp/cmake/thirdparty/get_cumlprims_mg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ function(find_and_configure_cumlprims_mg)
return()
endif()

set(oneValueArgs VERSION)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_find_generate_module(cumlprims_mg
HEADER_NAMES cumlprims.hpp
LIBRARY_NAMES cumlprims
Expand All @@ -34,6 +30,4 @@ function(find_and_configure_cumlprims_mg)

endfunction()

set(CUML_MIN_VERSION_cumlprims_mg "${CUML_VERSION_MAJOR}.${CUML_VERSION_MINOR}.00")

find_and_configure_cumlprims_mg(VERSION CUML_MIN_VERSION_cumlprims_mg)
find_and_configure_cumlprims_mg()
4 changes: 0 additions & 4 deletions cpp/cmake/thirdparty/get_gbench.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

function(find_and_configure_gbench)

if(TARGET benchmark::benchmark)
return()
endif()

set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
Expand Down
26 changes: 4 additions & 22 deletions cpp/cmake/thirdparty/get_gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,11 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_gtest VERSION)
function(find_and_configure_gtest)

if(TARGET GTest::gtest)
return()
endif()

rapids_cpm_find(GTest ${VERSION}
GLOBAL_TARGETS gmock gmock_main gtest gtest_main GTest::gmock GTest::gtest GTest::gtest_main
CPM_ARGS
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-${VERSION}
GIT_SHALLOW TRUE
OPTIONS
"INSTALL_GTEST ON"
# googletest >= 1.10.0 provides a cmake config file -- use it if it exists
FIND_PACKAGE_ARGUMENTS "CONFIG"
)

if(NOT TARGET GTest::gtest)
add_library(GTest::gtest ALIAS gtest)
add_library(GTest::gtest_main ALIAS gtest_main)
endif()
include(${rapids-cmake-dir}/cpm/gtest.cmake)
rapids_cpm_gtest()

endfunction()

find_and_configure_gtest(1.10.0)
find_and_configure_gtest()
6 changes: 1 addition & 5 deletions cpp/cmake/thirdparty/get_nccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ function(find_and_configure_nccl)
return()
endif()

set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_find_generate_module(NCCL
HEADER_NAMES nccl.h
LIBRARY_NAMES nccl
Expand All @@ -35,7 +31,7 @@ function(find_and_configure_nccl)

endfunction()

find_and_configure_nccl(VERSION 2.8)
find_and_configure_nccl()



Expand Down
29 changes: 4 additions & 25 deletions cpp/cmake/thirdparty/get_rmm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,13 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_rmm VERSION)
function(find_and_configure_rmm)

if(TARGET rmm::rmm)
return()
endif()

if(${VERSION} MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
set(MAJOR_AND_MINOR "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}")
else()
set(MAJOR_AND_MINOR "${VERSION}")
endif()

rapids_cpm_find(rmm ${VERSION}
GLOBAL_TARGETS rmm::rmm
include(${rapids-cmake-dir}/cpm/rmm.cmake)
rapids_cpm_rmm(
BUILD_EXPORT_SET cuml-exports
INSTALL_EXPORT_SET cuml-exports
CPM_ARGS
GIT_REPOSITORY https://github.com/rapidsai/rmm.git
GIT_TAG branch-${MAJOR_AND_MINOR}
GIT_SHALLOW TRUE
OPTIONS "BUILD_TESTS OFF"
"BUILD_BENCHMARKS OFF"
"CUDA_STATIC_RUNTIME ${CUDA_STATIC_RUNTIME}"
"DISABLE_DEPRECATION_WARNING ${DISABLE_DEPRECATION_WARNING}"
)

endfunction()

set(CUML_MIN_VERSION_rmm "${CUML_VERSION_MAJOR}.${CUML_VERSION_MINOR}.00")

find_and_configure_rmm(${CUML_MIN_VERSION_rmm})
find_and_configure_rmm()
19 changes: 3 additions & 16 deletions cpp/cmake/thirdparty/get_spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,9 @@

function(find_and_configure_spdlog)

if(TARGET spdlog::spdlog)
return()
endif()

set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_cpm_find(spdlog ${PKG_VERSION}
CPM_ARGS
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG ${PKG_PINNED_TAG}
DOWNLOAD_ONLY YES
)
include(${rapids-cmake-dir}/cpm/spdlog.cmake)
rapids_cpm_spdlog()

endfunction()

find_and_configure_spdlog(VERSION 1.7.0
PINNED_TAG 1.7.0)
find_and_configure_spdlog()
17 changes: 8 additions & 9 deletions cpp/cmake/thirdparty/get_thrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
# limitations under the License.
#=============================================================================

function(find_and_configure_thrust VERSION)
function(find_and_configure_thrust)
include(${rapids-cmake-dir}/cpm/thrust.cmake)

rapids_cpm_find(Thrust ${VERSION}
CPM_ARGS
GIT_REPOSITORY https://github.com/thrust/thrust.git
GIT_TAG ${VERSION}
)

thrust_create_target(cuml::Thrust FROM_OPTIONS)
rapids_cpm_thrust(
NAMESPACE cuml
BUILD_EXPORT_SET cuml-exports
INSTALL_EXPORT_SET cuml-exports
)

endfunction()

find_and_configure_thrust(1.12.0)
find_and_configure_thrust()
6 changes: 1 addition & 5 deletions cpp/cmake/thirdparty/get_treelite.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@

function(find_and_configure_treelite)

if(TARGET treelite::treelite)
return()
endif()

set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_cpm_find(Treelite ${PKG_VERSION}
GLOBAL_TARGETS treelite
GLOBAL_TARGETS treelite::treelite treelite
CPM_ARGS
GIT_REPOSITORY https://github.com/dmlc/treelite.git
GIT_TAG ${PKG_PINNED_TAG}
Expand Down
3 changes: 0 additions & 3 deletions cpp/cmake/thirdparty/get_ucx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
#=============================================================================

function(find_and_configure_ucx)
set(oneValueArgs VERSION PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

rapids_find_generate_module(ucx
HEADER_NAMES ucp/api/ucp.h
Expand Down
21 changes: 0 additions & 21 deletions cpp/cmake/version_config.hpp.in

This file was deleted.

3 changes: 1 addition & 2 deletions cpp/examples/dbscan/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2019-2020, NVIDIA CORPORATION.
# Copyright (c) 2019-2021, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,5 +15,4 @@
#=============================================================================

add_executable(dbscan_example dbscan_example.cpp)
target_include_directories(dbscan_example PRIVATE ${CUML_INCLUDE_DIRECTORIES})
target_link_libraries(dbscan_example cuml++)
Loading

0 comments on commit 8d1ecb4

Please sign in to comment.