-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example cmake project #177
Merged
Merged
Changes from all commits
Commits
Show all changes
90 commits
Select commit
Hold shift + click to select a range
c0afe64
Add initial skeleton for example cmake project.
jrhemstad a53d032
Add support for nvcc-specific matrix.
jrhemstad 663e2f4
Remove errnoeous runs-on
jrhemstad 9405359
Fix path to compute-matrix script.
jrhemstad be00cb2
debug
jrhemstad 18debe3
debug.
jrhemstad 677b8fc
debug.
jrhemstad ee821cc
lol, use hyphen not underscore.
jrhemstad 597cbc2
Get absolute path for matrix file.
jrhemstad ba3af68
Fix reference to matrix_file var.
jrhemstad fdf757b
Remove extraneous matrix_query
jrhemstad 42c4f6f
Use composite action instead of reusable workflow for matrix.
jrhemstad 2cb5703
Fix quotes around composite action inputs.
jrhemstad c61c78f
Need to checkout repo to get local composite action.
jrhemstad 52de697
Fix quotes.
jrhemstad ed72001
Add shell to composite action.
jrhemstad a6df874
Specify shell in step.
jrhemstad 661935f
Correctly use inputs for composite action.
jrhemstad 7205c23
debug
jrhemstad c098fed
Fix expansion.
jrhemstad 214537d
Remove debug.
jrhemstad 95dfcc9
Remove debug.
jrhemstad 189645c
Fix indention.
alliepiper 64a476f
Add CCCL::CCCL, CCCL::libcudacxx, CCCL::CUB, and CCCL::Thrust targets.
alliepiper 5d420e8
Merge remote-tracking branch 'origin' into example-cmake-project
jrhemstad b1ad055
Merge branch 'new_cccl_cmake_targets' into example-cmake-project
jrhemstad aae51ad
(Not working) Update to use new targets.
jrhemstad 4b4efc0
Make CPM point to the PR branch instead.
jrhemstad bcaef1d
Escape quotes in jq query string.
jrhemstad 9822778
Use underscore instead of hyphen to avoid needing quotes in query.
jrhemstad c194bfd
Use alternative syntax for jq query.
jrhemstad 8d09b5c
Missing quote.
jrhemstad 27f0e79
Add post processing to set nvcc-specific matrix outputs.
jrhemstad b7e0fa6
Quotes around matrix output.
jrhemstad 100bdb7
Single quotes.
jrhemstad 2a36423
Make CCCL::CCCL target GLOBAL.
4cd2f80
Remove old compute-matrix reusable workflow.
jrhemstad 1cd1581
Fix usage message.
jrhemstad e32fce7
Update devcontainer script to reference nvcc field.
jrhemstad 705207c
Removed unused GITHUB_OUTPUT var.
jrhemstad 468bab7
EOF
jrhemstad dda1646
Fix quotes.
jrhemstad 0aed220
Add more complete example file.
jrhemstad 4a25011
Add top level cmake file for building/running all the examples.
jrhemstad 8d8aa2a
Merge branch 'example-cmake-project' into examples-job
jrhemstad 39e1287
Enable examples to run via CI.
alliepiper d333ffe
Add missing newlines.
alliepiper 3850f15
Enable overriding CPM source for CI.
jrhemstad 0451167
Add top level job for running examples.
jrhemstad 347d55a
Add devcontainer_version field to matrix file.
jrhemstad f7aa4ea
Update make_devcontainers script to read devcontainer_version.
jrhemstad f29bcb7
Add job to get devcontainer_version and pass to dependent jobs.
jrhemstad a4d19a6
Add and use input for devcontainer_version.
jrhemstad 9075ea1
Avoid unnecessarily using compute-matrix action.
jrhemstad ee65f91
Use yaml alias/anchor for cuda versions.
jrhemstad 9919681
[skip tests] Update devcontainer version job name.
jrhemstad 1d085dc
Update to CUDA 12.2 and devcontainer 23.08.
jrhemstad 2ee384c
Update devcontainer.json image versions and update to CUDA 12.2.
jrhemstad 1484da0
Add more docs.
jrhemstad 1a20d54
Merge branch 'main' into update-devcontainer-version
jrhemstad 7d1d86f
Merge branch 'example-cmake-project' into examples-job
jrhemstad d054fe6
Merge branch 'main' into example-cmake-project
jrhemstad 19a6ddb
Merge branch 'example-cmake-project' into examples-job
jrhemstad fbd9317
Merge branch 'update-devcontainer-version' into examples-job
jrhemstad 67492f4
Mark the CCCL::Thrust options as advanced.
alliepiper 55790dc
Guard against rebuilding pre-existing targets.
alliepiper 1dec47f
Make the imported `CCCL::CCCL` target global in our CMake package.
alliepiper 5ff3be0
Merge branch 'new_cccl_cmake_targets' into example-cmake-project
jrhemstad 7313db4
Include cmake/CCCLUtilities
jrhemstad ce955dc
Don't use magic number.
jrhemstad 0f1486d
Merge branch 'main' into example-cmake-project
jrhemstad aa20ba1
Update CPM to point to cccl/main.
jrhemstad 24919f3
Update README.
jrhemstad b579747
Add some more comments to the cmakelists.txt.
jrhemstad 03fa106
Update examples/README
jrhemstad ee32c9a
Merge branch 'examples-job' into example-cmake-project
jrhemstad 1ee5f31
Get devcontainer version from prior job.
jrhemstad 35f562b
Hard code example job to only build/run example_project.
jrhemstad b1d71c8
Set error handling options in run-as-coder shell.
jrhemstad c493a73
Add license.
jrhemstad e13cc7e
Fix spacing.
jrhemstad 6b4fcfd
Add license headers.
jrhemstad 4542b0e
[skip-tests]
jrhemstad 3e7b7f5
Remove accidental submodule?
jrhemstad 58fc9c2
Split cccl tests from examples in naming schemes.
alliepiper 60ddebf
Remove unnecessary include.
alliepiper bd0425f
Add options to allow configuration of example CPM repo.
alliepiper a629a33
Add CMakePresets.txt.json with recipe for testing examples.
alliepiper 33ef7b0
Update PR workflow to run examples using presets and new options.
alliepiper 0e51c5d
Specify the CUDA compiler for the example config step.
alliepiper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"version": 3, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 21, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "base", | ||
"hidden": true, | ||
"generator": "Ninja", | ||
"binaryDir": "${sourceDir}/build/${presetName}", | ||
"cacheVariables": { | ||
"CCCL_ENABLE_LIBCUDACXX": false, | ||
"CCCL_ENABLE_CUB": false, | ||
"CCCL_ENABLE_THRUST": false, | ||
"CCCL_ENABLE_TESTING": false, | ||
"CCCL_ENABLE_EXAMPLES": false | ||
} | ||
}, | ||
{ | ||
"name": "examples", | ||
"displayName": "CCCL Examples", | ||
"description": "Configure, build, and run the CCCL Examples", | ||
"inherits": "base", | ||
"cacheVariables": { | ||
"CMAKE_CUDA_ARCHITECTURES": "70", | ||
"CCCL_ENABLE_EXAMPLES": true | ||
} | ||
} | ||
], | ||
"testPresets": [ | ||
{ | ||
"name": "base", | ||
"hidden": true, | ||
"output": { | ||
"outputOnFailure": true | ||
}, | ||
"execution": { | ||
"noTestsAction": "error", | ||
"stopOnFailure": false | ||
} | ||
}, | ||
{ | ||
"name": "examples", | ||
"configurePreset": "examples", | ||
"inherits": "base", | ||
"filter":{ | ||
"include": { | ||
"name": "^cccl\\.example\\." | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# 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. | ||
|
||
|
||
# Add a build-and-test CTest. | ||
# - full_test_name_var will be set to the full name of the test. | ||
# - name_prefix is the prefix of the test's name (e.g. `cccl.test.cmake`) | ||
# - subdir is the relative path to the test project directory. | ||
# - test_id is used to generate a unique name for this test, allowing the | ||
# subdir to be reused. | ||
# - Any additional args will be passed to the project configure step. | ||
function(cccl_add_compile_test full_test_name_var name_prefix subdir test_id) | ||
set(test_name ${name_prefix}.${subdir}.${test_id}) | ||
set(src_dir "${CMAKE_CURRENT_SOURCE_DIR}/${subdir}") | ||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${subdir}/${test_id}") | ||
add_test(NAME ${test_name} | ||
COMMAND "${CMAKE_CTEST_COMMAND}" | ||
--build-and-test "${src_dir}" "${build_dir}" | ||
--build-generator "${CMAKE_GENERATOR}" | ||
--build-options | ||
${ARGN} | ||
--test-command "${CMAKE_CTEST_COMMAND}" --output-on-failure | ||
) | ||
set(${full_test_name_var} ${test_name} PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# 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. | ||
|
||
set(cmake_opts | ||
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" | ||
-D "CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}" | ||
-D "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" | ||
-D "CMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}" | ||
-D "CMAKE_CUDA_HOST_COMPILER=${CMAKE_CUDA_HOST_COMPILER}" | ||
-D "CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES}" | ||
) | ||
|
||
set(CCCL_EXAMPLE_CPM_REPOSITORY "nvidia/cccl" CACHE STRING "GitHub repository used for CPM examples.") | ||
set(CCCL_EXAMPLE_CPM_TAG "main" CACHE STRING "Git tag/branch used for CPM examples.") | ||
|
||
set(cmake_cpm_opts | ||
-D "CCCL_REPOSITORY=${CCCL_EXAMPLE_CPM_REPOSITORY}" | ||
-D "CCCL_TAG=${CCCL_EXAMPLE_CPM_TAG}" | ||
) | ||
|
||
cccl_add_compile_test(test_name | ||
cccl.example | ||
example_project | ||
"default" | ||
${cmake_opts} | ||
${cmake_cpm_opts} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
This directory contains examples of how to use CCCL in your project. | ||
|
||
See the `README.md` in each subdirectory for more information. | ||
|
||
To build and run only the examples, run the following commands from the root directory of the repository: | ||
|
||
```bash | ||
cmake -S . -B build -DCCCL_ENABLE_EXAMPLES=ON -DCCCL_ENABLE_THRUST=OFF -DCCCL_ENABLE_CUB=OFF -DCCCL_ENABLE_LIBCUDACXX=OFF -DCCCL_ENABLE_TESTING=OFF | ||
cmake --build build | ||
ctest --test-dir build --output-on-failure | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR) | ||
|
||
project(CCCLDemo CUDA) | ||
|
||
# This example uses the CMake Package Manager (CPM) to simplify fetching CCCL from GitHub | ||
# For more information, see https://github.com/cpm-cmake/CPM.cmake | ||
include(cmake/CPM.cmake) | ||
|
||
|
||
# We define these as variables so they can be overriden in CI to pull from a PR instead of CCCL `main` | ||
# In your project, these variables are unncessary and you can just use the values directly | ||
set(CCCL_REPOSITORY "nvidia/cccl" CACHE STRING "GitHub repository to fetch CCCL from") | ||
set(CCCL_TAG "main" CACHE STRING "Git tag/branch to fetch from CCCL repository") | ||
|
||
# This will automatically clone CCCL from GitHub and make the exported cmake targets available | ||
CPMAddPackage( | ||
NAME CCCL | ||
GITHUB_REPOSITORY ${CCCL_REPOSITORY} | ||
GIT_TAG ${CCCL_TAG} | ||
) | ||
|
||
# Default to building for the GPU on the current system | ||
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) | ||
set(CMAKE_CUDA_ARCHITECTURES native) | ||
endif() | ||
|
||
# Creates a cmake executable target for the main program | ||
add_executable(example_project example.cu) | ||
|
||
# "Links" the CCCL Cmake target to the `example_project` executable. This configures everything needed to use | ||
# CCCL headers, including setting up include paths, compiler flags, etc. | ||
target_link_libraries(example_project PRIVATE CCCL::CCCL) | ||
|
||
# This is only relevant for internal testing and not needed by end users. | ||
include(CTest) | ||
enable_testing() | ||
add_test(NAME example_project COMMAND example_project) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allisonvacanti Can this be overriden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep -- this can be overridden by either passing
-DCMAKE_CUDA_ARCHITECTURES
to cmake (in addition to--preset
), or modifying the config with ccmake/cmake-gui.I only added it because the example uses libcu++ atomics, so the default arch (5.2) will throw errors for being too old. If the example avoided atomics we could drop this completely.