Skip to content

Latest commit

 

History

History
165 lines (110 loc) · 6.93 KB

CONTRIBUTING.md

File metadata and controls

165 lines (110 loc) · 6.93 KB

Contributing to CCCL

Thank you for your interest in contributing to the CUDA C++ Core Libraries (CCCL)!

Getting Started

  1. Fork & Clone the Repository:

    Fork the CCCL GitHub Repository and clone the fork. For more information, check GitHub's documentation on forking and cloning a repository.

  2. Set up Development Environment:

    CCCL uses Development Containers to provide a consistent development environment for both local development and CI. Contributors are strongly encouraged to use these containers as they simplify environment setup. See the Dev Containers guide for instructions on how to quickly get up and running using dev containers with or without VSCode.

Making Changes

  1. Create a New Branch:

    git checkout -b your-feature-branch
  2. Make Changes.

  3. Build and Test:

    Ensure changes don't break existing functionality by building and running tests.

    ./ci/build_[thrust|cub|libcudacxx].sh -cxx <HOST_COMPILER> -std <CXX_STANDARD> -arch <GPU_ARCHS>
    ./ci/test_[thrust|cub|libcudacxx].sh  -cxx <HOST_COMPILER> -std <CXX_STANDARD> -arch <GPU_ARCHS>

    For more details on building and testing, refer to the Building and Testing section below.

  4. Commit Changes:

    git commit -m "Brief description of the change"

Developer Guides

For more information about design and development practices for each CCCL component, refer to the following developer guides:

CUB

Thrust

Coming soon!

libcudacxx

Coming soon!

Building and Testing

CCCL components are header-only libraries. This means there isn't a traditional build process for the library itself. However, before submitting contributions, it's a good idea to build and run tests. Dedicated build and test scripts for each component are provided in the ci/ directory.

Building

Use the build scripts provided in the ci/ directory to build tests for each component. Building tests does not require a GPU.

   ci/build_[thrust|cub|libcudacxx].sh -cxx <HOST_COMPILER> -std <CXX_STANDARD> -arch <GPU_ARCHS>

- **HOST_COMPILER**: The desired host compiler (e.g., `g++`, `clang++`).
- **CXX_STANDARD**: The C++ standard version (e.g., `11`, `14`, `17`, `20`).
- **GPU_ARCHS**: A semicolon-separated list of CUDA GPU architectures (e.g., `"70;85;90"`). This uses the same syntax as CMake's [CUDA_ARCHITECTURES](https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html#prop_tgt:CUDA_ARCHITECTURES):
   - `70` - both PTX and SASS
   - `70-real` - SASS only
   - `70-virtual` - PTX only

**Example:**
```bash
./ci/build_cub.sh -cxx g++ -std 14 -arch "70;75;80-virtual"

Testing

Use the test scripts provided in the ci/ directory to run tests for each component. These take the same arguments as the build scripts and will automatically build the tests if they haven't already been built. Running tests requires a GPU.

   ci/test_[thrust|cub|libcudacxx].sh -cxx <HOST_COMPILER> -std <CXX_STANDARD> -arch <GPU_ARCHS>

Example:

./ci/test_cub.sh -cxx g++ -std 14 -arch "70;75;80-virtual"

Creating a Pull Request

  1. Push changes to your fork
  2. Create a pull request targeting the main branch of the original CCCL repository. Refer to GitHub's documentation for more information on creating a pull request.
  3. Describe the purpose and context of the changes in the pull request description.

Code Formatting (pre-commit hooks)

CCCL uses pre-commit to execute all code linters and formatters. These tools ensure a consistent coding style throughout the project. Using pre-commit ensures that linter versions and options are aligned for all developers. Additionally, there is a CI check in place to enforce that committed code follows our standards.

The linters used by CCCL are listed in .pre-commit-config.yaml. For example, C++ and CUDA code is formatted with clang-format.

To use pre-commit, install via conda or pip:

conda config --add channels conda-forge
conda install pre-commit
pip install pre-commit

Then run pre-commit hooks before committing code:

pre-commit run

By default, pre-commit runs on staged files (only changes and additions that will be committed). To run pre-commit checks on all files, execute:

pre-commit run --all-files

Optionally, you may set up the pre-commit hooks to run automatically when you make a git commit. This can be done by running:

pre-commit install

Now code linters and formatters will be run each time you commit changes.

You can skip these checks with git commit --no-verify or with the short version git commit -n.

Continuous Integration (CI)

CCCL's CI pipeline tests across various CUDA versions, compilers, and GPU architectures. For external contributors, the CI pipeline will not begin until a maintainer leaves an /ok to test comment. For members of the NVIDIA GitHub enterprise, the CI pipeline will begin immediately. For a detailed overview of CCCL's CI, see ci-overview.md.

There is a CI check for pre-commit, called pre-commit.ci. This enforces that all linters (such as clang-format) pass. If pre-commit.ci is failing, you can comment pre-commit.ci autofix on a pull request to trigger the auto-fixer. The auto-fixer will push a commit to your pull request that applies changes made by pre-commit hooks.

Review Process

Once submitted, maintainers will be automatically assigned to review the pull request. They might suggest changes or improvements. Constructive feedback is a part of the collaborative process, aimed at ensuring the highest quality code.

For constructive feedback and effective communication during reviews, we recommend following Conventional Comments.

Further recommended reading for successful PR reviews:

Thank You!

Your contributions enhance CCCL for the entire community. We appreciate your effort and collaboration!