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

Add cmake infrastructure for internal projection library #1132

Merged
merged 36 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cfd69ad
Add cmake infrastructure and placeholder files for projection library
harrism May 9, 2023
dcb23ef
Merge branch 'branch-23.06' into feature/projection/cmake
harrism May 9, 2023
7b2e9b9
Rename to cuproj
harrism May 10, 2023
f469cf0
Merge branch 'branch-23.06' into feature/projection/cmake
harrism May 10, 2023
68acf29
Delete cugeo dir
harrism May 11, 2023
c2784a9
Merge branch 'branch-23.08' into feature/projection/cmake
harrism May 31, 2023
d8d851d
Remove _ctk_static_suffix
harrism May 31, 2023
dade592
if TARGET conda_env update
harrism May 31, 2023
10b0590
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 1, 2023
88a3760
Update version to 23.08 and PUBLIC -> PRIVATE
harrism Jun 1, 2023
48ead2e
Move cuproj into cpp and build it when cuspatial builds.
harrism Jun 6, 2023
b889452
re-add cuml
harrism Jun 6, 2023
2073b1f
Add sqlite dependency
harrism Jun 6, 2023
d366ad5
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 6, 2023
d59cdc4
Add proj and sqlite dependencies to conda meta.yaml
harrism Jun 6, 2023
3eba34e
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 7, 2023
cd68e4e
Fix comment
harrism Jun 7, 2023
5243a5d
rename to get_cudf.cmake
harrism Jun 7, 2023
e27f7bb
Remove GNUInstallDirs
harrism Jun 7, 2023
a0ad375
Copyright
harrism Jun 7, 2023
e2a28ea
cuspatial-exports --> cuproj-exports
harrism Jun 7, 2023
5d395c4
PROJ namespace
harrism Jun 7, 2023
517e65b
Remove FIND_PACKAGE_ARGUMENTS
harrism Jun 7, 2023
5a00596
Get cudftestutil when BUILD_BENCHMARKS is enabled too.
harrism Jun 7, 2023
48c9ffc
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 7, 2023
1745d0b
PROJ case
harrism Jun 7, 2023
beee5a4
Remove rapids_export of PROJ
harrism Jun 7, 2023
24923f2
Make cuproj get_cudf.cmake match cuspatial's
harrism Jun 8, 2023
300e769
Remove `BUILD_INTERFACE` from `target_compile_definitions`.
harrism Jun 13, 2023
42e5103
Temporary: attempt debugging cmake find_package in CI
harrism Jun 13, 2023
8bbc369
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 13, 2023
3552d0c
Revert temporary cmake debugging
harrism Jun 13, 2023
d063ca9
Update cpp/CMakeLists.txt
harrism Jun 14, 2023
fcdb4bb
Update CUPROJ VERSION in update-version.sh
harrism Jun 14, 2023
2812e0d
Merge branch 'branch-23.08' into feature/projection/cmake
harrism Jun 21, 2023
07f9a2a
Remove CUDAToolkit package.
harrism Jun 22, 2023
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
1 change: 1 addition & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function sed_runner() {

# python/cpp update
sed_runner 's/'"CUSPATIAL VERSION .* LANGUAGES"'/'"CUSPATIAL VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/CMakeLists.txt
sed_runner 's/'"CUPROJ VERSION .* LANGUAGES"'/'"CUPROJ VERSION ${NEXT_FULL_TAG} LANGUAGES"'/g' cpp/cuproj/CMakeLists.txt
sed_runner 's/'"cuspatial_version .*)"'/'"cuspatial_version ${NEXT_FULL_TAG})"'/g' python/cuspatial/CMakeLists.txt

# RTD update
Expand Down
2 changes: 2 additions & 0 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies:
- numpydoc
- nvcc_linux-64=11.8
- pre-commit
- proj
- pydata-sphinx-theme
- pydeck
- pytest
Expand All @@ -41,5 +42,6 @@ dependencies:
- setuptools
- shapely
- sphinx<6
- sqlite
- sysroot_linux-64==2.17
name: all_cuda-118_arch-x86_64
4 changes: 4 additions & 0 deletions conda/recipes/libcuspatial/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ requirements:
- gtest {{ gtest_version }}
- libcudf ={{ minor_version }}
- librmm ={{ minor_version }}
- sqlite
- proj

outputs:
- name: libcuspatial
Expand All @@ -66,6 +68,8 @@ outputs:
- cudatoolkit {{ cuda_spec }}
- libcudf ={{ minor_version }}
- librmm ={{ minor_version }}
- sqlite
- proj
test:
commands:
- test -f $PREFIX/lib/libcuspatial.so
Expand Down
16 changes: 6 additions & 10 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH)

