cudawrappers

C++ wrapper for the Nvidia/HIP C libraries (e.g. CUDA driver, nvrtc, hiprtc, cuFFT, hipFFT, etc.)

https://github.com/nlesc-recruit/cudawrappers

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.2%) to scientific vocabulary

Keywords

accelerator amd cpp cuda driver-api gpu gpu-computing hip library nvidia rocm
Last synced: 4 months ago · JSON representation ·

Repository

C++ wrapper for the Nvidia/HIP C libraries (e.g. CUDA driver, nvrtc, hiprtc, cuFFT, hipFFT, etc.)

Basic Info
Statistics
  • Stars: 7
  • Watchers: 1
  • Forks: 6
  • Open Issues: 20
  • Releases: 9
Topics
accelerator amd cpp cuda driver-api gpu gpu-computing hip library nvidia rocm
Created about 4 years ago · Last pushed 5 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.dev.md

Developer documentation

If you're looking for user documentation, go here.

Before you can do development work, you'll need to check out a local copy of the repository:

shell cd <where you keep your GitHub repositories> git clone https://github.com/nlesc-recruit/cudawrappers.git cd cudawrappers

Prerequisites

Development environment

As a convenience, a virtual conda environment is provided in environment.yml. This environment contains all tools needed for developing. To use it, first install mambaforge and next create the environment with bash mamba env create --file environment.yml --name cudawrappers and activate the new environment with the command bash mamba activate cudawrappers

Build tools

Summary of what you need :

  • gcc 9 or above
  • g++ 9 or above
  • make 4 or above
  • cmake 3.17 or above

Check that you have the correct gcc, g++ and make versions using

shell gcc --version g++ --version make --version

On a Debian-based system you can install them with

shell sudo apt install build-essential

Next, you need CMake 3.17 or above. Check if you have the correct version installed with cmake --version. If your CMake version is not adequate, you can install CMake manually by downloading the latest stable version from the CMake downloads page and following the installation instructions.

If you don't have enough privileges to install cmake globally - for instance if you are in a cluster without privileges - you can use --prefix=PREFIX to install the CMake to your home folder. Remember that your PATH variable must contain the path that you install cmake, so for instance, you can add the following to your .bashrc:

shell PREFIX=<PREFIX-USED-WITH-CMAKE> export PATH=$PREFIX/bin:$PATH

Remember to update your environment either by logging out and in again, or running source $HOME/.bashrc.

Hardware requirements

You need a GPU with a NVIDIA Pascal architecture or newer to properly use this library.

CUDA Toolkit and NVIDIA drivers

You need to install current NVIDIA drivers. Ideally the latest drivers. The earliest driver version we tested was 455.32. Runnning nvidia-smi command will provide information about the installed driver and CUDA version. You can also see the details of the GPU device.

You also need CUDA 10 or newer, which can be installed in a Debian-based system with the following command:

shell sudo apt install nvidia-cuda-toolkit

Check that nvcc is working with nvcc --version.

Building

The following commands will compile the libraries and tests:

sh cmake -S . -B build -DBUILD_TESTING=ON make --directory=build

Running the tests

To run the tests locally, enter the build directory and run:

shell make test

After running the tests, a coverage report build/coverage.html can be generated with gcovr by running:

gcovr

If you are running the tests on DAS, you can run a job using srun command. For instance,

shell srun -N 1 -C TitanX --gres=gpu:1 make test

This command will run the tests in one of the worker nodes with a GPU device.

Linting and Formatting

We use the following linters and formatters in this project:

The formatter clang-format will format all source files, and cmake-format will format all CMake-related files. The linters will check for errors and bugs, but also style-related issues. So run the formatters before running the linters.

To run the formatters and linters, you first need to build the project and set up pre-commit. See this section for more details.

In addition, you can install VSCode extensions for many of these linters. Here is a short list:

Linters on Codacy

We use Codacy for online linting information. Codacy runs cppcheck and flawfinder online but to run clang-tidy we have to create a GitHub action, run clang-tidy there and push the information to Codacy. Check the file codacy.yml for details on how that is done.

To run clang-tidy on Codacy for this project or a fork, you will need to define a secret called with a name of CODACY_PROJECT_TOKEN. See GitHub docs to learn more about secrets. For the main branch and pull requests originating from inside this repo, there is no need to create a new token. But if it gets revoked, or for forks, follow the steps in the Codacy API tokens page for details on how to create one.

After a pull request is created, a Codacy test should appear. Follow the link there or here for the results.

pre-commit hook

pre-commit is a tool that can automatically run linters, formatters, or any other executables whenever you commit code with git commit.

If you think having such automated checks is helpful for development, you can install the pre-commit CLI from PyPI using pip:

```shell

Install the tool in user space

python3 -m pip install --user pre-commit ```

