Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New rapids and nvbench #529

Merged
merged 3 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20.1)
cmake_minimum_required(VERSION 3.23.1)

# Used for config file generation
if(NOT DEFINED PROJECT_NAME)
Expand Down
2 changes: 1 addition & 1 deletion cmake/GetNVBench.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ function(find_and_configure_nvbench VERSION)
endfunction()

# NVBench doesn't tag yet
set(CUDA_MATX_MIN_VERSION_nvbench "1a13a2e")
set(CUDA_MATX_MIN_VERSION_nvbench "7521229")
find_and_configure_nvbench(${CUDA_MATX_MIN_VERSION_nvbench})
336 changes: 329 additions & 7 deletions cmake/rapids-cmake/CHANGELOG.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cmake/rapids-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-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 @@ -24,8 +24,8 @@
# use rapids-cmake via CPM inside the same global project. In those
# cases it can fail due to CMAKE_MODULE_PREFIX not being exported properly

# Enfore the minimum required CMake version for all users
cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)
# Enforce the minimum required CMake version for all users
cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)

set(rapids-cmake-dir "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake")
if(NOT DEFINED CACHE{rapids-cmake-dir})
Expand Down
6 changes: 3 additions & 3 deletions cmake/rapids-cmake/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ into three categories:

While RAPIDS core provides commonly used scripts we know that they aren't universal and might need to be composed in different ways.

This means that the code we are developing should be designed for composibility, and all side-effects
This means that the code we are developing should be designed for composability, and all side-effects
or CMake behavior changes should be explicitly opt-in.

So when writing new rapids-cmake features make sure to think about how users might want to opt-in, and
Expand Down Expand Up @@ -69,14 +69,14 @@ that don't/can't use `rapids_add_library` to still opt-in to other features.

Please ensure that when you are creating new features you follow the following guidelines:
- Each function should follow the `rapids_<component>_<file_name>` naming pattern
- Each function should go into a separate `.cmake` file in the approiate directory
- Each function should go into a separate `.cmake` file in the appropriate directory
- Each user facing `.cmake` file should have include guards (`include_guard(GLOBAL)`)
- Each user facing `.cmake` file should be documented following the rst structure
- Each user facing function should be added to the `cmake-format.json` document
- Run `cmake-genparsers -f json` on the `.cmake` file as a starting point
- Each function first line should be `list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.<component>.<function>")`
- A file should not modify any state simply by being included. State modification should
only occur inside functions unless absolutely neccessary due to restrctions of the CMake
only occur inside functions unless absolutely necessary due to restrictions of the CMake
language.
- Any files that do need to break this rule can't be part of `rapids-<component>.cmake`.

Expand Down
52 changes: 44 additions & 8 deletions cmake/rapids-cmake/RAPIDS.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-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 @@ -17,13 +17,50 @@
# This is the preferred entry point for projects using rapids-cmake
#

set(rapids-cmake-version 22.10)
# Allow users to control which version is used
if(NOT rapids-cmake-version)
# Define a default version if the user doesn't set one
set(rapids-cmake-version 23.12)
endif()

# Allow users to control which GitHub repo is fetched
if(NOT rapids-cmake-repo)
# Define a default repo if the user doesn't set one
set(rapids-cmake-repo rapidsai/rapids-cmake)
endif()

# Allow users to control which branch is fetched
if(NOT rapids-cmake-branch)
# Define a default branch if the user doesn't set one
set(rapids-cmake-branch "branch-${rapids-cmake-version}")
endif()

# Allow users to control the exact URL passed to FetchContent
if(NOT rapids-cmake-url)
# Construct a default URL if the user doesn't set one
set(rapids-cmake-url "https://github.com/${rapids-cmake-repo}/")
# In order of specificity
if(rapids-cmake-sha)
# An exact git SHA takes precedence over anything
string(APPEND rapids-cmake-url "archive/${rapids-cmake-sha}.zip")
elseif(rapids-cmake-tag)
# Followed by a git tag name
string(APPEND rapids-cmake-url "archive/refs/tags/${rapids-cmake-tag}.zip")
else()
# Or if neither of the above two were defined, use a branch
string(APPEND rapids-cmake-url "archive/refs/heads/${rapids-cmake-branch}.zip")
endif()
endif()

if(POLICY CMP0135)
cmake_policy(PUSH)
cmake_policy(SET CMP0135 NEW)
endif()
include(FetchContent)
FetchContent_Declare(
rapids-cmake
GIT_REPOSITORY https://github.com/rapidsai/rapids-cmake.git
GIT_TAG branch-${rapids-cmake-version}
)
FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}")
if(POLICY CMP0135)
cmake_policy(POP)
endif()
FetchContent_GetProperties(rapids-cmake)
if(rapids-cmake_POPULATED)
# Something else has already populated rapids-cmake, only thing
Expand All @@ -34,4 +71,3 @@ if(rapids-cmake_POPULATED)
else()
FetchContent_MakeAvailable(rapids-cmake)
endif()

