diff --git a/build.sh b/build.sh index 11948c64412..c9333a3e2af 100755 --- a/build.sh +++ b/build.sh @@ -165,10 +165,10 @@ fi if buildAll || hasArg libcudf; then if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then - CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=" + CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=NATIVE" echo "Building for the architecture of the GPU in the system..." else - CUDF_CMAKE_CUDA_ARCHITECTURES="" + CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=ALL" echo "Building for *ALL* supported GPU architectures..." fi diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index d9a493f57a0..18af85c98e0 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -14,19 +14,7 @@ # 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(CUDF_BUILD_FOR_ALL_ARCHS TRUE) -elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "") - set(CUDF_BUILD_FOR_DETECTED_ARCHS TRUE) -endif() +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.10/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) @@ -38,8 +26,9 @@ include(rapids-cuda) include(rapids-export) include(rapids-find) +rapids_cuda_init_architectures(CUDF) -project(CUDF VERSION 21.10.00 LANGUAGES C CXX) +project(CUDF VERSION 21.10.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. @@ -79,7 +68,7 @@ message(VERBOSE "CUDF: Enable the -lineinfo option for nvcc (useful for cuda-mem message(VERBOSE "CUDF: 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(CUDF_BUILD_TESTS ${BUILD_TESTS}) set(CUDF_BUILD_BENCHMARKS ${BUILD_BENCHMARKS}) @@ -88,13 +77,6 @@ set(CUDF_CUDA_FLAGS "") set(CUDF_CXX_DEFINITIONS "") set(CUDF_CUDA_DEFINITIONS "") -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(VERBOSE "CUDF: 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(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - # 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") @@ -106,54 +88,47 @@ endif() ################################################################################################### # - 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 "CUDF: 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 "CUDF: 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 cudf-exports + INSTALL_EXPORT_SET cudf-exports) +include(cmake/Modules/ConfigureCUDA.cmake) # set other CUDA compilation flags -# * find CUDAToolkit package -# * determine GPU architectures -# * enable the CMake CUDA language -# * set other CUDA compilation flags -include(cmake/Modules/ConfigureCUDA.cmake) ################################################################################################### # - dependencies ---------------------------------------------------------------------------------- # find zlib -find_package(ZLIB REQUIRED) +rapids_find_package(ZLIB REQUIRED + BUILD_EXPORT_SET cudf-exports + INSTALL_EXPORT_SET cudf-exports) # find Threads (needed by cudftestutil) -find_package(Threads REQUIRED) +rapids_find_package(Threads REQUIRED + BUILD_EXPORT_SET cudf-exports + INSTALL_EXPORT_SET cudf-exports) + # add third party dependencies using CPM -include(cmake/thirdparty/CUDF_GetCPM.cmake) +rapids_cpm_init() # find jitify -include(cmake/thirdparty/CUDF_GetJitify.cmake) +include(cmake/thirdparty/get_jitify.cmake) # find thrust/cub -include(cmake/thirdparty/CUDF_GetThrust.cmake) +include(cmake/thirdparty/get_thrust.cmake) # find rmm -include(cmake/thirdparty/CUDF_GetRMM.cmake) +include(cmake/thirdparty/get_rmm.cmake) # find arrow -include(cmake/thirdparty/CUDF_GetArrow.cmake) +include(cmake/thirdparty/get_arrow.cmake) # find dlpack -include(cmake/thirdparty/CUDF_GetDLPack.cmake) +include(cmake/thirdparty/get_dlpack.cmake) # find libcu++ -include(cmake/thirdparty/CUDF_GetLibcudacxx.cmake) +include(cmake/thirdparty/get_libcudacxx.cmake) # find cuCollections # Should come after including thrust and libcudacxx -include(cmake/thirdparty/CUDF_GetcuCollections.cmake) +include(cmake/thirdparty/get_cucollections.cmake) # find or install GoogleTest -include(cmake/thirdparty/CUDF_GetGTest.cmake) +include(cmake/thirdparty/get_gtest.cmake) # preprocess jitify-able kernels include(cmake/Modules/JitifyPreprocessKernels.cmake) # find cuFile @@ -487,14 +462,6 @@ target_compile_options(cudf "$<$:${CUDF_CUDA_FLAGS}>" ) -target_compile_definitions(cudf - PUBLIC "$<$:${CUDF_CXX_DEFINITIONS}>" - "$:${CUDF_CUDA_DEFINITIONS}>>" -) - -# Disable Jitify log printing. See https://github.com/NVIDIA/jitify/issues/79 -target_compile_definitions(cudf PRIVATE "JITIFY_PRINT_LOG=0") - # Specify include paths for the current target and dependents target_include_directories(cudf PUBLIC "$" @@ -507,15 +474,13 @@ target_include_directories(cudf "$" "$") -# Add Conda library paths if specified -if(CONDA_LINK_DIRS) - target_link_directories(cudf PUBLIC "$") -endif() +target_compile_definitions(cudf + PUBLIC "$<$:${CUDF_CXX_DEFINITIONS}>" + "$:${CUDF_CUDA_DEFINITIONS}>>" +) -# Add Conda include paths if specified -if(CONDA_INCLUDE_DIRS) - target_include_directories(cudf PUBLIC "$") -endif() +# Disable Jitify log printing. See https://github.com/NVIDIA/jitify/issues/79 +target_compile_definitions(cudf PRIVATE "JITIFY_PRINT_LOG=0") # Instruct jitify to use the kernel JIT cache if(JITIFY_USE_CACHE) @@ -546,6 +511,16 @@ target_link_libraries(cudf rmm::rmm PRIVATE cuco::cuco) +# Add Conda library, and include paths if specified +if(TARGET conda_env) + target_link_libraries(cudf PRIVATE conda_env ) +endif() + +# Add cuFile interface if available +if(TARGET cuFile::cuFile_interface) + target_link_libraries(cudf PRIVATE cuFile::cuFile_interface) +endif() + if(CUDA_STATIC_RUNTIME) # Tell CMake what CUDA language runtime to use set_target_properties(cudf PROPERTIES CUDA_RUNTIME_LIBRARY Static) @@ -566,11 +541,6 @@ if(NOT TARGET CUDA::cuda_driver) endif() target_link_libraries(cudf PUBLIC CUDA::cuda_driver) -# Add cuFile interface if available -if(TARGET cuFile::cuFile_interface) - target_link_libraries(cudf PRIVATE cuFile::cuFile_interface) -endif() - file(WRITE "${CUDF_BINARY_DIR}/fatbin.ld" [=[ SECTIONS @@ -579,7 +549,7 @@ SECTIONS .nv_fatbin : { *(.nv_fatbin) } } ]=]) -target_link_options(cudf PRIVATE "${CUDF_BINARY_DIR}/fatbin.ld") +target_link_options(cudf PRIVATE "$") add_library(cudf::cudf ALIAS cudf) @@ -596,14 +566,24 @@ add_library(cudftestutil STATIC tests/utilities/table_utilities.cu tests/strings/utilities.cu) +set_target_properties(cudftestutil + 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(cudftestutil PUBLIC "$<$:${CUDF_CXX_FLAGS}>" "$:${CUDF_CUDA_FLAGS}>>" ) -target_compile_features(cudftestutil - PUBLIC cxx_std_17 $) - target_link_libraries(cudftestutil PUBLIC GTest::gmock GTest::gtest @@ -614,10 +594,6 @@ target_include_directories(cudftestutil PUBLIC "$" "$") -install(TARGETS cudftestutil - DESTINATION lib - EXPORT cudf-testing-targets) - add_library(cudf::cudftestutil ALIAS cudftestutil) ################################################################################################### @@ -634,32 +610,31 @@ endif() if(CUDF_BUILD_BENCHMARKS) # Find or install GoogleBench - CPMFindPackage(NAME benchmark - VERSION 1.5.2 + rapids_cpm_find(benchmark 1.5.2 GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.5.2 GIT_SHALLOW TRUE OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_INSTALL OFF") + # Find or install NVBench - include(cmake/thirdparty/CUDF_GetNVBench.cmake) + include(${rapids-cmake}/cpm/nvbench.cmake) + rapids_cpm_nvbench() add_subdirectory(benchmarks) endif() ################################################################################################### # - install targets ------------------------------------------------------------------------------- - +rapids_cmake_install_lib_dir(lib_dir) include(CPack) - include(GNUInstallDirs) -set(INSTALL_CONFIGDIR lib/cmake/cudf) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cudf) # install target for cudf_base and the proxy libcudf.so install(TARGETS cudf - DESTINATION lib - EXPORT cudf-targets) + DESTINATION ${lib_dir} + EXPORT cudf-exports) install(DIRECTORY ${CUDF_SOURCE_DIR}/include/cudf @@ -671,54 +646,115 @@ install(DIRECTORY ${CUDF_GENERATED_INCLUDE_DIR}/include/libcudacxx DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libcudf) -include(CMakePackageConfigHelpers) +install(TARGETS cudftestutil + DESTINATION ${lib_dir} + EXPORT cudf-testing-exports) -configure_package_config_file(cmake/cudf-config.cmake.in "${CUDF_BINARY_DIR}/cmake/cudf-config.cmake" - INSTALL_DESTINATION "${INSTALL_CONFIGDIR}") +install(EXPORT cudf-testing-exports + FILE cudf-testing-targets.cmake + NAMESPACE cudf:: + DESTINATION "${lib_dir}/cmake/cudf") -write_basic_package_version_file("${CUDF_BINARY_DIR}/cmake/cudf-config-version.cmake" - COMPATIBILITY SameMinorVersion) -install(FILES "${CUDF_BINARY_DIR}/cmake/cudf-config.cmake" - "${CUDF_BINARY_DIR}/cmake/cudf-config-version.cmake" - "${CUDF_SOURCE_DIR}/cmake/install/FindThrust.cmake" - DESTINATION "${INSTALL_CONFIGDIR}") +include("${rapids-cmake-dir}/export/write_dependencies.cmake") +rapids_export_write_dependencies(INSTALL cudf-testing-exports + "${PROJECT_BINARY_DIR}/rapids-cmake/cudf/export/cudf-testing-dependencies.cmake") -install(EXPORT cudf-targets - FILE cudf-targets.cmake - NAMESPACE cudf:: - DESTINATION "${INSTALL_CONFIGDIR}") +set(doc_string + [=[ +#[=======================================================================[ -install(EXPORT cudf-testing-targets - FILE cudf-testing-targets.cmake - NAMESPACE cudf:: - DESTINATION "${INSTALL_CONFIGDIR}") +Provide targets for the cudf library. + +Built based on the Apache Arrow columnar memory format, cuDF is a GPU DataFrame +library for loading, joining, aggregating, filtering, and otherwise +manipulating data. + +cuDF provides a pandas-like API that will be familiar to data engineers & +data scientists, so they can use it to easily accelerate their workflows +without going into the details of CUDA programming. + + +Imported Targets +^^^^^^^^^^^^^^^^ + +If cudf is found, this module defines the following IMPORTED GLOBAL +targets: + + cudf::cudf - The main cudf library. + +This module offers an optional testing component which defines the +following IMPORTED GLOBAL targets: + + cudf::cudftestutil - The main cudf testing library + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project:: + + CUDF_FOUND + CUDF_VERSION + CUDF_VERSION_MAJOR + CUDF_VERSION_MINOR + CUDF_VERSION_PATCH + +#]=======================================================================] + ]=]) + + +set(install_code_string + [=[ +set(ArrowCUDA_DIR "${Arrow_DIR}") +find_dependency(ArrowCUDA) +if(testing IN_LIST cudf_FIND_COMPONENTS) + enable_language(CUDA) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-dependencies.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-dependencies.cmake") + endif() + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") + endif() +endif() + +if(NOT TARGET cudf::Thrust) + thrust_create_target(cudf::Thrust FROM_OPTIONS) +endif() +]=]) + +rapids_export(INSTALL cudf + EXPORT_SET cudf-exports + GLOBAL_TARGETS cudf + NAMESPACE cudf:: + FINAL_CODE_BLOCK install_code_string) ################################################################################################ # - build export ------------------------------------------------------------------------------- -configure_package_config_file(cmake/cudf-build-config.cmake.in ${CUDF_BINARY_DIR}/cudf-config.cmake - INSTALL_DESTINATION ${CUDF_BINARY_DIR}) - -write_basic_package_version_file(${CUDF_BINARY_DIR}/cudf-config-version.cmake - COMPATIBILITY SameMinorVersion) - -if(TARGET gtest) - get_target_property(gtest_is_imported gtest IMPORTED) - if(NOT gtest_is_imported) - export(TARGETS gtest gmock gtest_main gmock_main - FILE ${CUDF_BINARY_DIR}/cudf-gtesting-targets.cmake - NAMESPACE GTest::) - endif() +set(build_code_string + [=[ +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-dependencies.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-dependencies.cmake") +endif() +if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/cudf-testing-targets.cmake") endif() -export(EXPORT cudf-targets - FILE ${CUDF_BINARY_DIR}/cudf-targets.cmake - NAMESPACE cudf::) +if(NOT TARGET cudf::Thrust) + thrust_create_target(cudf::Thrust FROM_OPTIONS) +endif() +]=]) -export(EXPORT cudf-testing-targets - FILE ${CUDF_BINARY_DIR}/cudf-testing-targets.cmake - NAMESPACE cudf::) +rapids_export(BUILD cudf + EXPORT_SET cudf-exports + GLOBAL_TARGETS cudf + NAMESPACE cudf:: + FINAL_CODE_BLOCK code_string) +export(EXPORT cudf-testing-exports + FILE ${CUDF_BINARY_DIR}/cudf-testing.cmake + NAMESPACE cudf::) +rapids_export_write_dependencies(BUILD cudf-testing-exports + "${CUDF_BINARY_DIR}/cudf-testing-dependencies.cmake") ################################################################################################### # - make documentation ---------------------------------------------------------------------------- diff --git a/cpp/cmake/Modules/ConfigureCUDA.cmake b/cpp/cmake/Modules/ConfigureCUDA.cmake index 716163b5530..a537b5e3beb 100644 --- a/cpp/cmake/Modules/ConfigureCUDA.cmake +++ b/cpp/cmake/Modules/ConfigureCUDA.cmake @@ -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 "CUDF: Building CUDF for GPU architectures: ${CMAKE_CUDA_ARCHITECTURES}") - -# Must come after find_package(CUDAToolkit) because we symlink -# ccache 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 CUDF_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations) endif() diff --git a/cpp/cmake/Modules/EvalGPUArchs.cmake b/cpp/cmake/Modules/EvalGPUArchs.cmake deleted file mode 100644 index 09e42c6cc7a..00000000000 --- a/cpp/cmake/Modules/EvalGPUArchs.cmake +++ /dev/null @@ -1,70 +0,0 @@ -#============================================================================= -# 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. -# 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. -#============================================================================= - -# Unset this first in case it's set to -set(CMAKE_CUDA_ARCHITECTURES OFF) - -# Enable CUDA so we can invoke nvcc -enable_language(CUDA) - -# Function uses the CUDA runtime API to query the compute capability of the device, so if a user -# doesn't pass any architecture options to CMake we only build the current architecture -function(evaluate_gpu_archs gpu_archs) - set(eval_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.cu) - set(eval_exe ${PROJECT_BINARY_DIR}/eval_gpu_archs) - set(error_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.stderr.log) - file( - WRITE ${eval_file} - " -#include -#include -#include -using namespace std; -int main(int argc, char** argv) { - set archs; - int nDevices; - if((cudaGetDeviceCount(&nDevices) == cudaSuccess) && (nDevices > 0)) { - for(int dev=0;dev= 1.9.10 included configs. -# -# Result Variables -# ^^^^^^^^^^^^^^^^ -# -# This module defines the following variables: -# ~~~ -# ``Thrust_FOUND`` system has Thrust -# ``Thrust_INCLUDE_DIRS`` the Thrust include directories -# ~~~ - -include(FindPackageHandleStandardArgs) - -# try to find Thrust via installed config first -find_package(Thrust QUIET CONFIG) -if(Thrust_FOUND) - find_package_handle_standard_args(Thrust CONFIG_MODE) - return() -endif() - -find_dependency(CUDAToolkit) - -find_path( - Thrust_INCLUDE_DIR - NAMES thrust/version.h - HINTS ${CUDAToolkit_INCLUDE_DIRS}) - -file(READ ${Thrust_INCLUDE_DIR}/thrust/version.h _version_header) -string(REGEX MATCH "#define THRUST_VERSION ([0-9]*)" _match "${_version_header}") -math(EXPR major "${CMAKE_MATCH_1} / 100000") -math(EXPR minor "(${CMAKE_MATCH_1} / 100) % 1000") -math(EXPR subminor "${CMAKE_MATCH_1} % 100") -set(Thrust_VERSION "${major}.${minor}.${subminor}") - -find_package_handle_standard_args( - Thrust - REQUIRED_VARS Thrust_INCLUDE_DIR - VERSION_VAR Thrust_VERSION) - -if(Thrust_FOUND) - set(Thrust_INCLUDE_DIRS "${Thrust_INCLUDE_DIR}") - # Create wrapper function to handle situation where we can't use a regular IMPORTED INTERFACE - # target since that'll use -isystem, leading to the wrong search order with nvcc - function(thrust_create_target tgt) - if(NOT TARGET ${tgt}) - add_library(thrust_internal INTERFACE) - set_target_properties(thrust_internal PROPERTIES INTERFACE_INCLUDE_DIRECTORIES - "${Thrust_INCLUDE_DIRS}") - add_library(${tgt} ALIAS thrust_internal) - endif() - endfunction() -endif() diff --git a/cpp/cmake/thirdparty/CUDF_GetCPM.cmake b/cpp/cmake/thirdparty/CUDF_GetCPM.cmake deleted file mode 100644 index ce2921f5954..00000000000 --- a/cpp/cmake/thirdparty/CUDF_GetCPM.cmake +++ /dev/null @@ -1,33 +0,0 @@ -set(CPM_DOWNLOAD_VERSION 7644c3a40fc7889f8dee53ce21e85dc390b883dc) # v0.32.1 - -if(CPM_SOURCE_CACHE) - # Expand relative path. This is important if the provided path contains a tilde (~) - get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE) - set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -elseif(DEFINED ENV{CPM_SOURCE_CACHE}) - set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -else() - set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -endif() - -if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - message(VERBOSE "CUDF: Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") - file( - DOWNLOAD - https://raw.githubusercontent.com/cpm-cmake/CPM.cmake/${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake - ${CPM_DOWNLOAD_LOCATION}) -endif() - -include(${CPM_DOWNLOAD_LOCATION}) - -# If a target is installed, found by the `find_package` step of CPMFindPackage, -# and marked as IMPORTED, make it globally accessible to consumers of our libs. -function(fix_cmake_global_defaults target) - if(TARGET ${target}) - get_target_property(_is_imported ${target} IMPORTED) - get_target_property(_already_global ${target} IMPORTED_GLOBAL) - if(_is_imported AND NOT _already_global) - set_target_properties(${target} PROPERTIES IMPORTED_GLOBAL TRUE) - endif() - endif() -endfunction() diff --git a/cpp/cmake/thirdparty/CUDF_GetGTest.cmake b/cpp/cmake/thirdparty/CUDF_GetGTest.cmake deleted file mode 100644 index 9e4f3c137b1..00000000000 --- a/cpp/cmake/thirdparty/CUDF_GetGTest.cmake +++ /dev/null @@ -1,50 +0,0 @@ -#============================================================================= -# Copyright (c) 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. -# 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. -#============================================================================= - -function(find_and_configure_gtest VERSION) - - if(TARGET GTest::gtest) - return() - endif() - - # Find or install GoogleTest - CPMFindPackage(NAME GTest - VERSION ${VERSION} - 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") - # Add GTest aliases if they don't already exist. - # Assumes if GTest::gtest doesn't exist, the others don't either. - # TODO: Is this always a valid assumption? - if(NOT TARGET GTest::gtest) - add_library(GTest::gtest ALIAS gtest) - add_library(GTest::gmock ALIAS gmock) - add_library(GTest::gtest_main ALIAS gtest_main) - add_library(GTest::gmock_main ALIAS gmock_main) - endif() - # Make sure consumers of cudf can also see GTest::* targets - fix_cmake_global_defaults(GTest::gtest) - fix_cmake_global_defaults(GTest::gmock) - fix_cmake_global_defaults(GTest::gtest_main) - fix_cmake_global_defaults(GTest::gmock_main) -endfunction() - -set(CUDF_MIN_VERSION_GTest 1.10.0) - -find_and_configure_gtest(${CUDF_MIN_VERSION_GTest}) diff --git a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake b/cpp/cmake/thirdparty/CUDF_GetRMM.cmake deleted file mode 100644 index b2861ae48c4..00000000000 --- a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake +++ /dev/null @@ -1,50 +0,0 @@ -#============================================================================= -# Copyright (c) 2020-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. -# 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. -#============================================================================= - -function(find_and_configure_rmm VERSION) - - 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() - - # Consumers have two options for local source builds: - # 1. Pass `-D CPM_rmm_SOURCE=/path/to/rmm` to build a local RMM source tree - # 2. Pass `-D CMAKE_PREFIX_PATH=/path/to/rmm/build` to use an existing local - # RMM build directory as the install location for find_package(rmm) - CPMFindPackage(NAME rmm - VERSION ${VERSION} - 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}" - ) - - # Make sure consumers of cudf can also see rmm::rmm - fix_cmake_global_defaults(rmm::rmm) -endfunction() - -set(CUDF_MIN_VERSION_rmm "${CUDF_VERSION_MAJOR}.${CUDF_VERSION_MINOR}.00") - -find_and_configure_rmm(${CUDF_MIN_VERSION_rmm}) diff --git a/cpp/cmake/thirdparty/CUDF_GetArrow.cmake b/cpp/cmake/thirdparty/get_arrow.cmake similarity index 83% rename from cpp/cmake/thirdparty/CUDF_GetArrow.cmake rename to cpp/cmake/thirdparty/get_arrow.cmake index 38a5d8da44a..c67f316f7e9 100644 --- a/cpp/cmake/thirdparty/CUDF_GetArrow.cmake +++ b/cpp/cmake/thirdparty/get_arrow.cmake @@ -49,8 +49,9 @@ function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENAB if(BUILD_STATIC) set(ARROW_BUILD_STATIC ON) set(ARROW_BUILD_SHARED OFF) - # Use CPMAddPackage if static linking - set(CPMAddOrFindPackage CPMAddPackage) + # Turn off CPM using `find_package` so we always download + # and make sure we get proper static library + set(CPM_DOWNLOAD_ALL TRUE) endif() set(ARROW_PYTHON_OPTIONS "") @@ -66,9 +67,9 @@ function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENAB # does not have the CUDA driver installed. This must be an env var. set(ENV{CUDA_LIB_PATH} "${CUDAToolkit_LIBRARY_DIR}/stubs") - cmake_language(CALL ${CPMAddOrFindPackage} - NAME Arrow - VERSION ${VERSION} + rapids_cpm_find(Arrow ${VERSION} + GLOBAL_TARGETS arrow_shared arrow_cuda_shared + CPM_ARGS GIT_REPOSITORY https://github.com/apache/arrow.git GIT_TAG apache-arrow-${VERSION} GIT_SHALLOW TRUE @@ -100,6 +101,33 @@ function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENAB "ARROW_PROTOBUF_USE_SHARED ${ARROW_BUILD_SHARED}" "ARROW_ZSTD_USE_SHARED ${ARROW_BUILD_SHARED}") + if(Arrow_ADDED) + rapids_export(BUILD Arrow + VERSION ${VERSION} + EXPORT_SET arrow_targets + GLOBAL_TARGETS arrow_shared arrow_static + NAMESPACE cudf::) + + rapids_export(BUILD ArrowCUDA + VERSION ${VERSION} + EXPORT_SET arrow_cuda_targets + GLOBAL_TARGETS arrow_cuda_shared arrow_cuda_static + NAMESPACE cudf::) + endif() + # We generate the arrow-config and arrowcuda-config files + # when we built arrow locally, so always do `find_dependency` + rapids_export_package(BUILD Arrow cudf-exports) + rapids_export_package(INSTALL Arrow cudf-exports) + + # We have to generate the find_dependency(ArrowCUDA) ourselves + # since we need to specify ArrowCUDA_DIR to be where Arrow + # was found, since Arrow packages ArrowCUDA.config in a non-standard + # location + rapids_export_package(BUILD ArrowCUDA cudf-exports) + + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(BUILD Arrow [=[${CMAKE_CURRENT_LIST_DIR}]=] cudf-exports) + rapids_export_find_package_root(BUILD ArrowCUDA [=[${CMAKE_CURRENT_LIST_DIR}]=] cudf-exports) set(ARROW_FOUND TRUE) set(ARROW_LIBRARIES "") @@ -159,22 +187,6 @@ function(find_and_configure_arrow VERSION BUILD_STATIC ENABLE_S3 ENABLE_ORC ENAB set(ARROW_FOUND "${ARROW_FOUND}" PARENT_SCOPE) set(ARROW_LIBRARIES "${ARROW_LIBRARIES}" PARENT_SCOPE) - if(TARGET arrow_shared) - get_target_property(arrow_is_imported arrow_shared IMPORTED) - if(NOT arrow_is_imported) - export(TARGETS arrow_shared arrow_cuda_shared - FILE ${CUDF_BINARY_DIR}/cudf-arrow-targets.cmake - NAMESPACE cudf::) - endif() - elseif(TARGET arrow_static) - get_target_property(arrow_is_imported arrow_static IMPORTED) - if(NOT arrow_is_imported) - export(TARGETS arrow_static arrow_cuda_static - FILE ${CUDF_BINARY_DIR}/cudf-arrow-targets.cmake - NAMESPACE cudf::) - endif() - endif() - endfunction() set(CUDF_VERSION_Arrow 5.0.0) diff --git a/cpp/cmake/thirdparty/CUDF_GetcuCollections.cmake b/cpp/cmake/thirdparty/get_cucollections.cmake similarity index 69% rename from cpp/cmake/thirdparty/CUDF_GetcuCollections.cmake rename to cpp/cmake/thirdparty/get_cucollections.cmake index 73717249585..b2e70ebaddc 100644 --- a/cpp/cmake/thirdparty/CUDF_GetcuCollections.cmake +++ b/cpp/cmake/thirdparty/get_cucollections.cmake @@ -22,17 +22,14 @@ function(find_and_configure_cucollections) # Find or install cuCollections CPMFindPackage(NAME cuco - GITHUB_REPOSITORY NVIDIA/cuCollections - GIT_TAG 0d602ae21ea4f38d23ed816aa948453d97b2ee4e - OPTIONS "BUILD_TESTS OFF" - "BUILD_BENCHMARKS OFF" - "BUILD_EXAMPLES OFF" + GLOBAL_TARGETS cuco::cuco + CPM_ARGS + GITHUB_REPOSITORY NVIDIA/cuCollections + GIT_TAG 0d602ae21ea4f38d23ed816aa948453d97b2ee4e + OPTIONS "BUILD_TESTS OFF" + "BUILD_BENCHMARKS OFF" + "BUILD_EXAMPLES OFF" ) - - set(CUCO_INCLUDE_DIR "${cuco_SOURCE_DIR}/include" PARENT_SCOPE) - - # Make sure consumers of cudf can also see cuco::cuco target - fix_cmake_global_defaults(cuco::cuco) endfunction() find_and_configure_cucollections() diff --git a/cpp/cmake/thirdparty/CUDF_GetDLPack.cmake b/cpp/cmake/thirdparty/get_dlpack.cmake similarity index 69% rename from cpp/cmake/thirdparty/CUDF_GetDLPack.cmake rename to cpp/cmake/thirdparty/get_dlpack.cmake index 349f75d604f..1334ac91c6e 100644 --- a/cpp/cmake/thirdparty/CUDF_GetDLPack.cmake +++ b/cpp/cmake/thirdparty/get_dlpack.cmake @@ -15,25 +15,21 @@ #============================================================================= function(find_and_configure_dlpack VERSION) - if(DLPACK_INCLUDE) - set(DLPACK_INCLUDE_DIR "${DLPACK_INCLUDE}" PARENT_SCOPE) - return() - endif() - find_path(DLPACK_INCLUDE_DIR "dlpack" - HINTS "$ENV{DLPACK_ROOT}/include" - "$ENV{CONDA_PREFIX}/include") - if(DLPACK_INCLUDE_DIR) - set(DLPACK_INCLUDE_DIR ${DLPACK_INCLUDE_DIR} PARENT_SCOPE) - return() - endif() - CPMFindPackage(NAME dlpack - VERSION ${VERSION} + + rapids_find_generate_module( DLPACK + HEADER_NAMES dlpack.h) + + rapids_cpm_find(dlpack ${VERSION} GIT_REPOSITORY https://github.com/dmlc/dlpack.git GIT_TAG v${VERSION} GIT_SHALLOW TRUE DOWNLOAD_ONLY TRUE OPTIONS "BUILD_MOCK OFF") - set(DLPACK_INCLUDE_DIR "${dlpack_SOURCE_DIR}/include" PARENT_SCOPE) + + if(DEFINED dlpack_SOURCE_DIR) + #otherwise find_package(DLPACK) will set this variable + set(DLPACK_INCLUDE_DIR "${dlpack_SOURCE_DIR}/include" PARENT_SCOPE) + endif() endfunction() set(CUDF_MIN_VERSION_dlpack 0.5) diff --git a/cpp/cmake/thirdparty/get_gtest.cmake b/cpp/cmake/thirdparty/get_gtest.cmake new file mode 100644 index 00000000000..9de2b4a50a9 --- /dev/null +++ b/cpp/cmake/thirdparty/get_gtest.cmake @@ -0,0 +1,37 @@ +#============================================================================= +# Copyright (c) 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. +# 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. +#============================================================================= + +function(find_and_configure_gtest) + include(${rapids-cmake-dir}/cpm/gtest.cmake) + + # Find or install GoogleTest + rapids_cpm_gtest(BUILD_EXPORT_SET cudf-testing-exports + INSTALL_EXPORT_SET cudf-testing-exports) + + if(GTest_ADDED) + rapids_export(BUILD GTest + VERSION ${GTest_VERSION} + EXPORT_SET GTestTargets + GLOBAL_TARGETS gtest gmock gtest_main gmock_main + NAMESPACE GTest::) + + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(BUILD GTest [=[${CMAKE_CURRENT_LIST_DIR}]=] cudf-testing-exports) + endif() + +endfunction() + +find_and_configure_gtest() diff --git a/cpp/cmake/thirdparty/CUDF_GetJitify.cmake b/cpp/cmake/thirdparty/get_jitify.cmake similarity index 94% rename from cpp/cmake/thirdparty/CUDF_GetJitify.cmake rename to cpp/cmake/thirdparty/get_jitify.cmake index 6e853816ec5..b8a85889ef2 100644 --- a/cpp/cmake/thirdparty/CUDF_GetJitify.cmake +++ b/cpp/cmake/thirdparty/get_jitify.cmake @@ -17,8 +17,7 @@ # Jitify doesn't have a version :/ function(find_and_configure_jitify) - CPMFindPackage(NAME jitify - VERSION 2.0.0 + rapids_cpm_find(jitify 2.0.0 GIT_REPOSITORY https://github.com/rapidsai/jitify.git GIT_TAG cudf_0.19 GIT_SHALLOW TRUE diff --git a/cpp/cmake/thirdparty/CUDF_GetLibcudacxx.cmake b/cpp/cmake/thirdparty/get_libcudacxx.cmake similarity index 82% rename from cpp/cmake/thirdparty/CUDF_GetLibcudacxx.cmake rename to cpp/cmake/thirdparty/get_libcudacxx.cmake index 63d6d26802c..4921abe0581 100644 --- a/cpp/cmake/thirdparty/CUDF_GetLibcudacxx.cmake +++ b/cpp/cmake/thirdparty/get_libcudacxx.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -15,16 +15,14 @@ #============================================================================= function(find_and_configure_libcudacxx VERSION) - CPMFindPackage(NAME libcudacxx - VERSION ${VERSION} + rapids_cpm_find(libcudacxx ${VERSION} GIT_REPOSITORY https://github.com/NVIDIA/libcudacxx.git GIT_TAG ${VERSION} GIT_SHALLOW TRUE DOWNLOAD_ONLY TRUE ) - set(LIBCUDACXX_DIR "${libcudacxx_SOURCE_DIR}" PARENT_SCOPE) + set(LIBCUDACXX_INCLUDE_DIR "${libcudacxx_SOURCE_DIR}/include" PARENT_SCOPE) - set(LIBCXX_DIR "${libcudacxx_SOURCE_DIR}/libcxx" PARENT_SCOPE) set(LIBCXX_INCLUDE_DIR "${libcudacxx_SOURCE_DIR}/libcxx/include" PARENT_SCOPE) endfunction() diff --git a/cpp/cmake/thirdparty/CUDF_GetNVBench.cmake b/cpp/cmake/thirdparty/get_rmm.cmake similarity index 60% rename from cpp/cmake/thirdparty/CUDF_GetNVBench.cmake rename to cpp/cmake/thirdparty/get_rmm.cmake index 09ceffb284f..ec40afa4d05 100644 --- a/cpp/cmake/thirdparty/CUDF_GetNVBench.cmake +++ b/cpp/cmake/thirdparty/get_rmm.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021, NVIDIA CORPORATION. +# Copyright (c) 2020-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. @@ -14,21 +14,13 @@ # limitations under the License. #============================================================================= -# NVBench doesn't have a public release yet +function(find_and_configure_rmm) + include(${rapids-cmake-dir}/cpm/rmm.cmake) -function(find_and_configure_nvbench) - - if(TARGET nvbench::main) - return() - endif() - - CPMFindPackage(NAME nvbench - GIT_REPOSITORY https://github.com/NVIDIA/nvbench.git - GIT_TAG main - GIT_SHALLOW TRUE - OPTIONS "NVBench_ENABLE_EXAMPLES OFF" - "NVBench_ENABLE_TESTING OFF") + # Find or install RMM + rapids_cpm_rmm(BUILD_EXPORT_SET cudf-exports + INSTALL_EXPORT_SET cudf-exports) endfunction() -find_and_configure_nvbench() +find_and_configure_rmm() diff --git a/cpp/cmake/thirdparty/CUDF_GetThrust.cmake b/cpp/cmake/thirdparty/get_thrust.cmake similarity index 77% rename from cpp/cmake/thirdparty/CUDF_GetThrust.cmake rename to cpp/cmake/thirdparty/get_thrust.cmake index 2792786f553..aecf0498b65 100644 --- a/cpp/cmake/thirdparty/CUDF_GetThrust.cmake +++ b/cpp/cmake/thirdparty/get_thrust.cmake @@ -24,17 +24,21 @@ function(find_and_configure_thrust VERSION) set(cpm_thrust_disconnect_update "") endif() - CPMAddPackage(NAME Thrust - VERSION ${VERSION} - GIT_REPOSITORY https://github.com/NVIDIA/thrust.git - GIT_TAG ${VERSION} - GIT_SHALLOW TRUE + rapids_cpm_find( + Thrust ${VERSION} + BUILD_EXPORT_SET cudf-exports + INSTALL_EXPORT_SET cudf-exports + CPM_ARGS + GIT_REPOSITORY https://github.com/NVIDIA/thrust.git + GIT_TAG ${VERSION} + GIT_SHALLOW TRUE ${cpm_thrust_disconnect_update} PATCH_COMMAND patch --reject-file=- -p1 -N < ${CUDF_SOURCE_DIR}/cmake/thrust.patch || true - ) + OPTIONS "THRUST_INSTALL TRUE") - thrust_create_target(cudf::Thrust FROM_OPTIONS) - set(THRUST_LIBRARY "cudf::Thrust" PARENT_SCOPE) + if(NOT TARGET cudf::Thrust) + thrust_create_target(cudf::Thrust FROM_OPTIONS) + endif() include(GNUInstallDirs) install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust" @@ -52,6 +56,10 @@ function(find_and_configure_thrust VERSION) install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libcudf/Thrust/dependencies/cub/") + + # Store where CMake can find our custom Thrust install + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(INSTALL Thrust [=[${CMAKE_CURRENT_LIST_DIR}/../../../include/libcudf/Thrust/]=] cudf-exports) endfunction() set(CUDF_MIN_VERSION_Thrust 1.12.0) diff --git a/cpp/libcudf_kafka/CMakeLists.txt b/cpp/libcudf_kafka/CMakeLists.txt index 7c112d838d8..020f5c76c10 100644 --- a/cpp/libcudf_kafka/CMakeLists.txt +++ b/cpp/libcudf_kafka/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2018-2020, NVIDIA CORPORATION. +# Copyright (c) 2018-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. @@ -13,10 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.10/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) + +include(rapids-cmake) +include(rapids-cpm) +include(rapids-cuda) +include(rapids-export) +include(rapids-find) project(CUDA_KAFKA VERSION 21.10.00 LANGUAGES CXX) +# Set a default build type if none was specified +rapids_cmake_build_type(Release) + ################################################################################################### # - Build options option(BUILD_TESTS "Build tests for libcudf_kafka" ON) @@ -26,19 +39,15 @@ message(VERBOSE "CUDF_KAFKA: Build gtests: ${BUILD_TESTS}") ################################################################################################### # - Dependencies -# CPM -include(../cmake/thirdparty/CUDF_GetCPM.cmake) - -# libcudf -include(cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake) - -# librdkafka -include(cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake) +# add third party dependencies using CPM +rapids_cpm_init() +include(cmake/thirdparty/get_cudf.cmake) +include(cmake/thirdparty/get_rdkafka.cmake) # # GTests if enabled if (BUILD_TESTS) # GoogleTest - include(../cmake/thirdparty/CUDF_GetGTest.cmake) + include(../cmake/thirdparty/get_gtest.cmake) # include CTest module -- automatically calls enable_testing() include(CTest) @@ -46,32 +55,46 @@ if (BUILD_TESTS) endif() ################################################################################################### -# - include paths --------------------------------------------------------------------------------- - -include_directories("${CMAKE_BINARY_DIR}/include" - "${CMAKE_SOURCE_DIR}/include" - "${CMAKE_SOURCE_DIR}/src") +# - library target -------------------------------------------------------------------------------- +add_library(cudf_kafka SHARED + src/kafka_consumer.cpp) ################################################################################################### -# - library paths --------------------------------------------------------------------------------- - -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc - "${CMAKE_BINARY_DIR}/lib" - "${CMAKE_BINARY_DIR}") +# - include paths --------------------------------------------------------------------------------- +target_include_directories(cudf_kafka + PUBLIC + "$" + "$") ################################################################################################### -# - library target -------------------------------------------------------------------------------- +# - library paths --------------------------------------------------------------------------------- +target_link_libraries(cudf_kafka PUBLIC cudf::cudf RDKAFKA::RDKAFKA) -add_library(cudf_kafka SHARED - src/kafka_consumer.cpp -) +set_target_properties(cudf_kafka + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + # set target compile options + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON) ################################################################################################### # - cudf_kafka Install ---------------------------------------------------------------------------- -target_link_libraries(cudf_kafka cudf::cudf RDKAFKA::RDKAFKA) - +rapids_cmake_install_lib_dir(lib_dir) install(TARGETS cudf_kafka - DESTINATION lib) + DESTINATION ${lib_dir} + EXPORT cudf_kafka-exports) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION include) + +rapids_export(INSTALL cudf_kafka + EXPORT_SET cudf_kafka-exports + GLOBAL_TARGETS cudf_kafka + NAMESPACE cudf_kafka:: + ) + +rapids_export(BUILD cudf_kafka + EXPORT_SET cudf_kafka-exports + GLOBAL_TARGETS cudf_kafka + NAMESPACE cudf_kafka:: + ) diff --git a/cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake b/cpp/libcudf_kafka/cmake/thirdparty/get_cudf.cmake similarity index 52% rename from cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake rename to cpp/libcudf_kafka/cmake/thirdparty/get_cudf.cmake index 29220860b6e..ea749726b97 100644 --- a/cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetCUDF.cmake +++ b/cpp/libcudf_kafka/cmake/thirdparty/get_cudf.cmake @@ -15,24 +15,37 @@ #============================================================================= function(find_and_configure_cudf VERSION) - CPMFindPackage(NAME cudf - VERSION ${VERSION} - GIT_REPOSITORY https://github.com/rapidsai/cudf.git - GIT_TAG branch-${VERSION} - GIT_SHALLOW TRUE - SOURCE_SUBDIR cpp - OPTIONS "BUILD_TESTS OFF" - "BUILD_BENCHMARKS OFF") - if(cudf_ADDED) - set(cudf_ADDED TRUE PARENT_SCOPE) + rapids_cmake_parse_version(MAJOR_MINOR ${VERSION} major_minor) + rapids_cpm_find(cudf ${VERSION} + BUILD_EXPORT_SET cudf_kafka-exports + INSTALL_EXPORT_SET cudf_kafka-exports + CPM_ARGS + GIT_REPOSITORY https://github.com/rapidsai/cudf.git + GIT_TAG branch-${major_minor} + GIT_SHALLOW TRUE + SOURCE_SUBDIR cpp + OPTIONS "BUILD_TESTS OFF" + "BUILD_BENCHMARKS OFF") + # If after loading cudf we now have the CMAKE_CUDA_COMPILER + # variable we know that we need to re-enable the cuda language + if(CMAKE_CUDA_COMPILER) + set(cudf_REQUIRES_CUDA TRUE PARENT_SCOPE) endif() endfunction() set(CUDA_KAFKA_MIN_VERSION_cudf "${CUDA_KAFKA_VERSION_MAJOR}.${CUDA_KAFKA_VERSION_MINOR}.${CUDA_KAFKA_VERSION_PATCH}") find_and_configure_cudf(${CUDA_KAFKA_MIN_VERSION_cudf}) -if(cudf_ADDED) +if(cudf_REQUIRES_CUDA) + rapids_cuda_init_architectures(CUDA_KAFKA) + # Since we are building cudf as part of ourselves we need # to enable the CUDA language in the top-most scope enable_language(CUDA) + + # Since CUDA_KAFKA only enables CUDA optionally we need to manually include the file that + # rapids_cuda_init_architectures relies on `project` calling + if(DEFINED CMAKE_PROJECT_CUDA_KAFKA_INCLUDE) + include("${CMAKE_PROJECT_CUDA_KAFKA_INCLUDE}") + endif() endif() diff --git a/cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake b/cpp/libcudf_kafka/cmake/thirdparty/get_rdkafka.cmake similarity index 52% rename from cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake rename to cpp/libcudf_kafka/cmake/thirdparty/get_rdkafka.cmake index 5c07db66668..3a4fffd5000 100644 --- a/cpp/libcudf_kafka/cmake/thirdparty/CUDF_KAFKA_GetRDKafka.cmake +++ b/cpp/libcudf_kafka/cmake/thirdparty/get_rdkafka.cmake @@ -14,12 +14,28 @@ # limitations under the License. #============================================================================= -find_path(RDKAFKA_INCLUDE "librdkafka" HINTS "$ENV{RDKAFKA_ROOT}/include") -find_library(RDKAFKA++_LIBRARY "rdkafka++" HINTS "$ENV{RDKAFKA_ROOT}/lib" "$ENV{RDKAFKA_ROOT}/build") -if(RDKAFKA_INCLUDE AND RDKAFKA++_LIBRARY) - add_library(rdkafka INTERFACE) - target_link_libraries(rdkafka INTERFACE "${RDKAFKA++_LIBRARY}") - target_include_directories(rdkafka INTERFACE "${RDKAFKA_INCLUDE}") - add_library(RDKAFKA::RDKAFKA ALIAS rdkafka) -endif() \ No newline at end of file +function( get_RDKafka ) + rapids_find_generate_module(RDKAFKA + HEADER_NAMES rdkafkacpp.h + INCLUDE_SUFFIXES librdkafka + LIBRARY_NAMES rdkafka++ + BUILD_EXPORT_SET cudf_kafka-exports + INSTALL_EXPORT_SET cudf_kafka-exports + ) + + if(DEFINED ENV{RDKAFKA_ROOT}) + # Since this is inside a function the modification of + # CMAKE_PREFIX_PATH won't leak to other callers/users + list(APPEND CMAKE_PREFIX_PATH "$ENV{RDKAFKA_ROOT}") + list(APPEND CMAKE_PREFIX_PATH "$ENV{RDKAFKA_ROOT}/build") + endif() + + + rapids_find_package(RDKAFKA REQUIRED + BUILD_EXPORT_SET cudf_kafka-exports + INSTALL_EXPORT_SET cudf_kafka-exports) + +endfunction() + +get_RDKafka() diff --git a/cpp/libcudf_kafka/tests/CMakeLists.txt b/cpp/libcudf_kafka/tests/CMakeLists.txt index e813ed5439e..f0c2664cd96 100644 --- a/cpp/libcudf_kafka/tests/CMakeLists.txt +++ b/cpp/libcudf_kafka/tests/CMakeLists.txt @@ -17,22 +17,16 @@ ################################################################################################### # - compiler function ----------------------------------------------------------------------------- -function(ConfigureTest CMAKE_TEST_NAME ) - add_executable(${CMAKE_TEST_NAME} ${ARGN}) - set_target_properties(${CMAKE_TEST_NAME} +function(ConfigureTest test_name ) + add_executable(${test_name} ${ARGN}) + set_target_properties(${test_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "$") - target_link_libraries(${CMAKE_TEST_NAME} PRIVATE GTest::gmock_main GTest::gtest_main cudf_kafka) - target_include_directories(${CMAKE_TEST_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include) - add_test(NAME ${CMAKE_TEST_NAME} COMMAND ${CMAKE_TEST_NAME}) + target_link_libraries(${test_name} PRIVATE GTest::gmock_main GTest::gtest_main cudf_kafka) + + add_test(NAME ${test_name} COMMAND ${test_name}) endfunction() ################################################################################################### # - Kafka host tests ---------------------------------------------------------------------------------- ConfigureTest(KAFKA_HOST_TEST kafka_consumer_tests.cpp) - -################################################################################################### -### enable testing ################################################################################ -################################################################################################### - -enable_testing() diff --git a/java/src/main/native/CMakeLists.txt b/java/src/main/native/CMakeLists.txt index bc59e3aee64..d4875b22b89 100755 --- a/java/src/main/native/CMakeLists.txt +++ b/java/src/main/native/CMakeLists.txt @@ -13,26 +13,23 @@ # See the License for the specific language governing permissions and # limitations under the License. #============================================================================= -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) + +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.10/RAPIDS.cmake + ${CMAKE_BINARY_DIR}/RAPIDS.cmake) +include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) + +include(rapids-cmake) +include(rapids-cuda) +include(rapids-find) # Use GPU_ARCHS if it is defined if(DEFINED GPU_ARCHS) set(CMAKE_CUDA_ARCHITECTURES "${GPU_ARCHS}") endif() +rapids_cuda_init_architectures(CUDF_JNI) -# 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(CUDF_JNI_BUILD_FOR_ALL_ARCHS TRUE) -elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "") - set(CUDF_JNI_BUILD_FOR_DETECTED_ARCHS TRUE) -endif() - -project(CUDF_JNI VERSION 21.10.00 LANGUAGES C CXX) +project(CUDF_JNI VERSION 21.10.00 LANGUAGES C CXX CUDA) ################################################################################################### # - build options --------------------------------------------------------------------------------- @@ -71,11 +68,8 @@ set(CUDF_CUDA_FLAGS "") set(CUDF_CXX_DEFINITIONS "") set(CUDF_CUDA_DEFINITIONS "") -# * find CUDAToolkit package -# * determine GPU architectures -# * enable the CMake CUDA language -# * set other CUDA compilation flags -include(ConfigureCUDA) +rapids_find_package(CUDAToolkit REQUIRED) +include(ConfigureCUDA) # set other CUDA compilation flags # Disable NVTX if necessary if(NOT USE_NVTX) @@ -85,33 +79,12 @@ endif() if(PER_THREAD_DEFAULT_STREAM) message(STATUS "Using per-thread default stream") add_compile_definitions(CUDA_API_PER_THREAD_DEFAULT_STREAM) -endif(PER_THREAD_DEFAULT_STREAM) +endif() ################################################################################################### # - build type ------------------------------------------------------------------------------------ - # Set a default build type if none was specified -set(DEFAULT_BUILD_TYPE "Release") - -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() - -################################################################################################### -# - cudart options -------------------------------------------------------------------------------- -# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking - -if(CUDA_STATIC_RUNTIME) - message(STATUS "Enabling static linking of cudart") - set(CUDART_LIBRARY "cudart_static") -else() - set(CUDART_LIBRARY "cudart") -endif(CUDA_STATIC_RUNTIME) +rapids_cmake_build_type("Release") ################################################################################################### # - Thrust/CUB/libcudacxx ------------------------------------------------------------------------------------ @@ -182,7 +155,7 @@ if(CUDF_JNI_ARROW_STATIC) set(CUDF_JNI_ARROW_LIBNAME "libarrow.a") else() set(CUDF_JNI_ARROW_LIBNAME "arrow") -endif(CUDF_JNI_ARROW_STATIC) +endif() find_library(ARROW_LIBRARY ${CUDF_JNI_ARROW_LIBNAME} REQUIRED HINTS "$ENV{ARROW_ROOT}/lib" @@ -194,10 +167,10 @@ if(NOT ARROW_LIBRARY) message(FATAL_ERROR "Arrow static library not found. Was libcudf built with CUDF_USE_ARROW_STATIC=ON?") else() message(FATAL_ERROR "Arrow dynamic library not found.") - endif(CUDF_JNI_ARROW_STATIC) + endif() else() message(STATUS "ARROW: ARROW_LIBRARY set to ${ARROW_LIBRARY}") -endif(NOT ARROW_LIBRARY) +endif() ################################################################################################### # - find JNI ------------------------------------------------------------------------------------- @@ -206,7 +179,7 @@ if(JNI_FOUND) message(STATUS "JDK with JNI in ${JNI_INCLUDE_DIRS}") else() message(FATAL_ERROR "JDK with JNI not found, please check your settings.") -endif(JNI_FOUND) +endif() ################################################################################################### # - nvcomp ---------------------------------------------------------------------------------------- @@ -216,9 +189,7 @@ if(NVCOMP_FOUND) message(STATUS "nvcomp compression library found in ${NVCOMP_ROOT}") else() message(FATAL_ERROR "nvcomp compression library not found.") -endif(NVCOMP_FOUND) - -add_library(nvcomp STATIC IMPORTED ${NVCOMP_LIB}) +endif() ################################################################################################### # - GDS/cufile ------------------------------------------------------------------------------------ @@ -226,57 +197,55 @@ add_library(nvcomp STATIC IMPORTED ${NVCOMP_LIB}) if(USE_GDS) message(STATUS "Building with GPUDirect Storage (GDS)/cuFile support") find_package(cuFile REQUIRED) -endif(USE_GDS) +endif() ################################################################################################### -# - include paths --------------------------------------------------------------------------------- +# - library targets ------------------------------------------------------------------------------- -include_directories("${THRUST_INCLUDE}" - "${CUB_INCLUDE}" - "${LIBCUDACXX_INCLUDE}" - "${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}" - "${NVCOMP_INCLUDE_DIR}" - "${CMAKE_BINARY_DIR}/include" - "${CMAKE_SOURCE_DIR}/include" - "${SPDLOG_INCLUDE}" - "${CMAKE_SOURCE_DIR}/src" - "${JNI_INCLUDE_DIRS}" - "${CUDF_INCLUDE}" - "${RMM_INCLUDE}" - "${ARROW_INCLUDE}") +add_library(cudfjni SHARED + src/row_conversion.cu + src/AggregationJni.cpp + src/CudfJni.cpp + src/CudaJni.cpp + src/ColumnVectorJni.cpp + src/ColumnViewJni.cpp + src/CompiledExpression.cpp + src/ContiguousTableJni.cpp + src/HashJoinJni.cpp + src/HostMemoryBufferNativeUtilsJni.cpp + src/NvcompJni.cpp + src/NvtxRangeJni.cpp + src/RmmJni.cpp + src/ScalarJni.cpp + src/TableJni.cpp + src/map_lookup.cu) ################################################################################################### -# - library paths --------------------------------------------------------------------------------- - -link_directories("${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}" # CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES is an undocumented/unsupported variable containing the link directories for nvcc - "${CMAKE_BINARY_DIR}/lib") +# - include paths --------------------------------------------------------------------------------- +target_include_directories(cudfjni + PUBLIC + "${THRUST_INCLUDE}" + "${CUB_INCLUDE}" + "${LIBCUDACXX_INCLUDE}" + "${CUDAToolkit_INCLUDE_DIRS}" + "${NVCOMP_INCLUDE_DIR}" + "${CMAKE_BINARY_DIR}/include" + "${CMAKE_SOURCE_DIR}/include" + "${SPDLOG_INCLUDE}" + "${CMAKE_SOURCE_DIR}/src" + "${JNI_INCLUDE_DIRS}" + "${CUDF_INCLUDE}" + "${RMM_INCLUDE}" + "${ARROW_INCLUDE}") ################################################################################################### -# - library targets ------------------------------------------------------------------------------- - -set(SOURCE_FILES - "src/row_conversion.cu" - "src/AggregationJni.cpp" - "src/CudfJni.cpp" - "src/CudaJni.cpp" - "src/ColumnVectorJni.cpp" - "src/ColumnViewJni.cpp" - "src/CompiledExpression.cpp" - "src/ContiguousTableJni.cpp" - "src/HashJoinJni.cpp" - "src/HostMemoryBufferNativeUtilsJni.cpp" - "src/NvcompJni.cpp" - "src/NvtxRangeJni.cpp" - "src/RmmJni.cpp" - "src/ScalarJni.cpp" - "src/TableJni.cpp" - "src/map_lookup.cu") -add_library(cudfjni SHARED ${SOURCE_FILES}) +# - compile options --------------------------------------------------------------------------------- #Override RPATH for cudfjni -SET_TARGET_PROPERTIES(cudfjni - PROPERTIES BUILD_RPATH "\$ORIGIN" +set_target_properties(cudfjni + PROPERTIES BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" # set target compile options CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON @@ -295,18 +264,17 @@ target_compile_definitions(cudfjni ) if(USE_GDS) - add_library(cufilejni SHARED "src/CuFileJni.cpp") - SET_TARGET_PROPERTIES(cufilejni - PROPERTIES BUILD_RPATH "\$ORIGIN" + add_library(cufilejni SHARED src/CuFileJni.cpp) + set_target_properties(cufilejni + 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 ) target_include_directories(cufilejni PRIVATE "${cuFile_INCLUDE_DIRS}") target_link_libraries(cufilejni PRIVATE cudfjni "${cuFile_LIBRARIES}") -endif(USE_GDS) +endif() ################################################################################################### # - rmm logging level ----------------------------------------------------------------------------- @@ -322,4 +290,16 @@ target_compile_definitions(cudfjni PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM ################################################################################################### # - link libraries -------------------------------------------------------------------------------- -target_link_libraries(cudfjni ${NVCOMP_LIB} ${CUDF_LIB} ${ARROW_LIBRARY} ${CUDART_LIBRARY} cuda) +target_link_libraries(cudfjni PRIVATE nvcomp ${CUDF_LIB} ${ARROW_LIBRARY}) + +################################################################################################### +# - cudart options -------------------------------------------------------------------------------- +# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking + +if(CUDA_STATIC_RUNTIME) + # Tell CMake what CUDA language runtime to use + set_target_properties(cudfjni PROPERTIES CUDA_RUNTIME_LIBRARY Static) +else() + # Tell CMake what CUDA language runtime to use + set_target_properties(cudfjni PROPERTIES CUDA_RUNTIME_LIBRARY Shared) +endif() diff --git a/java/src/main/native/cmake/EvalGpuArchs.cmake b/java/src/main/native/cmake/EvalGpuArchs.cmake deleted file mode 100644 index 740987e4785..00000000000 --- a/java/src/main/native/cmake/EvalGpuArchs.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (c) 2019, 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. -# - -function(evaluate_gpu_archs gpu_archs) - set(eval_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.cu) - set(eval_exe ${PROJECT_BINARY_DIR}/eval_gpu_archs) - set(error_file ${PROJECT_BINARY_DIR}/eval_gpu_archs.stderr.log) - file(WRITE ${eval_file} - " -#include -#include -#include -using namespace std; -int main(int argc, char** argv) { - set archs; - int nDevices; - if((cudaGetDeviceCount(&nDevices) == cudaSuccess) && (nDevices > 0)) { - for(int dev=0;dev