Skip to content

Commit

Permalink
Merge branch 'branch-23.04' into fea/rapids-cmake-test
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Feb 27, 2023
2 parents f94bc35 + 6dceaa9 commit 611f4c0
Show file tree
Hide file tree
Showing 16 changed files with 370 additions and 44 deletions.
5 changes: 3 additions & 2 deletions ci/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ popd


if [[ ${RAPIDS_BUILD_TYPE} == "branch" ]]; then
aws s3 sync --delete docs/_html "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/html"
aws s3 sync --delete docs/_text "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/txt"
rapids-logger "Upload Docs to S3"
aws s3 sync --no-progress --delete docs/_html "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/html"
aws s3 sync --no-progress --delete docs/_text "s3://rapidsai-docs/rapids-cmake/${VERSION_NUMBER}/txt"
fi
1 change: 1 addition & 0 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ dependencies:
cuda: "11.4"
packages:
- cudatoolkit=11.4
- gcc<11.0.0
- sysroot_linux-64==2.17
- matrix:
cuda: "11.5"
Expand Down
2 changes: 2 additions & 0 deletions docs/packages/rapids_cpm_versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ as needed.
Supports the following placeholders:
- ``${rapids-cmake-version}`` will be evaluated to 'major.minor' of the current rapids-cmake cal-ver value.
- ``${version}`` will be evaluated to the contents of the ``version`` field.
- ``${cuda-toolkit-version}`` will be evaluated to 'major.minor' of the current CUDA Toolkit version.
- ``${cuda-toolkit-version-major}`` will be evaluated to 'major' of the current CUDA Toolkit version.

If this field exists in the default package, the value will be ignored when an override file
entry exists for the package. This ensures that the git url or `proprietary_binary` entry in the override will be used.
Expand Down
46 changes: 46 additions & 0 deletions rapids-cmake/cpm/detail/download_proprietary_binary.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#=============================================================================
# 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.
#=============================================================================
include_guard(GLOBAL)

#[=======================================================================[.rst:
download_proprietary_binary
-------------------
.. versionadded:: v23.04.00
Download the associated proprietary binary from the providied URL and make
it part of the project with `FetchContent_MakeAvailable`
#]=======================================================================]
function(rapids_cpm_download_proprietary_binary package_name url)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_download_proprietary_binary")

# download and extract the binaries since they don't exist on the machine
include(FetchContent)
set(pkg_name "${package_name}_proprietary_binary")

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()

FetchContent_Declare(${pkg_name} URL ${url})
FetchContent_MakeAvailable(${pkg_name})

# Tell the subsequent rapids_cpm_find where to search so that it uses this binary
set(${package_name}_ROOT "${${pkg_name}_SOURCE_DIR}" PARENT_SCOPE)
set(${package_name}_proprietary_binary ON PARENT_SCOPE)
endfunction()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2022, NVIDIA CORPORATION.
# 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.
Expand All @@ -16,22 +16,21 @@
include_guard(GLOBAL)

#[=======================================================================[.rst:
get_proprietary_binary
rapids_cpm_get_proprietary_binary_url
-------------------
.. versionadded:: v22.06.00
.. versionadded:: v23.04.00
Download the associated proprietary binary for the given project based on
the current CPU target architecture ( x86_64, aarch64, etc )
Generated the url for the associated proprietary binary for the given project based
on the current CPU target architecture ( x86_64, aarch64, etc )
.. note::
if override => the proprietary entry only in the override will be evaluated
if no override => the proprietary entry only in the default will be evaluated
#]=======================================================================]
function(rapids_cpm_get_proprietary_binary package_name version)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_get_proprietary_binary")
function(rapids_cpm_get_proprietary_binary_url package_name version url_var)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_get_proprietary_binary_url")

include("${rapids-cmake-dir}/cpm/detail/get_default_json.cmake")
include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake")
Expand Down Expand Up @@ -61,25 +60,18 @@ function(rapids_cpm_get_proprietary_binary package_name version)
include("${rapids-cmake-dir}/rapids-version.cmake")
endif()

# Determine the CUDA Toolkit version so that we properly evaluate the placeholders in
# `proprietary_binary`
if(proprietary_binary MATCHES "{cuda-toolkit-version")
find_package(CUDAToolkit REQUIRED)
set(cuda-toolkit-version ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR})
set(cuda-toolkit-version-major ${CUDAToolkit_VERSION_MAJOR})
endif()

# Evaluate any magic placeholders in the proprietary_binary value including the
# `rapids-cmake-version` value
cmake_language(EVAL CODE "set(proprietary_binary ${proprietary_binary})")

if(proprietary_binary)
# download and extract the binaries since they don't exist on the machine
include(FetchContent)
set(pkg_name "${package_name}_proprietary_binary")

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0135 NEW)
endif()

FetchContent_Declare(${pkg_name} URL ${proprietary_binary})
FetchContent_MakeAvailable(${pkg_name})

