Skip to content

Commit

Permalink
Merge branch 'branch-24.08' into test-nvcomp-4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard authored Aug 6, 2024
2 parents ff4aa1f + 3c03bc6 commit 023e87e
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 12 deletions.
18 changes: 18 additions & 0 deletions cmake-format-rapids-cmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@
"nargs": 1
}
},
"rapids_cpm_bs_thread_pool": {
"pargs": {
"nargs": 0
},
"kwargs": {
"BUILD_EXPORT_SET": 1,
"INSTALL_EXPORT_SET": 1
}
},
"rapids_cpm_cccl": {
"pargs": {
"nargs": 0
Expand Down Expand Up @@ -183,6 +192,15 @@
"USE_PROPRIETARY_BINARY": 1
}
},
"rapids_cpm_nvtx3": {
"pargs": {
"nargs": 0
},
"kwargs": {
"BUILD_EXPORT_SET": 1,
"INSTALL_EXPORT_SET": 1
}
},
"rapids_cpm_rmm": {
"pargs": {
"nargs": 0
Expand Down
1 change: 1 addition & 0 deletions docs/packages/packages.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.. toctree::
:titlesonly:

/packages/rapids_cpm_bs_thread_pool
/packages/rapids_cpm_cccl
/packages/rapids_cpm_cuco
/packages/rapids_cpm_fmt
Expand Down
1 change: 1 addition & 0 deletions docs/packages/rapids_cpm_bs_thread_pool.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. cmake-module:: ../../rapids-cmake/cpm/bs_thread_pool.cmake
136 changes: 136 additions & 0 deletions rapids-cmake/cpm/bs_thread_pool.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# =============================================================================
# Copyright (c) 2024, 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.
# =============================================================================
include_guard(GLOBAL)

#[=======================================================================[.rst:
rapids_cpm_bs_thread_pool
-------------------------

.. versionadded:: v24.08.00

Allow projects to find or build `thread-pool` via `CPM` with built-in
tracking of these dependencies for correct export support.

Uses the version of `thread-pool` :ref:`specified in the version file <cpm_versions>` for consistency
across all RAPIDS projects.

.. code-block:: cmake

rapids_cpm_bs_thread_pool( [BUILD_EXPORT_SET <export-name>]
[INSTALL_EXPORT_SET <export-name>]
[<CPM_ARGS> ...])

.. |PKG_NAME| replace:: bs_thread_pool
.. include:: common_package_args.txt

Result Targets
^^^^^^^^^^^^^^
`BS::thread_pool` target will be created

Result Variables
^^^^^^^^^^^^^^^^
:cmake:variable:`bs_thread_pool_SOURCE_DIR` is set to the path to the source directory of `thread-pool`.
:cmake:variable:`bs_thread_pool_BINARY_DIR` is set to the path to the build directory of `thread-pool`.
:cmake:variable:`bs_thread_pool_ADDED` is set to a true value if `thread-pool` has not been added before.
:cmake:variable:`bs_thread_pool_VERSION` is set to the version of `thread-pool` specified by the versions.json.

#]=======================================================================]
# cmake-lint: disable=R0915
function(rapids_cpm_bs_thread_pool)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.bs_thread_pool")

set(options)
set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET)
set(multi_value)
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})

# Fix up _RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find
if(_RAPIDS_INSTALL_EXPORT_SET)
list(APPEND _RAPIDS_EXPORT_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET})
endif()
if(_RAPIDS_BUILD_EXPORT_SET)
list(APPEND _RAPIDS_EXPORT_ARGUMENTS BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET})
endif()
set(_RAPIDS_UNPARSED_ARGUMENTS ${_RAPIDS_EXPORT_ARGUMENTS})

include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(bs_thread_pool version repository tag shallow exclude)

include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake")
rapids_cpm_generate_patch_command(bs_thread_pool ${version} patch_command)

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(bs_thread_pool ${version} ${ARGN}
GLOBAL_TARGETS rapids_bs_thread_pool
CPM_ARGS
GIT_REPOSITORY ${repository}
GIT_TAG ${tag}
GIT_SHALLOW ${shallow} ${patch_command}
EXCLUDE_FROM_ALL ${exclude}
DOWNLOAD_ONLY ON)

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(bs_thread_pool)

# Extract the major version value of bs_thread_pool to use with `rapids-export` to setup
# compatibility rules
include("${rapids-cmake-dir}/cmake/parse_version.cmake")
rapids_cmake_parse_version(MAJOR ${version} ${version})

