feat(cccl): integrate missing CCCL directories — python/, ci/, .agent/, docs/, test/
Sparse-checkout from NVIDIA/cccl main branch to complete cccl_upstream: Added: - python/cuda_cccl/ (226 files) — Python bindings for device-level algorithms Critical for muh toolchain: cuda.compute.reduce_into, scan, radix_sort, etc. Includes 204 .py files with full test coverage for all 27 algorithms - ci/ (163 files) — Build/test infrastructure build_cub.sh, test_cub.sh, build_and_test_targets.sh, matrix.yaml Directly maps to our [INFRA-CI] and [INFRA-BUILD] items - .agent/skills/ (7 files) — NVIDIA's own agent skills for CCCL cccl-style/SKILL.md, cccl-test/SKILL.md, sass-diff/SKILL.md - docs/ (491 files) — Official CCCL documentation CI references, CMake guides, Python compute docs, libcudacxx PTX docs - test/ (12 files) — Top-level integration tests (cuda_smoke, stdpar) - Root configs: .clang-format, .clang-tidy, CONTRIBUTING.md, pyproject.toml - CLAUDE.md symlink → AGENTS.md (NVIDIA's standard) cccl_upstream now mirrors full NVIDIA/cccl structure: Before: 42M (cub + thrust + libcudacxx + cudax + c + examples + benchmarks) After: 53M (+python +ci +docs +.agent +test +configs) This completes the CCCL base needed for: - [muh-bench] items: ci/util/build_and_test_targets.sh for targeted builds - [CCCL-verify] items: python/cuda_cccl/tests/ as reference implementations - [CCCL-test] items: ci/test_cub.sh, ci/test_thrust.sh - Agent workflow: .agent/skills/ for consistent style and test patterns
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
.. _libcudacxx-extended-api-bit-bit_reverse:
|
||||
|
||||
``cuda::bit_reverse``
|
||||
=====================
|
||||
|
||||
Defined in the ``<cuda/bit>`` header.
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
namespace cuda {
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] __host__ __device__ constexpr
|
||||
T bit_reverse(T value) noexcept;
|
||||
|
||||
} // namespace cuda
|
||||
|
||||
The function reverses the order of bits in a value.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- ``value``: Input value
|
||||
|
||||
**Return value**
|
||||
|
||||
- Value with reversed bits
|
||||
|
||||
**Constraints**
|
||||
|
||||
- ``T`` is an unsigned integer type.
|
||||
|
||||
**Performance considerations**
|
||||
|
||||
The function performs the following operations:
|
||||
|
||||
- Device:
|
||||
|
||||
- ``uint8_t`` ``uint16_t``: ``PRMT``, ``BREV``
|
||||
- ``uint32_t``: ``BREV``
|
||||
- ``uint64_t``: ``BREV`` x2, ``MOV`` x2
|
||||
- ``uint128_t``: ``BREV`` x4, ``MOV`` x4
|
||||
|
||||
- Host: ``__builtin_bitreverse<N>`` with clang
|
||||
|
||||
.. note::
|
||||
|
||||
Using the function could not be optimal when the input is a run-time value that the compiler can resolve at compile-time, e.g. an index of a loop with a fixed number of iterations.
|
||||
|
||||
.. note::
|
||||
|
||||
GCC <= 8 uses a slow path with more instructions even in device code.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
#include <cuda/bit>
|
||||
#include <cuda/std/cassert>
|
||||
|
||||
__global__ void bit_reverse_kernel() {
|
||||
assert(cuda::bit_reverse(0x0000FFFFu) == 0xFFFF0000u);
|
||||
assert(cuda::bit_reverse(uint8_t{0b00001011}) == uint8_t{0b11010000});
|
||||
}
|
||||
|
||||
int main() {
|
||||
bit_reverse_kernel<<<1, 1>>>();
|
||||
cudaDeviceSynchronize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
`See it on Godbolt 🔗 <https://godbolt.org/z/nW6qe5fT4>`__
|
||||
@@ -0,0 +1,75 @@
|
||||
.. _libcudacxx-extended-api-bit-bitfield_extract:
|
||||
|
||||
``cuda::bitfield_extract``
|
||||
==========================
|
||||
|
||||
Defined in the ``<cuda/bit>`` header.
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
namespace cuda {
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] __host__ __device__ constexpr
|
||||
T bitfield_extract(T value, int start, int width) noexcept;
|
||||
|
||||
} // namespace cuda
|
||||
|
||||
The function extracts a bitfield from a value and returns it in the lower bits.
|
||||
``bitfield_extract()`` computes ``(value >> start) & mask``, where ``mask`` is a sequence of bits of width ``width``.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- ``value``: The value to apply the bitfield.
|
||||
- ``start``: Initial position of the bitfield.
|
||||
- ``width``: Width of the bitfield.
|
||||
|
||||
**Return value**
|
||||
|
||||
- ``(value >> start) & mask``, where ``mask`` is a bitmask of width ``width``.
|
||||
|
||||
**Constraints**
|
||||
|
||||
- ``T`` is an unsigned integer type.
|
||||
|
||||
**Preconditions**
|
||||
|
||||
- ``start >= 0 && start <= num_bits(T)``.
|
||||
- ``width >= 0 && width <= num_bits(T)``.
|
||||
- ``start + width <= num_bits(T)``.
|
||||
|
||||
**Performance considerations**
|
||||
|
||||
The function performs the following operations in CUDA for ``uint8_t``, ``uint16_t``, ``uint32_t``:
|
||||
|
||||
- ``SM < 70``: ``BFE``.
|
||||
- ``SM >= 70``: ``BMSK``, bitwise operation x2.
|
||||
|
||||
.. note::
|
||||
|
||||
Using the function could not be optimal when the input is a run-time value that the compiler can resolve at compile-time, e.g. an index of a loop with a fixed number of iterations.
|
||||
|
||||
.. note::
|
||||
|
||||
GCC <= 8 uses a slow path with more instructions even in CUDA.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
#include <cuda/bit>
|
||||
#include <cuda/std/cassert>
|
||||
|
||||
__global__ void bitfield_extract_kernel() {
|
||||
assert(cuda::bitfield_extract(~0u, 0, 4) == 0b1111);
|
||||
assert(cuda::bitfield_extract(0b1011000u, 3, 4) == 0b1011);
|
||||
}
|
||||
|
||||
int main() {
|
||||
bitfield_extract_kernel<<<1, 1>>>();
|
||||
cudaDeviceSynchronize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
`See it on Godbolt 🔗 <https://godbolt.org/z/ofGnbsxW5>`__
|
||||
@@ -0,0 +1,76 @@
|
||||
.. _libcudacxx-extended-api-bit-bitfield_insert:
|
||||
|
||||
``cuda::bitfield_insert``
|
||||
=========================
|
||||
|
||||
Defined in the ``<cuda/bit>`` header.
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
namespace cuda {
|
||||
|
||||
template <typename T>
|
||||
[[nodiscard]] __host__ __device__ constexpr
|
||||
T bitfield_insert(T dest, T source, int start, int width) noexcept;
|
||||
|
||||
} // namespace cuda
|
||||
|
||||
The function extracts the lower bitfield of size ``width`` from ``source`` and inserts it into ``dest`` at position ``start``.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- ``dest``: The value to insert the bitfield into.
|
||||
- ``source``: The value from which extract the bitfield.
|
||||
- ``start``: Initial position of the bitfield.
|
||||
- ``width``: Width of the bitfield.
|
||||
|
||||
**Return value**
|
||||
|
||||
- ``((source << start) & mask) | (dest & ~mask)``, where ``mask`` is a bitmask of width ``width`` at position ``start``.
|
||||
|
||||
**Constraints**
|
||||
|
||||
- ``T`` is an unsigned integer type.
|
||||
|
||||
**Preconditions**
|
||||
|
||||
- ``start >= 0 && start <= num_bits(T)``.
|
||||
- ``width >= 0 && width <= num_bits(T)``.
|
||||
- ``start + width <= num_bits(T)``.
|
||||
|
||||
**Performance considerations**
|
||||
|
||||
The function performs the following operations in CUDA for ``uint8_t``, ``uint16_t``, ``uint32_t``:
|
||||
|
||||
- ``SM < 70``: ``BFI``.
|
||||
- ``SM >= 70``: ``BMSK``, bitwise operation x5.
|
||||
|
||||
.. note::
|
||||
|
||||
When the input values are run-time values that the compiler can resolve at compile-time, e.g. an index of a loop with a fixed number of iterations, using the function could not be optimal.
|
||||
|
||||
.. note::
|
||||
|
||||
GCC <= 8 uses a slow path with more instructions even in CUDA.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
#include <cuda/bit>
|
||||
#include <cuda/std/cassert>
|
||||
|
||||
__global__ void bitfield_insert_kernel() {
|
||||
assert(cuda::bitfield_insert(0u, 0xFFFFu, 0, 4) == 0b1111);
|
||||
assert(cuda::bitfield_insert(0u, 0xFFFFu, 3, 4) == 0b1111000);
|
||||
assert(cuda::bitfield_insert(1u, 0xFFFFu, 3, 4) == 0b1111001);
|
||||
}
|
||||
|
||||
int main() {
|
||||
bitfield_insert_kernel<<<1, 1>>>();
|
||||
cudaDeviceSynchronize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
`See it on Godbolt 🔗 <https://godbolt.org/z/4Thzz516M>`__
|
||||
74
cccl_upstream/docs/libcudacxx/extended_api/bit/bitmask.rst
Normal file
74
cccl_upstream/docs/libcudacxx/extended_api/bit/bitmask.rst
Normal file
@@ -0,0 +1,74 @@
|
||||
.. _libcudacxx-extended-api-bit-bitmask:
|
||||
|
||||
``cuda::bitmask``
|
||||
=================
|
||||
|
||||
Defined in the ``<cuda/bit>`` header.
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
namespace cuda {
|
||||
|
||||
template <typename T = uint32_t>
|
||||
[[nodiscard]] __host__ __device__ constexpr
|
||||
T bitmask(int start, int width) noexcept;
|
||||
|
||||
} // namespace cuda
|
||||
|
||||
The function generates a bitmask of size ``width`` starting at position ``start``.
|
||||
|
||||
**Parameters**
|
||||
|
||||
- ``start``: starting position of the bitmask.
|
||||
- ``width``: width of the bitmask.
|
||||
|
||||
**Return value**
|
||||
|
||||
- Bitmask of size ``width`` starting at position``start``.
|
||||
|
||||
**Constraints**
|
||||
|
||||
- ``T`` is an unsigned integral type.
|
||||
|
||||
**Preconditions**
|
||||
|
||||
- ``start >= 0 && start <= num_bits(T)``.
|
||||
- ``width >= 0 && width <= num_bits(T)``.
|
||||
- ``start + width <= num_bits(T)``.
|
||||
|
||||
**Performance considerations**
|
||||
|
||||
The function performs the following operations in device code:
|
||||
|
||||
- ``uint8_t``, ``uint16_t``, ``uint32_t``: ``BMSK``.
|
||||
- ``uint64_t``: ``SHL`` x4, ``ADD`` x2.
|
||||
|
||||
.. note::
|
||||
|
||||
When the input values are run-time values that the compiler can resolve at compile-time, e.g. an index of a loop with a fixed number of iterations, using the function could not be optimal.
|
||||
|
||||
.. note::
|
||||
|
||||
GCC <= 8 uses a slow path with more instructions even in CUDA.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code:: cuda
|
||||
|
||||
#include <cuda/bit>
|
||||
#include <cuda/std/cassert>
|
||||
#include <cuda/std/cstdint>
|
||||
|
||||
__global__ void bitmask_kernel() {
|
||||
assert(cuda::bitmask(2, 4) == 0b111100u);
|
||||
assert(cuda::bitmask<uint64_t>(1, 3) == uint64_t{0b1110});
|
||||
}
|
||||
|
||||
int main() {
|
||||
bitmask_kernel<<<1, 1>>>();
|
||||
cudaDeviceSynchronize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
`See it on Godbolt 🔗 <https://godbolt.org/z/habGohz7T>`__
|
||||
Reference in New Issue
Block a user