# Tell the subsequent rapids_cpm_find where to search so that it uses this binary
set(${package_name}_ROOT "${${pkg_name}_SOURCE_DIR}" PARENT_SCOPE)
set(${package_name}_proprietary_binary ON PARENT_SCOPE)
endif()
# Tell the caller what the URL will be for this binary
set(${url_var} "${proprietary_binary}" PARENT_SCOPE)
endfunction()
8 changes: 6 additions & 2 deletions rapids-cmake/cpm/nvcomp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ function(rapids_cpm_nvcomp)
# first see if we have a proprietary pre-built binary listed in versions.json and it if requested.
set(nvcomp_proprietary_binary OFF) # will be set to true by rapids_cpm_get_proprietary_binary
if(_RAPIDS_USE_PROPRIETARY_BINARY)
include("${rapids-cmake-dir}/cpm/detail/get_proprietary_binary.cmake")
rapids_cpm_get_proprietary_binary(nvcomp ${version})
include("${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake")
include("${rapids-cmake-dir}/cpm/detail/download_proprietary_binary.cmake")
rapids_cpm_get_proprietary_binary_url(nvcomp ${version} nvcomp_url)
if(nvcomp_url)
rapids_cpm_download_proprietary_binary(nvcomp ${nvcomp_url})
endif()

# Record the nvcomp_DIR so that if USE_PROPRIETARY_BINARY is disabled we can safely clear the
# nvcomp_DIR value
Expand Down
31 changes: 31 additions & 0 deletions rapids-cmake/cpm/patches/nvbench/public_fmt_dep_in_conda.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
diff --git a/nvbench/CMakeLists.txt b/nvbench/CMakeLists.txt
index f86bd41..ba6418f 100644
--- a/nvbench/CMakeLists.txt
+++ b/nvbench/CMakeLists.txt
@@ -76,10 +76,25 @@ target_link_libraries(nvbench
PUBLIC
${ctk_libraries}
PRIVATE
- fmt::fmt
nvbench_json
nvbench_git_revision
)
+
+# ##################################################################################################
+# * conda environment -----------------------------------------------------------------------------
+rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH)
+if(TARGET conda_env)
+ # When we are inside a conda env the linker will be set to
+ # `ld.bfd` which will try to resolve all undefined symbols at link time.
+ #
+ # Since we could be using a shared library version of fmt we need
+ # it on the final link line of consumers
+ target_link_libraries(nvbench PRIVATE $<BUILD_INTERFACE:conda_env>
+ PUBLIC fmt::fmt)
+else()
+ target_link_libraries(nvbench PRIVATE fmt::fmt)
+endif()
+
target_compile_features(nvbench PUBLIC cuda_std_17 PRIVATE cxx_std_17)
add_dependencies(nvbench.all nvbench)

28 changes: 14 additions & 14 deletions rapids-cmake/cpm/spdlog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,27 @@ function(rapids_cpm_spdlog)

if(_RAPIDS_FMT_OPTION STREQUAL "BUNDLED")
set(spdlog_fmt_option "")
elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT" OR _RAPIDS_FMT_OPTION STREQUAL
"EXTERNAL_FMT_HO")
elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT")
set(spdlog_fmt_option "SPDLOG_FMT_EXTERNAL ON")
set(spdlog_fmt_target fmt::fmt)
elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT_HO")
set(spdlog_fmt_option "SPDLOG_FMT_EXTERNAL_HO ON")
set(spdlog_fmt_target fmt::fmt-header-only)
elseif(_RAPIDS_FMT_OPTION STREQUAL "STD_FORMAT")
set(spdlog_fmt_option "SPDLOG_USE_STD_FORMAT ON")
else()
message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO', 'STD_FORMAT'"
)
endif()

if(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT" OR _RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT_HO")
include("${rapids-cmake-dir}/cpm/fmt.cmake")

# Using `spdlog_ROOT` needs to cause any internal find calls in `spdlog-config.cmake` to first
# search beside it before looking globally.
list(APPEND fmt_ROOT ${spdlog_ROOT})

rapids_cpm_fmt(${_RAPIDS_UNPARSED_ARGUMENTS})

set(spdlog_fmt_option "SPDLOG_${_RAPIDS_FMT_OPTION} ON")
if(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT")
set(spdlog_fmt_target fmt::fmt)
elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT_HO")
set(spdlog_fmt_target fmt::fmt-header-only)
endif()
elseif(_RAPIDS_FMT_OPTION STREQUAL "STD_FORMAT")
set(spdlog_fmt_option "SPDLOG_USE_${_RAPIDS_FMT_OPTION} ON")
else()
message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO', 'STD_FORMAT'"
)
endif()

