Files
project_6/cccl_upstream/docs/libcudacxx/ptx_api.rst
muh-bot 2a7ca101d7 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
2026-08-07 02:34:33 +00:00

84 lines
2.8 KiB
ReStructuredText

.. _libcudacxx-ptx:
PTX API
========
The ``cuda::ptx`` namespace contains functions that map one-to-one to
`PTX instructions <https://docs.nvidia.com/cuda/parallel-thread-execution/index.html>`__.
These can be used for maximal control of the generated code, or to
experiment with new hardware features before a high-level C++ API is
available.
.. toctree::
:maxdepth: 1
ptx/examples
ptx/instructions
ptx/pragmas
Versions and compatibility
---------------------------
The ``cuda/ptx`` header is intended to present a stable API within one major
version of the CTK on a best effort basis. This means that:
- All functions are marked static inline.
- The type of a function parameter can be changed to be more generic if
that means that code that called the original version can still be
compiled.
- Good exposure of the PTX should be high priority. If, at a new major
version, we face a difficult choice between breaking
backward-compatibility and an improvement of the PTX exposure, we
will tend to the latter option more easily than in other parts of
libcu++.
The API does not guarantee stability of template parameters. The order and
number of template parameters may change. Use arguments to driver overload
resolution as in the code below to ensure forward-compatibility:
.. code:: cuda
// Use arguments to drive overload resolution:
cuda::ptx::mbarrier_arrive_expect_tx(cuda::ptx::sem_release, cuda::ptx::scope_cta, cuda::ptx::space_shared, &bar, 1);
// Specifying templates directly is not forward-compatible, as order and number
// of template parameters may change in a minor release:
cuda::ptx::mbarrier_arrive_expect_tx<cuda::ptx::sem_release_t>(
cuda::ptx::sem_release, cuda::ptx::scope_cta, cuda::ptx::space_shared, &bar, 1
);
**PTX ISA version and compute capability.** Each binding notes under
which PTX ISA version and SM version it may be used. Example:
.. code:: cuda
// mbarrier.arrive.shared::cta.b64 state, [addr]; // 1. PTX ISA 70, SM_80
__device__ inline uint64_t mbarrier_arrive(
cuda::ptx::sem_release_t sem,
cuda::ptx::scope_cta_t scope,
cuda::ptx::space_shared_t space,
uint64_t* addr);
To check if the current compiler is recent enough, use:
.. code:: cuda
#if __cccl_ptx_isa >= 700
cuda::ptx::mbarrier_arrive(cuda::ptx::sem_release, cuda::ptx::scope_cta, cuda::ptx::space_shared, &bar, 1);
#endif
Ensure that you only call the function when compiling for a recent
enough compute capability (SM version), like this:
.. code:: cuda
NV_IF_TARGET(NV_PROVIDES_SM_80,(
cuda::ptx::mbarrier_arrive(cuda::ptx::sem_release, cuda::ptx::scope_cta, cuda::ptx::space_shared, &bar, 1);
));
For more information on which compilers correspond to which PTX ISA, see
the `PTX ISA release notes <https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes>`__.