# Set up install rules Need to be re-entrant safe so only call when `bs_thread_pool_ADDED`
if(bs_thread_pool_ADDED)
if(NOT TARGET rapids_bs_thread_pool)
add_library(rapids_bs_thread_pool INTERFACE)
target_include_directories(rapids_bs_thread_pool
INTERFACE "$<BUILD_INTERFACE:${bs_thread_pool_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_compile_definitions(rapids_bs_thread_pool INTERFACE "BS_THREAD_POOL_ENABLE_PAUSE=1")
target_compile_features(rapids_bs_thread_pool INTERFACE cxx_std_17 cuda_std_17)
set_property(TARGET rapids_bs_thread_pool PROPERTY EXPORT_NAME thread_pool)
install(TARGETS rapids_bs_thread_pool EXPORT bs_thread_pool-targets)
endif()
if(_RAPIDS_BUILD_EXPORT_SET)
include("${rapids-cmake-dir}/export/export.cmake")
rapids_export(BUILD bs_thread_pool
VERSION ${version}
EXPORT_SET bs_thread_pool-targets
GLOBAL_TARGETS thread_pool
NAMESPACE BS::)
include("${rapids-cmake-dir}/export/find_package_root.cmake")
rapids_export_find_package_root(BUILD bs_thread_pool [=[${CMAKE_CURRENT_LIST_DIR}]=]
EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET})
endif()
if(_RAPIDS_INSTALL_EXPORT_SET AND NOT exclude)
include(GNUInstallDirs)
install(DIRECTORY "${bs_thread_pool_SOURCE_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
include("${rapids-cmake-dir}/export/export.cmake")
rapids_export(INSTALL bs_thread_pool
VERSION ${version}
EXPORT_SET bs_thread_pool-targets
GLOBAL_TARGETS thread_pool
NAMESPACE BS::)
endif()
endif()

if(NOT TARGET BS::thread_pool AND TARGET rapids_bs_thread_pool)
add_library(BS::thread_pool ALIAS rapids_bs_thread_pool)
endif()

# Propagate up variables that CPMFindPackage provide
set(bs_thread_pool_SOURCE_DIR "${bs_thread_pool_SOURCE_DIR}" PARENT_SCOPE)
set(bs_thread_pool_BINARY_DIR "${bs_thread_pool_BINARY_DIR}" PARENT_SCOPE)
set(bs_thread_pool_ADDED "${bs_thread_pool_ADDED}" PARENT_SCOPE)
set(bs_thread_pool_VERSION ${version} PARENT_SCOPE)
endfunction()
2 changes: 1 addition & 1 deletion rapids-cmake/cpm/nvtx3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function(rapids_cpm_nvtx3)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.nvtx3")

set(options)
set(one_value USE_PROPRIETARY_BINARY BUILD_EXPORT_SET INSTALL_EXPORT_SET)
set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET)
set(multi_value)
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})