###################################################################################################
# - compiler options ------------------------------------------------------------------------------
set(_ctk_static_suffix "")
if(CUDA_STATIC_RUNTIME)
set(_ctk_static_suffix "_static")
# Control legacy FindCUDA.cmake behavior too
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
endif()

rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME})

Expand All @@ -110,7 +104,7 @@ include(cmake/Modules/ConfigureCUDA.cmake)
# add third party dependencies using CPM
rapids_cpm_init()
# find or add cuDF
include(cmake/thirdparty/CUSPATIAL_GetCUDF.cmake)
include(cmake/thirdparty/get_cudf.cmake)
# find or install GoogleTest
harrism marked this conversation as resolved.
Show resolved Hide resolved
if (CUSPATIAL_BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
Expand All @@ -119,6 +113,9 @@ endif()
###################################################################################################
# - library targets -------------------------------------------------------------------------------

# cuProj
add_subdirectory(cuproj)

add_library(cuspatial
src/bounding_boxes/linestring_bounding_boxes.cu
src/bounding_boxes/polygon_bounding_boxes.cu
Expand Down Expand Up @@ -222,9 +219,9 @@ endif()
if(CUSPATIAL_BUILD_BENCHMARKS)
# Find or install GoogleBench
CPMFindPackage(NAME benchmark
VERSION 1.5.2
VERSION 1.5.3
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.2
GIT_TAG v1.5.3
GIT_SHALLOW TRUE
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF")
Expand All @@ -243,7 +240,6 @@ endif()

rapids_cmake_install_lib_dir(lib_dir)
include(CPack)
include(GNUInstallDirs)

set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cuspatial)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function(find_and_configure_cudf)
set(global_targets cudf::cudf)
set(cudf_components "")

if(BUILD_TESTS)
if(BUILD_TESTS OR BUILD_BENCHMARKS)
list(APPEND global_targets cudf::cudftestutil)
set(cudf_components COMPONENTS testing)
endif()
Expand Down
270 changes: 270 additions & 0 deletions cpp/cuproj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
#=============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================

cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)

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

rapids_cuda_init_architectures(CUPROJ)

project(CUPROJ VERSION 23.08.00 LANGUAGES C CXX CUDA)
robertmaynard marked this conversation as resolved.
Show resolved Hide resolved

# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
# Setting this flag ensures `Threads::Threads` is the same value in first run and subsequent runs.
set(THREADS_PREFER_PTHREAD_FLAG ON)

# Must come after enable_language(CUDA)
# Use `-isystem <path>` instead of `-isystem=<path>`
# because the former works with clangd intellisense
set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA "-isystem ")

###################################################################################################
# - build options ---------------------------------------------------------------------------------

option(BUILD_SHARED_LIBS "Build cuproj shared libraries" ON)
option(USE_NVTX "Build with NVTX support" ON)
option(BUILD_TESTS "Configure CMake to build tests" OFF)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
option(PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF)
# Option to enable line info in CUDA device compilation to allow introspection when profiling / memchecking
option(CUDA_ENABLE_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF)
# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)

message(STATUS "CUPROJ: Build with NVTX support: ${USE_NVTX}")
message(STATUS "CUPROJ: Configure CMake to build tests: ${BUILD_TESTS}")
message(STATUS "CUPROJ: Configure CMake to build (google) benchmarks: ${BUILD_BENCHMARKS}")
message(STATUS "CUPROJ: Build with per-thread default stream: ${PER_THREAD_DEFAULT_STREAM}")
message(STATUS "CUPROJ: Disable warnings generated from deprecated declarations: ${DISABLE_DEPRECATION_WARNING}")
message(STATUS "CUPROJ: Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler: ${CUDA_ENABLE_LINEINFO}")
message(STATUS "CUPROJ: Statically link the CUDA toolkit runtime and libraries: ${CUDA_STATIC_RUNTIME}")

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

set(CUPROJ_CXX_FLAGS "")
set(CUPROJ_CUDA_FLAGS "")
set(CUPROJ_CXX_DEFINITIONS "")
set(CUPROJ_CUDA_DEFINITIONS "")

# 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")
message(STATUS "CUPROJ: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")

###################################################################################################
# - conda environment -----------------------------------------------------------------------------