61 changes: 44 additions & 17 deletions cmake/rapids-cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ Content](https://cmake.org/cmake/help/latest/module/FetchContent.html) into your

cmake_minimum_required(...)

file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-<VERSION_MAJOR>.<VERSION_MINOR>/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/<PROJECT>_RAPIDS.cmake)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-<VERSION_MAJOR>.<VERSION_MINOR>/RAPIDS.cmake
${CMAKE_CURRENT_BINARY_DIR}/<PROJECT>_RAPIDS.cmake)
endif()
include(${CMAKE_CURRENT_BINARY_DIR}/<PROJECT>_RAPIDS.cmake)

include(rapids-cmake)
include(rapids-cpm)
Expand Down Expand Up @@ -66,7 +68,7 @@ The `rapids-cmake` module contains helpful general CMake functionality
The `rapids-cpm` module contains CPM functionality to allow projects to acquire dependencies consistently.
For consistentcy All targets brought in via `rapids-cpm` are GLOBAL targets.

- `raipds_cpm_init()` handles initialization of the CPM module.
- `rapids_cpm_init()` handles initialization of the CPM module.
- `raipds_cpm_find(<project> name BUILD_EXPORT_SET <name> INSTALL_EXPORT_SET <name>)` Will search for a module and fall back to installing via CPM. Offers support to track dependencies for easy package exporting

### cuda
Expand All @@ -76,6 +78,7 @@ The most commonly used function are:

- `rapids_cuda_init_architectures(<project_name>)` handles initialization of `CMAKE_CUDA_ARCHITECTURE`. MUST BE CALLED BEFORE `PROJECT()`
- `rapids_cuda_init_runtime(<mode>)` handles initialization of `CMAKE_CUDA_RUNTIME_LIBRARY`.
- `rapids_cuda_patch_toolkit()` corrects bugs in the CUDAToolkit module that are being upstreamed.

### cython

Expand Down Expand Up @@ -105,26 +108,50 @@ The most commonly used function are:
- `rapids_find_package(<project_name> BUILD_EXPORT_SET <name> INSTALL_EXPORT_SET <name> )` Combines `find_package` and support to track dependencies for easy package exporting
- `rapids_generate_module(<PackageName> HEADER_NAMES <paths...> LIBRARY_NAMES <names...> )` Generate a FindModule for the given package. Allows association to export sets so the generated FindModule can be shipped with the project

### test

The `rapids_test` functions simplify CTest resource allocation, allowing for
tests to run in parallel without overallocating GPU resources.

The most commonly used functions are:
- `rapids_test_add(NAME <test_name> GPUS <N> PERCENT <N>)`: State how many GPU resources a single
test requires


## Overriding RAPIDS.cmake

At times projects or developers will need to verify ``rapids-cmake`` branches. To do this you need to override the default git repositry and branch that ``RAPIDS.cmake`` downloads, which should be done
like this:
At times projects or developers will need to verify ``rapids-cmake`` branches. To do this you can set variables that control which repository ``RAPIDS.cmake`` downloads, which should be done like this:

```cmake
# To override the version that is pulled:
set(rapids-cmake-version "<version>")

# To override the GitHub repository:
set(rapids-cmake-repo "<my_fork>")

include(FetchContent)
FetchContent_Declare(
rapids-cmake
GIT_REPOSITORY https://github.com/<my_fork>/rapids-cmake.git
GIT_TAG <my_feature_branch>
)
file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-21.12/RAPIDS.cmake
${CMAKE_BINARY_DIR}/RAPIDS.cmake)
include(${CMAKE_BINARY_DIR}/RAPIDS.cmake)
# To use an exact Git SHA:
set(rapids-cmake-sha "<my_git_sha>")

# To use a Git tag:
set(rapids-cmake-tag "<my_git_tag>")

# To override the repository branch:
set(rapids-cmake-branch "<my_feature_branch>")

# Or to override the entire repository URL (e.g. to use a GitLab repo):
set(rapids-cmake-url "https://gitlab.com/<my_user>/<my_fork>/-/archive/<my_branch>/<my_fork>-<my_branch>.zip")

file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.10/RAPIDS.cmake
${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/RAPIDS.cmake)
```

This tells ``FetchContent`` to ignore the explicit url and branch in ``RAPIDS.cmake`` and use the
ones provided.
A few notes:

- An explicitly defined ``rapids-cmake-url`` will always be used
- `rapids-cmake-sha` takes precedence over `rapids-cmake-tag`
- `rapids-cmake-tag` takes precedence over `rapids-cmake-branch`
- It is advised to always set `rapids-cmake-version` to the version expected by the repo your modifications will pull

## Contributing

Expand Down
21 changes: 21 additions & 0 deletions cmake/rapids-cmake/ci/check_style.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Copyright (c) 2020-2023, NVIDIA CORPORATION.

set -euo pipefail

rapids-logger "Create checks conda environment"
. /opt/conda/etc/profile.d/conda.sh

rapids-dependency-file-generator \
--output conda \
--file_key checks \
--matrix "cuda=${RAPIDS_CUDA_VERSION%.*};arch=$(arch);py=${RAPIDS_PY_VERSION}" | tee env.yaml

rapids-mamba-retry env create --force -f env.yaml -n checks

set +u
conda activate checks
set -u

# Run pre-commit checks
pre-commit run --all-files --show-diff-on-failure
Loading