Skip to content

Commit 4e07552

Browse files
authored
Merge branch 'main' into multi_gpu_CI_jobs_for_libcudacxx
2 parents c7eebec + 261c8f3 commit 4e07552

36 files changed

Lines changed: 1200 additions & 307 deletions

.agent/skills/cccl-style/SKILL.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: cccl-style
3+
description: Use when editing or reviewing CCCL code for style conventions; read common CCCL guidance and the path-specific references named by this skill.
4+
---
5+
6+
# CCCL Style
7+
8+
## Workflow
9+
10+
1. Read `references/common.md` for guidance that applies across CCCL.
11+
2. For `libcudacxx/include/**/*`, also read `references/libcudacxx.md`.
12+
3. For `cudax/include/**/*`, also read `references/libcudacxx.md`.
13+
4. If no path-specific reference exists, follow nearby code and repository docs. Do not import rules from another subproject.
14+
5. Apply each reference only to its stated scope. Rules for one CCCL subproject do not automatically apply to another.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Common CCCL Style Guidance
2+
3+
Apply this guidance across CCCL unless a path-specific style reference says otherwise.
4+
5+
## Naming Style
6+
7+
- Macros: macro style, e.g. `MY_MACRO`.
8+
- Template parameters: PascalCase, e.g. `MyParameter`.
9+
- All other symbols: snake style, e.g. `my_variable`. The one exception is the CUB public API, which uses PascalCase.
10+
11+
## Variables
12+
13+
- All variables that are not modified must use `const`. This includes variables initialized by casts (`static_cast`, `reinterpret_cast`, `bit_cast`), function return values, and loop-invariant computations.
14+
- All variables that can be evaluated at compile-time must use `constexpr`.
15+
- All `constexpr` variables at namespace/global scope must use `inline`, including variable templates.
16+
- Consider using plural names for array, span, list, e.g. `int values[4]` instead of `int value[4]`.
17+
- Use uniform initialization for class constructors (not enforced to builtin types) and compile-time conversions, e.g. `constexpr auto x = int{sizeof(float)};`.
18+
19+
## Headers
20+
21+
- Files must include all headers related to the symbols that they are using.
22+
- Relying on transitive header inclusion is not allowed.
23+
- Unneeded headers must be removed.
24+
- All headers must have the correct license. This also applies to source files.
25+
- All header inclusions must use the syntax `<header>`.
26+
- Use forward declaration, namely `__fwd/header.h` or direct type declaration, when possible instead of including the implementation header.
27+
- Headers should be the most precise available, e.g. `#include <cuda/std/__type_traits/is_array.h>`.
28+
- Do not include headers in `cuda/std/__cccl/` directly; they are provided by `__config` or the prologue/epilogue mechanism.
29+
30+
## Functions
31+
32+
- Functions must be marked `_CCCL_HOST_API`, `_CCCL_DEVICE_API`, `_CCCL_HOST_DEVICE_API`, `_CCCL_TILE_API`, or `_CCCL_API`.
33+
- Non-template, non-`constexpr` functions must use `inline`.
34+
- Most functions with a non-void return type should use `[[nodiscard]]`; functions with known side effects may be exceptions.
35+
- Functions that do not throw exceptions must use `noexcept`.
36+
- Use `_CCCL_CONSTEVAL` when the function can only be evaluated at compile time.
37+
- Use C++20 concept macros instead of SFINAE, e.g. `_CCCL_TEMPLATE(...)` and `_CCCL_REQUIRES(...)`.
38+
39+
## Function Calls And Types
40+
41+
- In headers, apply global qualification where the subproject requires it:
42+
- libcudacxx and cudax require free function calls to be fully qualified from the global namespace, e.g. `::cuda::ceil_div(...)`.
43+
- CUB applies this rule only to calls to symbols under the `::cuda` namespace hierarchy; otherwise follow existing CUB qualification style.
44+
- Thrust uses leading `::` for many symbols under the `::cuda` namespace hierarchy, but relies on ADL in many places and the blanket free-function qualification rule does not apply to those calls.
45+
- For covered calls, this includes calls to functions defined in the same namespace, e.g. inside `cuda::`, call `::cuda::ceil_div(...)`, not `ceil_div(...)`. This does not apply to (static) member functions of classes. The only exceptions for covered calls are functions that are supposed to be found through argument-dependent lookup (ADL), such as `::cuda::std::swap` and `::cuda::std::get`. Those functions can be called unqualified with a preceding `using ::cuda::std::get;`.
46+
- This global-qualification rule does not apply to source files such as tests and benchmarks.
47+
- In headers, apply type-name qualification where the subproject requires it:
48+
- libcudacxx and cudax require type names to be fully qualified except when they are already declared in the current namespace or an enclosing one. Outside those namespaces, fully qualify `cuda::std` and standard integer type aliases such as `::cuda::std::size_t`.
49+
- CUB applies this rule only to type names under the `::cuda` namespace hierarchy. Do not apply the libcudacxx/cudax blanket type-qualification rule to CUB namespaces or `detail` namespaces.
50+
- Thrust does not apply the libcudacxx/cudax blanket type-qualification rule. It uses leading `::` for many `::cuda` and `::cuda::std` type names, but also uses Thrust namespace patterns; follow neighboring Thrust code.
51+
- A local `using` declaration, e.g. `using ::cuda::std::size_t;`, is acceptable to avoid repetition within a function body.
52+
- Static member functions of a class template inherit the class's namespace.
53+
54+
## Comments
55+
56+
- Commented code without a description is not allowed.
57+
58+
## General Guidelines
59+
60+
- The code must reuse `cuda/` or `cuda/std` functionalities as much as possible, including macros.
61+
- Try to use modern C++ as much as possible. The repository supports C++17 but many more recent functionalities have been backported with functions and macros.
62+
63+
## Prevent Compiler Errors And Improve Compatibility
64+
65+
- Remove unused code, variables, functions, types, template parameters, headers, etc.
66+
- Variables that are unsigned, or that can become unsigned after template instantiation, must not check for negative values directly. Use `cuda::std::is_unsigned_v<T> ? false : (var < 0)` instead.
67+
68+
## Compiler Compatibility
69+
70+
- Protect host-only code with `#if !_CCCL_COMPILER(NVRTC)`.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# libcudacxx Style Guidance
2+
3+
Use this reference for `libcudacxx/include/**/*` and `cudax/include/**/*`.
4+
5+
## Naming Style
6+
7+
All non-public symbols must be C++ reserved identifiers:
8+
9+
- `_` for macros and template parameters, e.g. `_MY_MACRO`, `_MyParameter`.
10+
- `__` for all other symbols, e.g. `__my_variable`.
11+
- Avoid single-letter template parameter names. Wrong: `_T`; correct: `_Tp`.
12+
13+
## Class / Struct
14+
15+
- Data member names have postfix `_`, e.g. `class __myclass { int __data_; };`.
16+
- Constructor parameter names should match class/struct data member names without the postfix `_`, e.g. `class __myclass { __myclass(int __data) : __data_(__data) {} };`.
17+
18+
## Functions
19+
20+
- Use `constexpr` for functions that do not depend on run-time features, such as pointers.
21+
- If the return type is not explicit (`auto`), then a trailing return type is strongly preferred.
22+
23+
## Headers
24+
25+
- Use the correct license:
26+
- `libcudacxx/include/cuda/std` files ported from LLVM libc++ use the LLVM license.
27+
- `libcudacxx/include/cuda/` files use Apache License v2.0 with LLVM Exceptions.
28+
- Headers use include guards with names derived from the uppercase full path and closing `#endif` comments repeating the guard name.
29+
- Right after the include guard, include:
30+
31+
```cpp
32+
#include <cuda/std/detail/__config>
33+
34+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
35+
# pragma GCC system_header
36+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
37+
# pragma clang system_header
38+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
39+
# pragma system_header
40+
#endif // no system header
41+
```
42+
43+
- The last included header before code must be `<cuda/std/__cccl/prologue.h>`, and `<cuda/std/__cccl/epilogue.h>` must appear at the end of the file.
44+
45+
## Comments
46+
47+
- Use Doxygen-style `//! @brief` comments.
48+
- Documented functions must include `//! @brief`, `//! @param[in/out/in,out]` for every parameter, and `//! @return` for non-void functions.
49+
- The `@brief/@param/@return` description must accurately reflect the current functionality of the function.
50+
51+
## Compiler Compatibility
52+
53+
- Do not use lambda expressions in device-only or host-device code.
54+
- Do not rely on deduction guides for initialization; use explicit template arguments instead.