rapids_cmake_support_conda_env(conda_env)

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

rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME})

# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
# * set other CUDA compilation flags
include(cmake/modules/ConfigureCUDA.cmake)

###################################################################################################
# - dependencies ----------------------------------------------------------------------------------

# add third party dependencies using CPM
rapids_cpm_init()
# find or add cuDF
include(cmake/thirdparty/get_cudf.cmake)
# find or install GoogleTest and Proj
if (CUPROJ_BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
include(cmake/thirdparty/get_proj.cmake)
endif()

###################################################################################################
# - library targets -------------------------------------------------------------------------------

add_library(cuproj
src/test.cu
)

set_target_properties(cuproj
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)

target_compile_options(cuproj
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_FLAGS}>"
)

target_compile_definitions(cuproj
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUPROJ_CXX_DEFINITIONS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUPROJ_CUDA_DEFINITIONS}>"
)

# Specify include paths for the current target and dependents
target_include_directories(cuproj
PUBLIC "$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/include>"
PRIVATE "$<BUILD_INTERFACE:${CUPROJ_SOURCE_DIR}/src>"
INTERFACE "$<INSTALL_INTERFACE:include>")

# Add Conda library and include paths if specified
if(TARGET conda_env)
target_link_libraries(cuproj PRIVATE "$<BUILD_INTERFACE:conda_env>")
endif()

# Per-thread default stream
if(PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(cuproj PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
harrism marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Disable NVTX if necessary
if(NOT USE_NVTX)
target_compile_definitions(cuproj PUBLIC NVTX_DISABLE)
harrism marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Define spdlog level
target_compile_definitions(cuproj PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}")
harrism marked this conversation as resolved.
Show resolved Hide resolved

# Specify the target module library dependencies
#target_link_libraries(cuproj PUBLIC cudf::cudf)

add_library(cuproj::cuproj ALIAS cuproj)

###################################################################################################
# - add tests -------------------------------------------------------------------------------------

if(CUPROJ_BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
add_subdirectory(tests)
endif()

###################################################################################################
# - add benchmarks --------------------------------------------------------------------------------

if(CUPROJ_BUILD_BENCHMARKS)
# Find or install GoogleBench
CPMFindPackage(NAME benchmark
VERSION 1.5.3
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.3
GIT_SHALLOW TRUE
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF")

# Find or install NVBench Temporarily force downloading of fmt because current versions of nvbench
# do not support the latest version of fmt, which is automatically pulled into our conda
# environments by mamba.
set(CPM_DOWNLOAD_fmt TRUE)
include(${rapids-cmake-dir}/cpm/nvbench.cmake)
rapids_cpm_nvbench()
add_subdirectory(benchmarks)
endif()

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

rapids_cmake_install_lib_dir(lib_dir)
include(CPack)

set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cuproj)

install(TARGETS cuproj
DESTINATION ${lib_dir}
EXPORT cuproj-exports)

install(DIRECTORY ${CUPROJ_SOURCE_DIR}/include/cuproj
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

set(doc_string
[=[
Provide targets for the cuproj library.

cuproj is a GPU-accelerated library for transformation of geospatial coordinates between coordinates
reference systems.

Imported Targets
^^^^^^^^^^^^^^^^

If cuproj is found, this module defines the following IMPORTED GLOBAL
targets:

cuproj::cuproj - The main cuproj library.
]=]
)

rapids_export(
INSTALL cuproj
EXPORT_SET cuproj-exports
GLOBAL_TARGETS cuproj
NAMESPACE cuproj::
DOCUMENTATION doc_string
)


################################################################################################
# - build export -------------------------------------------------------------------------------

rapids_export(
BUILD cuproj
EXPORT_SET cuproj-exports
GLOBAL_TARGETS cuproj
NAMESPACE cuproj::
DOCUMENTATION doc_string
)


# ##################################################################################################
# * build documentation ----------------------------------------------------------------------------

find_package(Doxygen)

if(DOXYGEN_FOUND)

# doc targets for cuproj
add_custom_command(
OUTPUT CUPROJ_DOXYGEN
WORKING_DIRECTORY ${CUPROJ_SOURCE_DIR}/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
VERBATIM
COMMENT "Custom command for building cuproj doxygen docs."
)

add_custom_target(
docs_cuproj
DEPENDS CUPROJ_DOXYGEN
COMMENT "Custom command for building cuproj doxygen docs."
)

endif()
Loading