For other install options, look here.

You can install formatting and linting tools on a Debian-based system as follows: ```shell

install python3 and pip

sudo apt install python3 python3-pip

install cppcheck, clang-tidy and clang-format

sudo apt install cppcheck clang-tidy clang-format ```

Enable the pre-commit hooks defined in .pre-commit-config.yaml with:

shell pre-commit install

Once enabled, future git commits will trigger the pre-commit hooks. Depending on which files are changed by a given commit, some checks will be skipped. Here is an example after making some changes to a CMakeLists.txt file:

shell $ git commit -m "test precommit hook" clang-format.........................................(no files to check)Skipped clang-tidy...........................................(no files to check)Skipped cppcheck.............................................(no files to check)Skipped cmake-format.............................................................Failed - hook id: cmake-format - files were modified by this hook cmake-lint...............................................................Passed Validate repo CITATION.cff file......................(no files to check)Skipped

The clang-tidy and cppcheck pre-commit hooks require a file with compile commands. To generate this file, run cmake: cmake -DCMAKE_CXX_COMPILER=clang++ -S . -B build the CMAKE_CXX_COMPILER flag tells cmake to use the clang++ compiler. This is not strictly necessary, but it does enable compiler warnings in clang-tidy.

You can uninstall the pre-commit hooks by

shell pre-commit uninstall

Running pre-commit hooks individually is also possible with:

shell pre-commit run <name of the task>

For example,

shell pre-commit run clang-format pre-commit run cppcheck pre-commit run cmake-format pre-commit run cmake-lint

If you would like to use only some of the checks (for example only those that do not make code changes but only raise warnings), you can do so by copying the project's default configuration to a file that has '.user' in the filename -- it will be gitignored.

shell cp .pre-commit-config.yaml .pre-commit-config.user.yaml

Then, after editing the new '.user' config file, uninstall the project default hooks if you have them:

shell pre-commit uninstall

and install your preferred hooks:

shell pre-commit install -c .pre-commit-config.user.yaml

When running a user configuration, you are still able to run the hooks from the project default configuration, like so:

```shell

Run on staged files

pre-commit run cmake-format

Run on a named file

pre-commit run cmake-format --file CMakeLists.txt

Run on all files

pre-commit run cmake-format -a ```

See https://pre-commit.com/ for more information.

Building the API documentation

The API documentation is automatically generated for main branch and the pull requests to be merged to main branch. The documentation is hosted at https://cudawrappers.readthedocs.io/en/latest/ and is automatically built by readthedocs service.

Building locally

To build the documentation locally, you will need the following dependencies.

The Python dependencies can be found in docs/requirements.txt.

To build the documentation run:

```shell python3 -m venv venv . ./venv/bin/activate python3 -m pip install -r docs/requirements.txt

cd docs make html ```

This will create a new Python virtual environment, install the dependencies and build the documentation in _build/html folder.

To view the generated documentation, open _build/html/index.html in your web-browser.

Making a release