include("${rapids-cmake-dir}/cpm/find.cmake")
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 @@ -37,6 +37,11 @@
"file" : "nvbench/use_existing_fmt.diff",
"issue" : "Fix add support for using an existing fmt [https://github.com/NVIDIA/nvbench/pull/125]",
"fixed_in" : ""
},
{
"file" : "nvbench/public_fmt_dep_in_conda.diff",
"issue" : "Propagate fmt requirement in conda envs [https://github.com/NVIDIA/nvbench/pull/127]",
"fixed_in" : ""
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions testing/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ add_cmake_config_test( cpm_libcudacxx-simple.cmake )
add_cmake_config_test( cpm_nvbench-export.cmake )
add_cmake_config_test( cpm_nvbench-simple.cmake )
add_cmake_config_test( cpm_nvbench-already-found-fmt.cmake )
add_cmake_build_test( cpm_nvbench-conda-fmt.cmake )

add_cmake_config_test( cpm_nvcomp-export.cmake )
add_cmake_config_test( cpm_nvcomp-proprietary-off.cmake )
Expand All @@ -71,9 +72,14 @@ add_cmake_config_test( cpm_nvcomp-simple.cmake )
add_cmake_config_test( cpm_nvcomp-invalid-arch.cmake )
add_cmake_config_test( cpm_nvcomp-override-clears-proprietary_binary.cmake )

add_cmake_config_test( cpm_proprietary-url-ctk-version-find-ctk.cmake )
add_cmake_config_test( cpm_proprietary-url-ctk-version.cmake )
add_cmake_config_test( cpm_proprietary-url-no-ctk-parsing.cmake )

add_cmake_config_test( cpm_rmm-export.cmake )
add_cmake_config_test( cpm_rmm-simple.cmake )

add_cmake_build_test( cpm_spdlog-external-fmt.cmake )
add_cmake_config_test( cpm_spdlog-export.cmake )
add_cmake_config_test( cpm_spdlog-simple.cmake )

Expand Down
55 changes: 55 additions & 0 deletions testing/cpm/cpm_nvbench-conda-fmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#=============================================================================
# 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.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/rmm.cmake)
include(${rapids-cmake-dir}/cpm/nvbench.cmake)

enable_language(CUDA)
enable_language(CXX)

include(${rapids-cmake-dir}/cuda/set_architectures.cmake)
rapids_cuda_set_architectures(RAPIDS)

# Force shared libs so that nvbench doesn't have a chance to use a static fmt
set(BUILD_SHARED_LIBS ON)
set(NVBench_ENABLE_CUPTI OFF)
rapids_cpm_init()
rapids_cpm_rmm()
rapids_cpm_nvbench()

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/use_fmt.cpp" [=[
#include <spdlog/spdlog.h>
#include <nvbench/nvbench.cuh>

template <typename Type>
void nvbench_distinct(nvbench::state& state, nvbench::type_list<Type>)
{
}

using data_type = nvbench::type_list<bool, int8_t, int32_t, int64_t, float>;

NVBENCH_BENCH_TYPES(nvbench_distinct, NVBENCH_TYPE_AXES(data_type))
.set_name("distinct")
.set_type_axes_names({"Type"})
.add_int64_axis("NumRows", {10'000, 100'000, 1'000'000, 10'000'000});

int main() { return 0; }
]=])


add_library(uses_fmt SHARED "${CMAKE_CURRENT_BINARY_DIR}/use_fmt.cpp")
target_link_libraries(uses_fmt PRIVATE rmm::rmm nvbench::nvbench)
target_compile_features(uses_fmt PRIVATE cxx_std_17)
50 changes: 50 additions & 0 deletions testing/cpm/cpm_proprietary-url-ctk-version-find-ctk.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#=============================================================================
# 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.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/package_override.cmake)
include(${rapids-cmake-dir}/cpm/detail/get_proprietary_binary_url.cmake)
include(${rapids-cmake-dir}/cpm/detail/package_details.cmake)

rapids_cpm_init()

# Need to write out an override file with a proprietary blob url
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json
[=[
{
"packages" : {
"test_binary" : {
"version" : "2.6.1",
"proprietary_binary" : {
"x86_64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/x86_64_${cuda-toolkit-version-major}.tgz",
"aarch64-linux" : "https://fake.url.com/${version}/${cuda-toolkit-version}/aarch64_${cuda-toolkit-version-major}.tgz",
}
}
}
}
]=])
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json)

# Verify that the placeholders are evaluated correctly from `enable_language(CUDA)`
rapids_cpm_package_details(test_binary version repository tag shallow exclude)
rapids_cpm_get_proprietary_binary_url(test_binary ${version} url)

find_package(CUDAToolkit)
set(CTK_VER ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR})
set(CTK_VER_M ${CUDAToolkit_VERSION_MAJOR})
set(valid_url "https://fake.url.com/2.6.1/${CTK_VER}/${CMAKE_SYSTEM_PROCESSOR}_${CTK_VER_M}.tgz")
if(NOT valid_url STREQUAL url)
message(FATAL_ERROR "Expected: ${valid_url} got: ${url}")
endif()
Loading

0 comments on commit 611f4c0

Please sign in to comment.