.agent/skills/cccl-test/SKILL.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: cccl-test
3+
description: Use when writing, updating, reviewing, or validating CCCL tests; read common CCCL test guidance and the path-specific references named by this skill.
4+
---
5+
6+
# CCCL Test
7+
8+
## Workflow
9+
10+
1. Read `references/common.md` for guidance that applies across CCCL tests.
11+
2. For `libcudacxx/test/**/*`, also read `references/libcudacxx.md`.
12+
3. If no path-specific reference exists, follow nearby tests and repository docs. Do not import test rules from another subproject.
13+
4. Apply each reference only to its stated scope. Rules for one CCCL subproject do not automatically apply to another.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Common CCCL Test Guidance
2+
3+
Apply this guidance across CCCL tests unless a path-specific test reference says otherwise.
4+
5+
## Local Consistency
6+
7+
- Read nearby tests first and mirror their directory layout, file names, helper types, includes, assertion style, and local gating or skip mechanisms.
8+
9+
## Coverage
10+
11+
- Cover relevant edge cases.
12+
- Cover relevant input and output types.
13+
- Cover error behavior when applicable.
14+
- Cover runtime and compile-time behavior when applicable.
15+
- Cover device and host behavior when applicable.
16+
17+
## Test Structure
18+
19+
- All tests must have the correct license banner.
20+
- Use the local test harness assertions and helpers.
21+
- Use compile-time checks for compile-time guarantees and constexpr coverage when relevant.
22+
- Negative tests should check the intended diagnostic or failure mode when the local harness supports it.
23+
24+
## Portability
25+
26+
- Prefer project test macros and helpers for compiler, dialect, exception, host/device, and platform probes instead of spelling ad hoc checks directly.
27+
- If a test is unsupported, expected to fail, disabled, or skipped on a platform, motivate it with a comment.
28+
29+
## Validation
30+
31+
- Use targeted test runs for the project and files being changed.

.agent/skills/libcudacxx-test/SKILL.md renamed to .agent/skills/cccl-test/references/libcudacxx.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
---
2-
name: libcudacxx-test
3-
description: Write, update, and validate libcudacxx tests under libcudacxx/test.
4-
---
5-
61
# libcudacxx Test
72

83
## Organization

.agent/skills/libcudacxx-style/SKILL.md

Lines changed: 0 additions & 105 deletions
This file was deleted.

.claude/skills/cccl-style/SKILL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: cccl-style
3+
description: Use when editing or reviewing CCCL code for style conventions; read common CCCL guidance and the path-specific references named by this skill.
4+
---
5+
6+
The skill content is in .agent/skills/cccl-style/SKILL.md

.claude/skills/cccl-test/SKILL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
name: cccl-test
3+
description: Use when writing, updating, reviewing, or validating CCCL tests; read common CCCL test guidance and the path-specific references named by this skill.
4+
---
5+
6+
The skill content is in .agent/skills/cccl-test/SKILL.md

.claude/skills/libcudacxx-style/SKILL.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)