Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rapids-cmake for builds #515

Merged
merged 11 commits into from
Apr 27, 2022
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ if hasArg clean; then
fi

if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then
CUSPATIAL_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES="
CUSPATIAL_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=NATIVE"
echo "Building for the architecture of the GPU in the system..."
else
CUSPATIAL_CMAKE_CUDA_ARCHITECTURES=""
CUSPATIAL_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=ALL"
echo "Building for *ALL* supported GPU architectures..."
fi

Expand Down
3 changes: 3 additions & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ sed_runner 's/'"CUSPATIAL VERSION .* LANGUAGES"'/'"CUSPATIAL VERSION ${NEXT_FULL
sed_runner 's/version = .*/version = '"'${NEXT_SHORT_TAG}'"'/g' docs/source/conf.py
sed_runner 's/release = .*/release = '"'${NEXT_FULL_TAG}'"'/g' docs/source/conf.py

# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake

# bump cudf
for FILE in conda/environments/*.yml; do
sed_runner "s/cudf=${CURRENT_SHORT_TAG}/cudf=${NEXT_SHORT_TAG}/g" ${FILE};
Expand Down
111 changes: 52 additions & 59 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
# limitations under the License.
#=============================================================================

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)

# If `CMAKE_CUDA_ARCHITECTURES` is not defined, build for all supported architectures. If
# `CMAKE_CUDA_ARCHITECTURES` is set to an empty string (""), build for only the current
# architecture. If `CMAKE_CUDA_ARCHITECTURES` is specified by the user, use user setting.

# This needs to be run before enabling the CUDA language due to the default initialization behavior
# of `CMAKE_CUDA_ARCHITECTURES`, https://gitlab.kitware.com/cmake/cmake/-/issues/21302
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR CMAKE_CUDA_ARCHITECTURES STREQUAL "ALL")
set(CUSPATIAL_BUILD_FOR_ALL_ARCHS TRUE)
elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "")
set(CUSPATIAL_BUILD_FOR_DETECTED_ARCHS TRUE)
endif()
cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)

include(../fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)

project(CUSPATIAL VERSION 22.06.00 LANGUAGES C CXX)
rapids_cuda_init_architectures(CUSPATIAL)

project(CUSPATIAL VERSION 22.06.00 LANGUAGES C CXX CUDA)

# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
Expand Down Expand Up @@ -58,7 +55,7 @@ message(STATUS "CUSPATIAL: Enable the -lineinfo option for nvcc (useful for cuda
message(STATUS "CUSPATIAL: Statically link the CUDA runtime: ${CUDA_STATIC_RUNTIME}")

# Set a default build type if none was specified
set(DEFAULT_BUILD_TYPE "Release")
rapids_cmake_build_type("Release")
set(CUSPATIAL_BUILD_TESTS ${BUILD_TESTS})
set(CUSPATIAL_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})

Expand All @@ -67,15 +64,6 @@ set(CUSPATIAL_CUDA_FLAGS "")
set(CUSPATIAL_CXX_DEFINITIONS "")
set(CUSPATIAL_CUDA_DEFINITIONS "")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

# Set RMM logging level
set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.")
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
Expand All @@ -84,21 +72,16 @@ message(STATUS "CUSPATIAL: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")
###################################################################################################
# - conda environment -----------------------------------------------------------------------------

if("$ENV{CONDA_BUILD}" STREQUAL "1")
set(CMAKE_PREFIX_PATH "$ENV{BUILD_PREFIX};$ENV{PREFIX};${CMAKE_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
message(VERBOSE "CUSPATIAL: Conda build detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
elseif(DEFINED ENV{CONDA_PREFIX})
set(CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX};${CMAKE_PREFIX_PATH}")
set(CONDA_INCLUDE_DIRS "$ENV{CONDA_PREFIX}/include")
set(CONDA_LINK_DIRS "$ENV{CONDA_PREFIX}/lib")
message(VERBOSE "CUSPATIAL: Conda environment detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
endif()
rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH)

###################################################################################################
# - compiler options ------------------------------------------------------------------------------

rapids_find_package(
CUDAToolkit REQUIRED
BUILD_EXPORT_SET cuspatial-exports
INSTALL_EXPORT_SET cuspatial-exports
)
# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
Expand All @@ -109,9 +92,13 @@ include(cmake/Modules/ConfigureCUDA.cmake)
# - dependencies ----------------------------------------------------------------------------------

# find gdal
find_package(GDAL REQUIRED)
rapids_find_package(
GDAL REQUIRED
BUILD_EXPORT_SET cuspatial-exports
INSTALL_EXPORT_SET cuspatial-exports
)
# add third party dependencies using CPM
include(cmake/thirdparty/CUSPATIAL_GetCPM.cmake)
rapids_cpm_init()
# find or add cuDF
include(cmake/thirdparty/CUSPATIAL_GetCUDF.cmake)

Expand Down Expand Up @@ -233,37 +220,43 @@ set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cuspatial)

install(TARGETS cuspatial
DESTINATION lib
EXPORT cuspatial-targets)
EXPORT cuspatial-exports)

install(DIRECTORY ${CUSPATIAL_SOURCE_DIR}/include/cuspatial
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

include(CMakePackageConfigHelpers)
set(doc_string
[=[
Provide targets for the cuSpatial library.

configure_package_config_file(cmake/cuspatial-config.cmake.in "${CUSPATIAL_BINARY_DIR}/cmake/cuspatial-config.cmake"
INSTALL_DESTINATION "${INSTALL_CONFIGDIR}")
cuSpatial is a GPU-accelerated library for spatial data management and analytics.

write_basic_package_version_file("${CUSPATIAL_BINARY_DIR}/cmake/cuspatial-config-version.cmake"
COMPATIBILITY SameMinorVersion)
Imported Targets
^^^^^^^^^^^^^^^^

install(FILES "${CUSPATIAL_BINARY_DIR}/cmake/cuspatial-config.cmake"
"${CUSPATIAL_BINARY_DIR}/cmake/cuspatial-config-version.cmake"
DESTINATION "${INSTALL_CONFIGDIR}")
If cuspatial is found, this module defines the following IMPORTED GLOBAL
targets:

install(EXPORT cuspatial-targets
FILE cuspatial-targets.cmake
NAMESPACE cuspatial::
DESTINATION "${INSTALL_CONFIGDIR}")
cuspatial::cuspatial - The main cuspatial library.
]=]
)

################################################################################################
# - build export -------------------------------------------------------------------------------
rapids_export(
INSTALL cuspatial
EXPORT_SET cuspatial-exports
GLOBAL_TARGETS cuspatial
NAMESPACE cuspatial::
DOCUMENTATION doc_string
)

configure_package_config_file(cmake/cuspatial-build-config.cmake.in ${CUSPATIAL_BINARY_DIR}/cuspatial-config.cmake
INSTALL_DESTINATION ${CUSPATIAL_BINARY_DIR})

write_basic_package_version_file(${CUSPATIAL_BINARY_DIR}/cuspatial-config-version.cmake
COMPATIBILITY SameMinorVersion)
################################################################################################
# - build export -------------------------------------------------------------------------------

export(EXPORT cuspatial-targets
FILE ${CUSPATIAL_BINARY_DIR}/cuspatial-targets.cmake
NAMESPACE cuspatial::)
rapids_export(
BUILD cuspatial
EXPORT_SET cuspatial-exports
GLOBAL_TARGETS cuspatial
NAMESPACE cuspatial::
DOCUMENTATION doc_string
)
13 changes: 0 additions & 13 deletions cpp/cmake/Modules/ConfigureCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@
# limitations under the License.
#=============================================================================

# Find the CUDAToolkit
find_package(CUDAToolkit REQUIRED)

# Auto-detect available GPU compute architectures
include(${CMAKE_CURRENT_LIST_DIR}/SetGPUArchs.cmake)
message(STATUS "CUSPATIAL: Building CUSPATIAL for GPU architectures: ${CMAKE_CUDA_ARCHITECTURES}")

# Must come after find_package(CUDAToolkit) because we symlink
# sccache as a compiler front-end for nvcc in gpuCI CPU builds.
# Must also come after we detect and potentially rewrite
# CMAKE_CUDA_ARCHITECTURES
enable_language(CUDA)

if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CUSPATIAL_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations)
if(CUSPATIAL_BUILD_TESTS OR CUSPATIAL_BUILD_BENCHMARKS)
Expand Down
70 changes: 0 additions & 70 deletions cpp/cmake/Modules/EvalGPUArchs.cmake

This file was deleted.

55 changes: 0 additions & 55 deletions cpp/cmake/Modules/SetGPUArchs.cmake

This file was deleted.

60 changes: 0 additions & 60 deletions cpp/cmake/cuspatial-build-config.cmake.in

This file was deleted.

Loading