Expand Down
5 changes: 5 additions & 0 deletions rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"git_url": "https://github.com/google/benchmark.git",
"git_tag": "v${version}"
},
"bs_thread_pool": {
"version": "4.1.0",
"git_url": "https://github.com/bshoshany/thread-pool.git",
"git_tag": "097aa718f25d44315cadb80b407144ad455ee4f9"
},
"CCCL": {
"version": "2.5.0",
"git_shallow": false,
Expand Down
7 changes: 5 additions & 2 deletions rapids-cmake/cuda/init_architectures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ function(rapids_cuda_init_architectures project_name)
# 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.
if(CMAKE_CUDA_ARCHITECTURES STREQUAL "RAPIDS" OR CMAKE_CUDA_ARCHITECTURES STREQUAL "NATIVE")
set(cuda_arch_mode "${CMAKE_CUDA_ARCHITECTURES}")
if(DEFINED CMAKE_CUDA_ARCHITECTURES)
# Don't ever look at `ENV{CUDAARCHS}` if a `CMAKE_CUDA_ARCHITECTURES` has been specified
if(CMAKE_CUDA_ARCHITECTURES STREQUAL "RAPIDS" OR CMAKE_CUDA_ARCHITECTURES STREQUAL "NATIVE")
set(cuda_arch_mode "${CMAKE_CUDA_ARCHITECTURES}")
endif()
elseif(DEFINED ENV{CUDAARCHS} AND ("$ENV{CUDAARCHS}" STREQUAL "RAPIDS" OR "$ENV{CUDAARCHS}"
STREQUAL "NATIVE"))
set(cuda_arch_mode "$ENV{CUDAARCHS}")
Expand Down
23 changes: 14 additions & 9 deletions rapids-cmake/test/generate_resource_spec.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ files to be generated.
function(rapids_test_generate_resource_spec DESTINATION filepath)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.generate_resource_spec")

if(NOT DEFINED CMAKE_CUDA_COMPILER AND NOT DEFINED CMAKE_CXX_COMPILER)
unset(rapids_lang)
get_property(rapids_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if("CXX" IN_LIST rapids_languages)
set(rapids_lang CXX)
# Even when the CUDA language is disabled we want to pass this since it is used by
# find_package(CUDAToolkit) to find the location
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_CUDA_COMPILER)
endif()
if("CUDA" IN_LIST rapids_languages)
set(rapids_lang CUDA)
endif()

if(NOT rapids_lang)
message(FATAL_ERROR "rapids_test_generate_resource_spec Requires the CUDA or C++ language to be enabled."
)
endif()
Expand All @@ -58,18 +70,11 @@ function(rapids_test_generate_resource_spec DESTINATION filepath)
find_package(CUDAToolkit QUIET)
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/rapids-cmake/")

set(compiler "${CMAKE_CXX_COMPILER}")
set(lang CXX)
if(DEFINED CMAKE_CUDA_COMPILER)
set(compiler "${CMAKE_CUDA_COMPILER}")
set(lang CUDA)
endif()

try_compile(result "${PROJECT_BINARY_DIR}/rapids-cmake/generate_ctest_json-build"
"${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/generate_resource_spec"
generate_resource_spec
CMAKE_FLAGS "-DCUDAToolkit_ROOT=${CUDAToolkit_ROOT}" "-Doutput_file=${eval_exe}"
"-Dlang=${lang}" "-Dcuda_toolkit=${CUDAToolkit_FOUND}"
"-Dlang=${rapids_lang}" "-Dcuda_toolkit=${CUDAToolkit_FOUND}"
OUTPUT_VARIABLE compile_output)

if(NOT result)
Expand Down
5 changes: 5 additions & 0 deletions testing/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ add_cmake_config_test( cpm_generate_patch_command-override.cmake )
add_cmake_config_test( cpm_generate_patch_command-current_json_dir.cmake )
add_cmake_config_test( cpm_generate_patch_command-verify-copyright-header.cmake )

add_cmake_config_test( cpm_bs_thread_pool-simple.cmake )
add_cmake_config_test( cpm_bs_thread_pool-export.cmake )
add_cmake_build_test( cpm_bs_thread_pool-build-config-works.cmake )
add_cmake_build_test( cpm_bs_thread_pool-install-config-works.cmake )

add_cmake_config_test( cpm_cccl-simple.cmake )
add_cmake_config_test( cpm_cccl-export.cmake )
add_cmake_build_test( cpm_cccl-preserve-custom-install-loc )
Expand Down
40 changes: 40 additions & 0 deletions testing/cpm/cpm_bs_thread_pool-build-config-works.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#=============================================================================
# Copyright (c) 2024, 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.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/bs_thread_pool.cmake)

rapids_cpm_init()
rapids_cpm_bs_thread_pool(BUILD_EXPORT_SET test)

# Add a custom command that verifies that the expect files have
# been installed for each component
file(WRITE "${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir/CMakeLists.txt" "
cmake_minimum_required(VERSION 3.26.4)
project(verify_bs_thread_pool LANGUAGES CXX)
set(CMAKE_PREFIX_PATH \"${CMAKE_BINARY_DIR}/\")
find_package(bs_thread_pool REQUIRED)
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/stub.cpp\" \"#include <BS_thread_pool.hpp>\")
add_library(uses_bs_thread_pool SHARED stub.cpp)
target_link_libraries(uses_bs_thread_pool PRIVATE BS::thread_pool)
")

add_custom_target(verify_build_config ALL
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir/build"
COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir" -B="${CMAKE_BINARY_DIR}/build"
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/build"
)
32 changes: 32 additions & 0 deletions testing/cpm/cpm_bs_thread_pool-export.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#=============================================================================
# Copyright (c) 2023-2024, 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.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/bs_thread_pool.cmake)

rapids_cpm_init()

rapids_cpm_bs_thread_pool(BUILD_EXPORT_SET test)
rapids_cpm_bs_thread_pool(INSTALL_EXPORT_SET test2)

get_target_property(packages rapids_export_build_test PACKAGE_NAMES)
if(NOT bs_thread_pool IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_bs_thread_pool failed to record bs_thread_pool needs to be exported")
endif()

get_target_property(packages rapids_export_install_test2 PACKAGE_NAMES)
if(NOT bs_thread_pool IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_bs_thread_pool failed to record bs_thread_pool needs to be exported")
endif()
41 changes: 41 additions & 0 deletions testing/cpm/cpm_bs_thread_pool-install-config-works.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#=============================================================================
# Copyright (c) 2024, 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.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/bs_thread_pool.cmake)

rapids_cpm_init()
rapids_cpm_bs_thread_pool(BUILD_EXPORT_SET test)

# Add a custom command that verifies that the expect files have
# been installed for each component
file(WRITE "${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir/CMakeLists.txt" "
cmake_minimum_required(VERSION 3.26.4)
project(verify_bs_thread_pool LANGUAGES CXX)
set(CMAKE_PREFIX_PATH \"${CMAKE_BINARY_DIR}/\")
find_package(bs_thread_pool REQUIRED)
file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/stub.cpp\" \"#include <BS_thread_pool.hpp>\")
add_library(uses_bs_thread_pool SHARED stub.cpp)
target_link_libraries(uses_bs_thread_pool PRIVATE BS::thread_pool)
")

add_custom_target(verify_build_config ALL
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --prefix ./install/
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir/build"
COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/check_bs_thread_pool_dir" -B="${CMAKE_BINARY_DIR}/build"
COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/build"
)
Loading

0 comments on commit 023e87e

Please sign in to comment.