NVIDIA / NVIDIA/cuCollections

[ENHANCEMENT]: Including cuco datastructures declarations for non-CUDA compilers.

Open
#232 10 comments 1 reaction 1 assignee View on GitHub

@sleeepyjack is already working on this.

Since Oct 12, 2023.

P1: Should have type: feature request
Dominant language
Cuda
Stars
667
Forks
120
Avg merge
7d 5h
Merged PRs (30d)
4

Description

Is your feature request related to a problem? Please describe.

I would like to be able to have a declaration of the cuco datastructures available without having to compile the definition using CUDA so that they can be used in .hpp or .cpp files. At the moment, if you need a forward declaration you need to include all the default template arguments. The compiler doesn't allow redefinition of the default template arguments, even when they are the same as in the .cuh file.

Describe the solution you'd like

Split the .cuh files into .hpp and an .inl. This way one can include either .hpp only for the declarations or .cuh for both the declarations and the definitions.

The .cuh file becomes:

#pragma once

#include <<data_structure>.hpp>
#include <cuco/detail/<data_structure>.inl>

I'm not sure this is that trivial as there may be cuda specific keywords in the declarations like device, device and so on.

Alternatively, the hpp file only contains the highest level declarations + default template value declarations. Then the only change to the current .cuh files would have to be to leave out these defaults in addition to the extra line:

#include <<data_structure>.hpp>

Describe alternatives you've considered

Currently, forward declare the data structure with all its template arguments including those with default values and copy-paste their default values from the .cuh file into your declarations. Obviously, this is not ideal.

Additional context

This is in particular convenient for larger codebases.

Any cpp file that depends on the cuco data structure through nested includes will run into this problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.