Preparation

  1. Make sure the CHANGELOG.md describes what was added, changed, or removed since the previous version. Limit the scope of the description to include only those things that affect semantic versioning (so things like changes to a github action do not need to be included in the CHANGELOG). See semver.org for more details
  2. Verify that the information in CITATION.cff is correct (authors, dates, etc.)
  3. Use bump2version to update the version strings in the software
  4. Make sure all the tests are passing
  5. Make sure all the workflows are successful (see https://github.com/nlesc-recruit/cudawrappers/actions?query=branch%3Amain)

GitHub

  1. Make sure that the GitHub-Zenodo integration is enabled for https://github.com/nlesc-recruit/cudawrappers
  2. Go to https://github.com/nlesc-recruit/cudawrappers/releases and click Draft a new release

Verification

  1. Make sure the new release is added to Zenodo (see https://zenodo.org/records/8075251)
  2. Activate the latest release documentation at https://readthedocs.org/projects/cudawrappers/versions/

Owner

  • Name: RECRUIT
  • Login: nlesc-recruit
  • Kind: organization
  • Location: Netherlands

Reducing Energy Consumption in Radio-astronomical and Ultrasound Imaging Tools (RECRUIT)

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: cudawrappers
message: If you use this software, please cite it using the metadata from this file.
type: software
authors:
  - given-names: John W.
    family-names: Romein
    email: romein@astron.nl
    orcid: 'https://orcid.org/0000-0002-1915-5067'
    affiliation: ASTRON
  - given-names: Bram
    family-names: Veenboer
    affiliation: ASTRON
    email: veenboer@astron.nl
    orcid: 'https://orcid.org/0000-0001-9607-1142'
  - given-names: Steven
    name-particle: van der
    family-names: Vlugt
    affiliation: ASTRON
    email: vlugt@astron.nl
    orcid: 'https://orcid.org/0000-0001-6834-4860'
  - given-names: Mattia
    family-names: Mancini
    affiliation: ASTRON
    email: mancini@astron.nl
    orcid: 'https://orcid.org/0000-0002-3861-9234'
  - given-names: Bouwe
    family-names: Andela
    email: b.andela@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0001-9005-8940'
  - given-names: Leon
    family-names: Oostrum
    email: l.oostrum@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0001-8724-8372'
  - given-names: Hanno
    family-names: Spreeuw
    email: h.spreeuw@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0002-5057-0322'
  - given-names: Laura
    family-names: Ootes
    email: l.ootes@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0002-2800-8309'
  - given-names: Ben
    name-particle: van
    family-names: Werkhoven
    email: b.vanwerkhoven@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0002-7508-3272'
  - given-names: Alessio
    family-names: Sclocco
    email: a.sclocco@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0003-3278-0518'
  - given-names: Faruk
    family-names: Diblen
    email: f.diblen@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0002-0989-929X'
  - given-names: Jurriaan H.
    family-names: Spaaks
    email: j.spaaks@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0002-7064-4069'
  - given-names: Abel
    family-names: Soares Siqueira
    email: abel.siqueira@esciencecenter.nl
    affiliation: Netherlands eScience Center
    orcid: 'https://orcid.org/0000-0003-4451-281X'
identifiers:
  - type: doi
    value: 10.5281/zenodo.6076447
    description: The concept doi for all versions of the software.
repository-code: 'https://github.com/nlesc-recruit/cudawrappers'
keywords:
  - CUDA
  - HIP
  - C++
  - GPU
  - accelerators
license: Apache-2.0
date-released: 2022-03-08
version: "0.9.0"

GitHub Events

Total
  • Create event: 34
  • Release event: 3
  • Issues event: 10
  • Watch event: 4
  • Delete event: 33
  • Issue comment event: 19
  • Member event: 1
  • Push event: 134
  • Pull request review comment event: 81
  • Pull request event: 63
  • Pull request review event: 92
  • Fork event: 1
Last Year
  • Create event: 34
  • Release event: 3
  • Issues event: 10
  • Watch event: 4
  • Delete event: 33
  • Issue comment event: 19
  • Member event: 1
  • Push event: 134
  • Pull request review comment event: 81
  • Pull request event: 63
  • Pull request review event: 92
  • Fork event: 1

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 7
  • Total pull requests: 34
  • Average time to close issues: 3 months
  • Average time to close pull requests: 21 days
  • Total issue authors: 3
  • Total pull request authors: 6
  • Average comments per issue: 0.57
  • Average comments per pull request: 0.18
  • Merged pull requests: 25
  • Bot issues: 0
  • Bot pull requests: 5
Past Year
  • Issues: 5
  • Pull requests: 33
  • Average time to close issues: 9 days
  • Average time to close pull requests: 8 days
  • Issue authors: 3
  • Pull request authors: 6
  • Average comments per issue: 0.4
  • Average comments per pull request: 0.18
  • Merged pull requests: 25
  • Bot issues: 0
  • Bot pull requests: 5
Top Authors
Issue Authors
  • loostrum (10)
  • csbnw (5)
  • svlugt (2)
  • wvbbreu (1)
  • stijnh (1)
  • abelsiqueira (1)
  • HannoSpreeuw (1)
Pull Request Authors
  • csbnw (43)
  • loostrum (12)
  • pre-commit-ci[bot] (11)
  • wvbbreu (3)
  • matmanc (3)
  • laurasootes (2)
  • john-romein (2)
  • HannoSpreeuw (1)
  • infinitron (1)
Top Labels
Issue Labels
enhancement (12) bug (3) wontfix (2) nice to have (1)
Pull Request Labels
bug (17) enhancement (15)

Dependencies

docs/requirements.txt pypi
  • Sphinx *
  • breathe *
  • exhale *
  • myst-parser *
  • sphinx-rtd-theme *
.github/workflows/cffconvert.yml actions
  • actions/checkout v2 composite
  • citation-file-format/cffconvert-github-action 2.0.0 composite
.github/workflows/codacy.yml actions
  • actions/checkout v2 composite
.github/workflows/fair-software.yml actions
  • fair-software/howfairis-github-action 0.2.0 composite
.github/workflows/pre-commit.yml actions
  • actions/checkout v3 composite
.github/workflows/build.yml actions
  • Jimver/cuda-toolkit v0.2.11 composite
  • actions/checkout v3 composite
environment.yml pypi
  • bump2version ==1.0.1
  • clang-format ==14.0.0
  • cmakelang ==0.6.13
  • flawfinder ==2.0.19
  • pre-commit *