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:
169
cccl_upstream/docs/thrust/Doxyfile
Normal file
169
cccl_upstream/docs/thrust/Doxyfile
Normal file
@@ -0,0 +1,169 @@
|
||||
# Doxyfile for Thrust
|
||||
|
||||
PROJECT_NAME = Thrust
|
||||
OUTPUT_DIRECTORY = ../_build/doxygen/thrust
|
||||
CREATE_SUBDIRS = NO
|
||||
GENERATE_HTML = NO
|
||||
GENERATE_LATEX = NO
|
||||
GENERATE_XML = YES
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
|
||||
INPUT = ../../thrust/thrust \
|
||||
../../thrust/thrust/iterator \
|
||||
../../thrust/thrust/mr \
|
||||
../../thrust/thrust/random \
|
||||
../../thrust/thrust/system \
|
||||
../../thrust/thrust/system/cpp \
|
||||
../../thrust/thrust/system/omp \
|
||||
../../thrust/thrust/system/tbb \
|
||||
../../thrust/thrust/type_traits \
|
||||
../../thrust/thrust/detail/pointer.h
|
||||
|
||||
RECURSIVE = YES
|
||||
EXCLUDE_PATTERNS = */detail/* */test/* */examples/* */testing/*
|
||||
EXCLUDE_SYMBOLS = *detail* *__* THRUST_NS_QUALIFIER optional
|
||||
|
||||
FILE_PATTERNS = *.h *.hpp
|
||||
EXTENSION_MAPPING = cuh=C++ cu=C++
|
||||
|
||||
# Documentation extraction settings
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INHERITED_MEMB = YES
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = ../../thrust
|
||||
SHORT_NAMES = NO
|
||||
DISTRIBUTE_GROUP_DOC = YES
|
||||
|
||||
# Parsing settings
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
BUILTIN_STL_SUPPORT = YES
|
||||
|
||||
# Preprocessing
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
||||
# IMPORTANT: Aliases for custom commands
|
||||
# The rst alias enables embedding reStructuredText in doxygen comments
|
||||
ALIASES = "rst=\\verbatim embed:rst"
|
||||
ALIASES += "endrst=\\endverbatim"
|
||||
ALIASES += "rststar=\\verbatim embed:rst:leading-asterisk"
|
||||
ALIASES += "inlinerst=\\verbatim embed:rst:inline"
|
||||
|
||||
# Predefined macros
|
||||
PREDEFINED = __device__= \
|
||||
__host__= \
|
||||
__global__= \
|
||||
__forceinline__= \
|
||||
"__declspec(x)=" \
|
||||
"__align__(x)=" \
|
||||
__cccl_lib_mdspan \
|
||||
_CCCL_DOXYGEN_INVOKED \
|
||||
"_CCCL_AND=&&" \
|
||||
"_CCCL_CONCEPT=constexpr bool" \
|
||||
"_CCCL_CONSTEXPR_FRIEND=friend" \
|
||||
"_CCCL_CONSTEXPR_CXX20=constexpr" \
|
||||
"_CCCL_CONSTEXPR_CXX23=constexpr" \
|
||||
"_CCCL_CTK_AT_LEAST(x, y)=1" \
|
||||
"_CCCL_CTK_BELOW(x, y)=0" \
|
||||
"_CCCL_CUDACC_AT_LEAST(x, y)=1" \
|
||||
"_CCCL_CUDACC_BELOW(x, y)=0" \
|
||||
_CCCL_DEVICE= \
|
||||
_CCCL_DIAG_PUSH= \
|
||||
_CCCL_DIAG_POP= \
|
||||
"_CCCL_DIAG_SUPPRESS_CLANG(x)=" \
|
||||
"_CCCL_DIAG_SUPPRESS_GCC(x)=" \
|
||||
"_CCCL_DIAG_SUPPRESS_MSVC(x)=" \
|
||||
"_CCCL_DIAG_SUPPRESS_NVHPC(x)=" \
|
||||
_CCCL_EXEC_CHECK_DISABLE= \
|
||||
_CCCL_FORCEINLINE= \
|
||||
"_CCCL_GLOBAL_CONSTANT=inline constexpr" \
|
||||
"_CCCL_HAS_CTK()=1" \
|
||||
_CCCL_HIDE_FROM_ABI= \
|
||||
_CCCL_HOST= \
|
||||
_CCCL_HOST_DEVICE= \
|
||||
"_CCCL_IF_CONSTEVAL=if consteval" \
|
||||
"_CCCL_INLINE_VAR=inline" \
|
||||
"_CCCL_NODISCARD=[[nodiscard]]" \
|
||||
"_CCCL_NODISCARD_FRIEND=friend" \
|
||||
"_CCCL_REQUIRES(x)= ::cuda::std::enable_if_t<x, int> = 0>" \
|
||||
_CCCL_STD_VER=2020 \
|
||||
_CCCL_SUPPRESS_DEPRECATED_PUSH= \
|
||||
_CCCL_SUPPRESS_DEPRECATED_POP= \
|
||||
"_CCCL_TEMPLATE(x)=template<x, " \
|
||||
"_CCCL_TRAIT(x, y)=x<y>::value" \
|
||||
"_CCCL_TRAILING_REQUIRES(x)=-> x requires " \
|
||||
_CCCL_TYPE_VISIBILITY_DEFAULT= \
|
||||
_CCCL_TYPE_VISIBILITY_HIDDEN= \
|
||||
_CCCL_API=inline \
|
||||
_CCCL_HOST_DEVICE_API=inline \
|
||||
_CCCL_DEVICE_API=inline \
|
||||
_CCCL_HOST_API=inline \
|
||||
_CCCL_NODEBUG_API=inline \
|
||||
_CCCL_NODEBUG_DEVICE_API=inline \
|
||||
_CCCL_NODEBUG_HOST_API=inline \
|
||||
_CCCL_TRIVIAL_API=inline \
|
||||
_CCCL_TRIVIAL_DEVICE_API=inline \
|
||||
_CCCL_TRIVIAL_HOST_API=inline \
|
||||
_CCCL_PUBLIC_API=inline \
|
||||
_CCCL_PUBLIC_DEVICE_API=inline \
|
||||
_CCCL_PUBLIC_HOST_API=inline \
|
||||
_CCCL_VISIBILITY_DEFAULT= \
|
||||
_CCCL_VISIBILITY_HIDDEN= \
|
||||
_CCCL_LIFETIMEBOUND= \
|
||||
_CCCL_TRY=try \
|
||||
_CCCL_CATCH=catch \
|
||||
"_CCCL_CATCH_ALL=catch (...)" \
|
||||
"_CCCL_CATCH_FALLTHROUGH=" \
|
||||
"_LIBCUDACXX_NOEXCEPT_RETURN(...)=noexcept(noexcept(...)) { return ...; }" \
|
||||
"THRUST_NAMESPACE_BEGIN=namespace thrust {" \
|
||||
"THRUST_NAMESPACE_END=}" \
|
||||
THRUST_PREVENT_MACRO_SUBSTITUTION \
|
||||
"THRUST_FWD(x)=x" \
|
||||
"_CCCL_PUBLIC_API=inline" \
|
||||
"_CCCL_PUBLIC_DEVICE_API=inline" \
|
||||
"_CCCL_PUBLIC_HOST_API=inline" \
|
||||
"_CCCL_BEGIN_NAMESPACE_CUDA_STD=namespace cuda::std {" \
|
||||
"_CCCL_END_NAMESPACE_CUDA_STD=}" \
|
||||
"_CUDAX_CONSTEXPR_FRIEND=friend" \
|
||||
"_LIBCUDACXX_HAS_SPACESHIP_OPERATOR()=1" \
|
||||
"CCCL_DEPRECATED=" \
|
||||
"CCCL_DEPRECATED_BECAUSE(x)=" \
|
||||
"CCCL_IGNORE_DEPRECATED_CPP_DIALECT" \
|
||||
"CUB_DISABLE_NAMESPACE_MAGIC" \
|
||||
"CUB_IGNORE_NAMESPACE_MAGIC_ERROR" \
|
||||
"CUB_RDC_ENABLED" \
|
||||
"CUB_NAMESPACE_BEGIN=namespace cub {" \
|
||||
"CUB_NAMESPACE_END=}" \
|
||||
"CUB_RUNTIME_FUNCTION=" \
|
||||
"_CCCL_HOSTED()=1"
|
||||
|
||||
# Images and examples
|
||||
IMAGE_PATH = ../img
|
||||
EXAMPLE_PATH = ../../thrust/examples
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
EXAMPLE_PATTERNS = *.cu
|
||||
|
||||
# Output settings
|
||||
AUTOLINK_SUPPORT = YES
|
||||
QUIET = YES
|
||||
WARNINGS = YES
|
||||
WARN_AS_ERROR = FAIL_ON_WARNINGS
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_IF_INCOMPLETE_DOC = NO
|
||||
WARN_NO_PARAMDOC = NO
|
||||
18
cccl_upstream/docs/thrust/algorithms.rst
Normal file
18
cccl_upstream/docs/thrust/algorithms.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
.. _thrust-module-api-algorithms:
|
||||
|
||||
Algorithms
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
algorithms/copying
|
||||
algorithms/merging
|
||||
algorithms/prefix_sum
|
||||
algorithms/reductions
|
||||
algorithms/reordering
|
||||
algorithms/searching
|
||||
algorithms/set_operations
|
||||
algorithms/sorting
|
||||
algorithms/transformations
|
||||
12
cccl_upstream/docs/thrust/algorithms/copying.rst
Normal file
12
cccl_upstream/docs/thrust/algorithms/copying.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-algorithms-copying:
|
||||
|
||||
Copying
|
||||
-------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
copying/gather
|
||||
copying/scatter
|
||||
../api/group__copying*
|
||||
10
cccl_upstream/docs/thrust/algorithms/copying/gather.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/copying/gather.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-copying-gather:
|
||||
|
||||
Gather
|
||||
^^^^^^^
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__gather*
|
||||
10
cccl_upstream/docs/thrust/algorithms/copying/scatter.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/copying/scatter.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-copying-scatter:
|
||||
|
||||
Scatter
|
||||
^^^^^^^
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__scatter*
|
||||
10
cccl_upstream/docs/thrust/algorithms/merging.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/merging.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-merging:
|
||||
|
||||
Merging
|
||||
-------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__merging*
|
||||
12
cccl_upstream/docs/thrust/algorithms/prefix_sum.rst
Normal file
12
cccl_upstream/docs/thrust/algorithms/prefix_sum.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-algorithms-prefix_sums:
|
||||
|
||||
Prefix sums
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
prefix_sums/segmented
|
||||
prefix_sums/transformed
|
||||
../api/group__prefixsums*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-prefix_sums-segmented:
|
||||
|
||||
Segmented Prefix Sums
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__segmentedprefix*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-prefix_sums-transformed:
|
||||
|
||||
Transformed Prefix Sums
|
||||
-------------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__transformed__prefixsums*
|
||||
16
cccl_upstream/docs/thrust/algorithms/reductions.rst
Normal file
16
cccl_upstream/docs/thrust/algorithms/reductions.rst
Normal file
@@ -0,0 +1,16 @@
|
||||
.. _thrust-module-api-algorithms-reductions:
|
||||
|
||||
Reductions
|
||||
----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
reductions/comparisons
|
||||
reductions/counting
|
||||
reductions/extrema
|
||||
reductions/logical
|
||||
reductions/predicates
|
||||
reductions/transformed
|
||||
../api/group__reductions*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-comparisons:
|
||||
|
||||
Comparisons
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__comparisons*
|
||||
10
cccl_upstream/docs/thrust/algorithms/reductions/counting.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/reductions/counting.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-counting:
|
||||
|
||||
Counting
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__counting*
|
||||
10
cccl_upstream/docs/thrust/algorithms/reductions/extrema.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/reductions/extrema.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-extrema:
|
||||
|
||||
Extrema
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__extrema*
|
||||
10
cccl_upstream/docs/thrust/algorithms/reductions/logical.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/reductions/logical.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-logical:
|
||||
|
||||
Logical
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__logical*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-predicates:
|
||||
|
||||
Predicates
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__predicates*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reductions-transformed:
|
||||
|
||||
Transformed Reductions
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__transformed__reductions*
|
||||
12
cccl_upstream/docs/thrust/algorithms/reordering.rst
Normal file
12
cccl_upstream/docs/thrust/algorithms/reordering.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-algorithms-reordering:
|
||||
|
||||
Reordering
|
||||
----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
reordering/partitioning
|
||||
reordering/shuffling
|
||||
reordering/stream_compaction
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reordering-partitioning:
|
||||
|
||||
Partitioning
|
||||
-------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__partitioning*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reordering-shuffling:
|
||||
|
||||
Shuffling
|
||||
-------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__shuffling*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-reordering-stream-compactation:
|
||||
|
||||
Stream Compactation
|
||||
-------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__stream__compaction*
|
||||
11
cccl_upstream/docs/thrust/algorithms/searching.rst
Normal file
11
cccl_upstream/docs/thrust/algorithms/searching.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
.. _thrust-module-api-algorithms-searching:
|
||||
|
||||
Searching
|
||||
----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
searching/binary_search
|
||||
../api/group__searching*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-searching-binary-search:
|
||||
|
||||
Binary Search
|
||||
--------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__binary__search*
|
||||
10
cccl_upstream/docs/thrust/algorithms/set_operations.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/set_operations.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-set-operations:
|
||||
|
||||
Set Operations
|
||||
---------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__set__operations*
|
||||
10
cccl_upstream/docs/thrust/algorithms/sorting.rst
Normal file
10
cccl_upstream/docs/thrust/algorithms/sorting.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-sorting:
|
||||
|
||||
Sorting
|
||||
--------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__sorting*
|
||||
13
cccl_upstream/docs/thrust/algorithms/transformations.rst
Normal file
13
cccl_upstream/docs/thrust/algorithms/transformations.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _thrust-module-api-algorithms-transformations:
|
||||
|
||||
Transformations
|
||||
-----------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
transformations/filling
|
||||
transformations/modifying
|
||||
transformations/replacing
|
||||
../api/group__transformations*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-transformations-filling:
|
||||
|
||||
Filling
|
||||
--------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__filling*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-transformations-modifying:
|
||||
|
||||
Modifying
|
||||
--------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__modifying*
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-algorithms-transformations-replacing:
|
||||
|
||||
Replacing
|
||||
--------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../../api/group__replacing*
|
||||
12
cccl_upstream/docs/thrust/containers.rst
Normal file
12
cccl_upstream/docs/thrust/containers.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-containers:
|
||||
|
||||
Containers
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
api/*host__vector*
|
||||
api/*device__vector*
|
||||
api/group__containers_*
|
||||
183
cccl_upstream/docs/thrust/developer/cmake_options.rst
Normal file
183
cccl_upstream/docs/thrust/developer/cmake_options.rst
Normal file
@@ -0,0 +1,183 @@
|
||||
.. _cmake-options:
|
||||
|
||||
Developer CMake Options
|
||||
=======================
|
||||
|
||||
.. important::
|
||||
|
||||
This document details the CMake options used for **developer builds**
|
||||
of the Thrust tests and examples included in the CCCL repository.
|
||||
The options presented here are not available when using Thrust as an
|
||||
end-user via our installed CMake packages, or when using
|
||||
``add_subdirectory`` / CPM to add CCCL/Thrust to your project's build system.
|
||||
For details and examples of using Thrust as an end-user, please refer
|
||||
to the `Thrust + CMake example <https://github.com/NVIDIA/cccl/tree/main/examples/thrust_flexible_device_system>`_
|
||||
|
||||
|
||||
A Thrust build is configured using CMake options. These may be passed to
|
||||
CMake using
|
||||
|
||||
.. code:: bash
|
||||
|
||||
cmake -D<option_name>=<value> /path/to/thrust/sources
|
||||
|
||||
or configured interactively with the ``ccmake`` or ``cmake-gui``
|
||||
interfaces.
|
||||
|
||||
Thrust supports two build modes. By default, a single configuration is
|
||||
built that targets a specific host system, device system, and C++
|
||||
dialect. When ``THRUST_ENABLE_MULTICONFIG`` is ``ON``, multiple
|
||||
configurations targeting a variety of systems and dialects are
|
||||
generated.
|
||||
|
||||
The CMake options are divided into these categories:
|
||||
|
||||
1. `Generic CMake Options <#generic-cmake-options>`__: Options
|
||||
applicable to all Thrust builds.
|
||||
2. `Single Config CMake Options <#single-config-cmake-options>`__
|
||||
Options applicable only when ``THRUST_ENABLE_MULTICONFIG`` is
|
||||
disabled.
|
||||
3. `Multi Config CMake Options <#multi-config-cmake-options>`__ Options
|
||||
applicable only when ``THRUST_ENABLE_MULTICONFIG`` is enabled.
|
||||
4. `CUDA Specific CMake Options <#cuda-specific-cmake-options>`__
|
||||
Options that control CUDA compilation. Only available when one or
|
||||
more configurations targets the CUDA system.
|
||||
5. `TBB Specific CMake Options <#tbb-specific-cmake-options>`__
|
||||
Options that control TBB compilation. Only available when one or
|
||||
more configurations targets the TBB system.
|
||||
|
||||
Generic CMake Options
|
||||
---------------------
|
||||
|
||||
- ``CMAKE_BUILD_TYPE={Release, Debug, RelWithDebInfo, MinSizeRel}``
|
||||
|
||||
- Standard CMake build option. Default: ``RelWithDebInfo``
|
||||
|
||||
- ``THRUST_ENABLE_HEADER_TESTING={ON, OFF}``
|
||||
|
||||
- Whether to test compile public headers. Default is ``ON``.
|
||||
|
||||
- ``THRUST_ENABLE_TESTING={ON, OFF}``
|
||||
|
||||
- Whether to build unit tests. Default is ``ON``.
|
||||
|
||||
- ``THRUST_ENABLE_EXAMPLES={ON, OFF}``
|
||||
|
||||
- Whether to build examples. Default is ``ON``.
|
||||
|
||||
- ``THRUST_ENABLE_MULTICONFIG={ON, OFF}``
|
||||
|
||||
- Toggles single-config and multi-config modes. Default is ``OFF``
|
||||
(single config).
|
||||
|
||||
- ``THRUST_ENABLE_EXAMPLE_FILECHECK={ON, OFF}``
|
||||
|
||||
- Enable validation of example outputs using the LLVM FileCheck
|
||||
utility. Default is ``OFF``.
|
||||
|
||||
- ``THRUST_ENABLE_INSTALL_RULES={ON, OFF}``
|
||||
|
||||
- If true, installation rules will be generated for thrust. Default
|
||||
is ``ON``.
|
||||
|
||||
- ``THRUST_DISPATCH_TYPE={Dynamic, Force32bit, Force64bit}``
|
||||
|
||||
- Allows the user to force Thrust to use a specific size for the offset type. Default
|
||||
is ``Dynamic``.
|
||||
|
||||
- ``Dynamic`` lets Thrust choose the index type based on input size, allowing
|
||||
large inputs and optimal performance at the cost of increased compile time and binary size,
|
||||
as Thrust will compile each kernel twice, once for 32 bit and once for 64 bit.
|
||||
- ``Force32bit`` forces Thrust to use a 32 bit offset type. This improves compile time and
|
||||
binary size but limits the input size.
|
||||
- ``Force64bit`` forces Thrust to use a 64 bit offset type. This improves compile time and
|
||||
binary size and allows large input sizes. However, it might degrade runtime performance.
|
||||
|
||||
Single Config CMake Options
|
||||
---------------------------
|
||||
|
||||
- ``THRUST_HOST_SYSTEM={CPP, TBB, OMP}``
|
||||
|
||||
- Selects the host system. Default: ``CPP``
|
||||
|
||||
- ``THRUST_DEVICE_SYSTEM={CUDA, TBB, OMP, CPP}``
|
||||
|
||||
- Selects the device system. Default: ``CUDA``
|
||||
|
||||
- ``THRUST_CPP_DIALECT={17, 20}``
|
||||
|
||||
- Selects the C++ standard dialect to use. Default is ``14``
|
||||
(C++14).
|
||||
|
||||
.. _cmake-multi-config-options:
|
||||
|
||||
Multi Config CMake Options
|
||||
--------------------------
|
||||
|
||||
- ``THRUST_MULTICONFIG_ENABLE_DIALECT_CPPXX={ON, OFF}``
|
||||
|
||||
- Toggle whether a specific C++ dialect will be targeted.
|
||||
- Possible values of ``XX`` are ``{17, 20}``.
|
||||
- By default, only C++14 is enabled.
|
||||
|
||||
- ``THRUST_MULTICONFIG_ENABLE_SYSTEM_XXXX={ON, OFF}``
|
||||
|
||||
- Toggle whether a specific system will be targeted.
|
||||
- Possible values of ``XXXX`` are ``{CPP, CUDA, TBB, OMP}``
|
||||
- By default, only ``CPP`` and ``CUDA`` are enabled.
|
||||
|
||||
- ``THRUST_MULTICONFIG_WORKLOAD={SMALL, MEDIUM, LARGE, FULL}``
|
||||
|
||||
- Restricts the host/device combinations that will be targeted.
|
||||
- By default, the ``SMALL`` workload is used.
|
||||
- The full cross product of ``host x device`` systems results in 12
|
||||
configurations, some of which are more important than others. This
|
||||
option can be used to prune some of the less important ones.
|
||||
- ``SMALL``: (3 configs) Minimal coverage and validation of each
|
||||
device system against the ``CPP`` host.
|
||||
- ``MEDIUM``: (6 configs) Cheap extended coverage.
|
||||
- ``LARGE``: (8 configs) Expensive extended coverage. Includes all
|
||||
useful build configurations.
|
||||
- ``FULL``: (12 configs) The complete cross product of all possible
|
||||
build configurations.
|
||||
|
||||
======== =========== ========== ========= ============================
|
||||
Config Workloads Value Expense Note
|
||||
======== =========== ========== ========= ============================
|
||||
CPP/CUDA ``F L M S`` Essential Expensive Validates CUDA against CPP
|
||||
CPP/OMP ``F L M S`` Essential Cheap Validates OMP against CPP
|
||||
CPP/TBB ``F L M S`` Essential Cheap Validates TBB against CPP
|
||||
CPP/CPP ``F L M`` Important Cheap Tests CPP as device
|
||||
OMP/OMP ``F L M`` Important Cheap Tests OMP as host
|
||||
TBB/TBB ``F L M`` Important Cheap Tests TBB as host
|
||||
TBB/CUDA ``F L`` Important Expensive Validates TBB/CUDA interop
|
||||
OMP/CUDA ``F L`` Important Expensive Validates OMP/CUDA interop
|
||||
TBB/OMP ``F`` Not useful Cheap Mixes CPU-parallel systems
|
||||
OMP/TBB ``F`` Not useful Cheap Mixes CPU-parallel systems
|
||||
TBB/CPP ``F`` Not Useful Cheap Parallel host, serial device
|
||||
OMP/CPP ``F`` Not Useful Cheap Parallel host, serial device
|
||||
======== =========== ========== ========= ============================
|
||||
|
||||
CUDA Specific CMake Options
|
||||
---------------------------
|
||||
|
||||
- ``THRUST_ENABLE_RDC_TESTS={ON, OFF}``
|
||||
|
||||
- Enable tests that require separable compilation.
|
||||
- Default is ``ON``.
|
||||
|
||||
- ``THRUST_FORCE_RDC={ON, OFF}``
|
||||
|
||||
- Enable separable compilation on all targets that are agnostic of
|
||||
RDC.
|
||||
- Targets that explicitly require RDC to be enabled or disabled will
|
||||
ignore this setting.
|
||||
- Default is ``OFF``.
|
||||
|
||||
TBB Specific CMake Options
|
||||
--------------------------
|
||||
|
||||
When using TBB as a host or device system, Thrust will automatically find and
|
||||
link against an installed Intel TBB. The TBB installation is discovered through
|
||||
CMake's standard ``find_package(TBB)`` mechanism. No additional Thrust-specific
|
||||
options are provided for TBB configuration.
|
||||
271
cccl_upstream/docs/thrust/developer/systems.rst
Normal file
271
cccl_upstream/docs/thrust/developer/systems.rst
Normal file
@@ -0,0 +1,271 @@
|
||||
.. _systems:
|
||||
|
||||
Thrust systems
|
||||
==============
|
||||
|
||||
Thrust offers a set of algorithms and APIs which can dispatch to various systems.
|
||||
A system is basically a backend and Thrust currently supports the following systems:
|
||||
|
||||
- cpp
|
||||
- cuda
|
||||
- omp
|
||||
- tbb
|
||||
- generic
|
||||
- sequential
|
||||
|
||||
The generic and sequential systems are implementation details.
|
||||
Users can define additional systems to add new backends.
|
||||
|
||||
Each system lives in a directory under ``thrust/system/[detail/]``.
|
||||
|
||||
|
||||
Execution policy base classes
|
||||
*****************************
|
||||
|
||||
Thrust defines common base classes for execution policies:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust::detail {
|
||||
struct execution_policy_marker {};
|
||||
|
||||
template <typename DerivedPolicy>
|
||||
struct execution_policy_base : execution_policy_marker {};
|
||||
}
|
||||
namespace thrust {
|
||||
template <typename DerivedPolicy>
|
||||
struct execution_policy : thrust::detail::execution_policy_base<DerivedPolicy> {};
|
||||
}
|
||||
|
||||
There is an execution policy marker, which sits at the top of the inheritance chain.
|
||||
Then, we have an execution policy base and the actual execution policy,
|
||||
both are templated on the derived policy type (CRTP).
|
||||
|
||||
|
||||
System execution policy base classes and tags
|
||||
*********************************************
|
||||
|
||||
Inside each system directory is a header file ``execution_policy.h``
|
||||
which defines the execution policy and tag for that system,
|
||||
except for the generic system, which does not have a dedicated execution policy.
|
||||
The inheritance for a system, e.g. ``cpp``, looks like this:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust::system::cpp {
|
||||
struct tag; // forward declaration
|
||||
|
||||
template <typename Derived>
|
||||
struct execution_policy; // forward declaration
|
||||
|
||||
template <>
|
||||
struct execution_policy<tag> : ... {};
|
||||
|
||||
struct tag : execution_policy<tag> {};
|
||||
|
||||
template <typename Derived>
|
||||
struct execution_policy : ... {
|
||||
using tag_type = tag;
|
||||
_CCCL_HOST_DEVICE operator tag() const { return {}; }
|
||||
};
|
||||
}
|
||||
|
||||
Each system has it's own execution policy, again templated on a further derived execution policy.
|
||||
The system's execution policy derives (directly or indirectly) from ``thrust::execution_policy``.
|
||||
System execution policies are templates and intended to be further derived from.
|
||||
Additionally, there is a tag for each system, without any template parameters,
|
||||
that derives from the system's execution policy.
|
||||
Tags are non-template class types.
|
||||
The system's execution policy is specialized for the tag type to have no members,
|
||||
otherwise it has an alias for the tag type and can convert to the tag type.
|
||||
Therefore, the execution policy can always be converted to a tag (either by downcasting or by a conversion).
|
||||
|
||||
Various systems now further extend this hierarchy of execution policies, or play other tricks.
|
||||
The ``cpp::execution_policy<Derived>`` inherits from ``sequential::execution_policy<Derived>`` for example
|
||||
(which then inherits from ``thrust::execution_policy``),
|
||||
so any dispatch to an algorithm in the cpp system may fall back to the sequential system.
|
||||
The cuda tag additionally inherits from ``allocator_aware_execution_policy`` to provide further functionality.
|
||||
|
||||
|
||||
Parallel and sequential policy
|
||||
******************************
|
||||
|
||||
Each system also defines an internal parallel policy ``thrust::system::*::detail::par_t``.
|
||||
The cpp system for example:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust::system::cpp {
|
||||
namespace detail {
|
||||
struct par_t : execution_policy<par_t>, ... {};
|
||||
}
|
||||
inline constexpr detail::par_t par;
|
||||
}
|
||||
|
||||
These policies can be used by a user directly, to pick an execution order with a specific backend.
|
||||
Some systems also provide additional parallel execution policies,
|
||||
or member functions which can further configure a policy.
|
||||
The CUDA system for example also provides ``par_nosync_t``
|
||||
or can customize ``par_t`` by calling ``par.on(stream)``.
|
||||
In any case, the type passed to a Thrust algorithm will always be
|
||||
a class derived from the system's ``execution_policy`` class template.
|
||||
|
||||
Thrust further defines a single sequential policy, ``thrust::seq``:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust {
|
||||
namespace detail {
|
||||
struct seq_t : system::detail::sequential::execution_policy<seq_t>, ... { ... };
|
||||
}
|
||||
inline constexpr detail::seq_t seq;
|
||||
}
|
||||
|
||||
which is a global constant of the execution policy to the sequential system.
|
||||
|
||||
|
||||
Host and device system policy
|
||||
*****************************
|
||||
|
||||
Thrust additionally defines an active host and device system,
|
||||
which are selected by the macros ``THRUST_HOST_SYSTEM`` and ``THRUST_DEVICE_SYSTEM``
|
||||
and alias to the corresponding system parallel policies:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust {
|
||||
namespace detail {
|
||||
using host_t = thrust::__THRUST_HOST_SYSTEM_NAMESPACE::detail::par_t;
|
||||
using device_t = thrust::__THRUST_DEVICE_SYSTEM_NAMESPACE::detail::par_t;
|
||||
}
|
||||
inline constexpr detail::host_t host;
|
||||
inline constexpr detail::device_t device;
|
||||
}
|
||||
|
||||
Users most often use ``thrust::host`` and ``thrust::device`` to dispatch to the current host or device system.
|
||||
|
||||
|
||||
Algorithm dispatch
|
||||
******************
|
||||
|
||||
Each Thrust algorithm overload requires an execution policy to determine the backend to use.
|
||||
The policy can either be specified as a first argument by the user,
|
||||
or determined from the other arguments.
|
||||
We will focus on the first case for now.
|
||||
Let's take the public API entry point ``thrust::sort`` as an example.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust {
|
||||
template <typename DerivedPolicy, typename RandomAccessIterator>
|
||||
void sort(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
||||
RandomAccessIterator first, RandomAccessIterator last);
|
||||
}
|
||||
|
||||
We can see that the first argument is a reference to ``execution_policy_base``,
|
||||
the highest base class in the execution policy hierarchy
|
||||
that still carries compile-time information on the most derived type.
|
||||
This ensures that this overload is only selected, when the user passes a valid execution policy.
|
||||
For comparison, C++17 parallel algorithms use a plain template parameter for the execution policy
|
||||
and apply a constraint (SFINAE or requires).
|
||||
The reference is also ``const`` so users can pass a temporary execution policy object,
|
||||
which was just created at the call site.
|
||||
|
||||
Let's have a look at the implementation of the public API entry point:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust {
|
||||
template <typename DerivedPolicy, typename RandomAccessIterator>
|
||||
void sort(const thrust::detail::execution_policy_base<DerivedPolicy>& exec,
|
||||
RandomAccessIterator first, RandomAccessIterator last) {
|
||||
using thrust::system::detail::generic::sort;
|
||||
return sort(thrust::detail::derived_cast(thrust::detail::strip_const(exec)), first, last);
|
||||
}
|
||||
}
|
||||
|
||||
We first bring the generic sort implementation from the generic system into scope.
|
||||
Then, we strip away ``const`` and cast the reference to the execution policy to the most derived type,
|
||||
and perform an unqualified call to ``sort`` with the same arguments apart from the execution policy.
|
||||
|
||||
We have previously seen that execution policies form deeper inheritance chains,
|
||||
and some systems inherit the policy of other systems (e.g. the cpp system inherits the sequential system).
|
||||
The ``derived_cast`` makes sure we perform ADL (argument dependent lookup) using the most specialized execution policy
|
||||
when we try to find overloads of ``sort``.
|
||||
It's also necessary, because when an execution policy is passed to the public API,
|
||||
it binds to the reference of its base class ``execution_policy_base``,
|
||||
for which no backend system exists,
|
||||
so we have to bring the type down again the inheritance chain.
|
||||
|
||||
ADL will find a set of overloads for ``sort`` depending on the type of the execution policy.
|
||||
This set will at least include ``sort`` from the generic system and the API entry point itself.
|
||||
In case of the cpp system, it will also find ``sort`` from the sequential and cpp system.
|
||||
The compiler then ranks the overloads and the best match is the overload from the most specialized execution policy.
|
||||
|
||||
This is neat, because a system does not need to provide implementations of all algorithms.
|
||||
It can just fall back to a generic implementation (falling back to a different algorithm),
|
||||
or to an implementation from a different system.
|
||||
For example, ``thrust::count`` is not implemented in the cpp system,
|
||||
so it falls back to the generic implementation, which uses ``thrust::count_if``.
|
||||
That's also not implemented in the cpp system, so it falls back again to the generic system,
|
||||
which then implements it via ``thrust::transform_reduce``, and so on.
|
||||
As a different example, ``thrust::copy`` for the cpp system brings in the include of the sequential copy implementation,
|
||||
so ADL will find it and prefer it over the generic implementation.
|
||||
|
||||
Any generic algorithm is always outranked by a system specific implementation
|
||||
due to the inheritance chain of execution policies.
|
||||
Let's look at the generic sort implementation's interface:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust::system::detail::generic {
|
||||
template <typename DerivedPolicy, typename RandomAccessIterator>
|
||||
void sort(thrust::execution_policy<DerivedPolicy>& exec,
|
||||
RandomAccessIterator first, RandomAccessIterator last);
|
||||
}
|
||||
|
||||
Notice that it takes the execution policy argument as ``thrust::execution_policy``,
|
||||
which is derived from ``thrust::detail::execution_policy_base``, which appears in the public API.
|
||||
This is why any overload in the generic system will always outrank the public API entry point.
|
||||
|
||||
|
||||
System selection
|
||||
****************
|
||||
|
||||
Thrust also provides overloads of most algorithms without an execution policy,
|
||||
in which case the execution policy is determined based on the remaining arguments, usually iterators.
|
||||
Let's look at ``thrust::adjacent_difference``:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
namespace thrust {
|
||||
template <typename InputIterator, typename OutputIterator>
|
||||
OutputIterator adjacent_difference(InputIterator first, InputIterator last, OutputIterator result) {
|
||||
using system::detail::generic::select_system;
|
||||
using System1 = iterator_system_t<InputIterator>;
|
||||
using System2 = iterator_system_t<OutputIterator>;
|
||||
System1 system1;
|
||||
System2 system2;
|
||||
return thrust::adjacent_difference(select_system(system1, system2), first, last, result);
|
||||
}
|
||||
}
|
||||
|
||||
Such an API is implemented by first bringing ``select_system`` from the generic system into scope.
|
||||
Then, we determine the system types associated with all iterator types via ``thrust::iterator_system``,
|
||||
and instantiate these systems.
|
||||
We then select one of these systems and pass the it to the corresponding overload of ``adjacent_difference``,
|
||||
taking an execution policy as first argument.
|
||||
Notice that this call is qualified with ``thrust::``, so ADL is not used here.
|
||||
The dispatch to the correct system will be performed in the called overload of ``adjacent_difference``.
|
||||
|
||||
``select_system`` is implemented in the generic system, but no other Thrust system provides a different version of it.
|
||||
However, since users can define their own systems,
|
||||
they could also provide a different algorithm for selecting between multiple systems.
|
||||
The generic implementation will select the system to which all other systems are convertible
|
||||
(this is called the minimum system).
|
||||
If we remember how execution policies and tags are defined,
|
||||
they form inheritance hierarchies and tags have conversion operators,
|
||||
so those play a role here.
|
||||
``select_system`` may not find a minimum system,
|
||||
in which case it returns ``thrust::detail::unrelated_systems<System1, System2, ...>``,
|
||||
which usually fails to find an overload via ADL and lead to a compilation error.
|
||||
11
cccl_upstream/docs/thrust/developer_overview.rst
Normal file
11
cccl_upstream/docs/thrust/developer_overview.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
Developer Overview
|
||||
##################
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 1
|
||||
|
||||
developer/cmake_options
|
||||
developer/systems
|
||||
|
||||
This living document serves as a guide to the design of the internal structure of Thrust.
|
||||
61
cccl_upstream/docs/thrust/function_objects.rst
Normal file
61
cccl_upstream/docs/thrust/function_objects.rst
Normal file
@@ -0,0 +1,61 @@
|
||||
.. _thrust-module-api-function-objects:
|
||||
|
||||
Function Objects
|
||||
=================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
function_objects/adaptors
|
||||
function_objects/placeholder
|
||||
function_objects/predefined
|
||||
|
||||
.. _address-stability:
|
||||
|
||||
Copyable arguments
|
||||
------------------
|
||||
|
||||
The C++ language allows to take the address of a parameter and depend on this value for the correctness of a code.
|
||||
Consider this example:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
const int n = 10;
|
||||
thrust::device_vector<int> a(n, 1);
|
||||
thrust::device_vector<int> b(n);
|
||||
int* a_ptr = thrust::raw_pointer_cast(a.data());
|
||||
int* b_ptr = thrust::raw_pointer_cast(b.data());
|
||||
thrust::transform(thrust::device, a.begin(), a.end(), a.begin(),
|
||||
[a_ptr, b_ptr](const int& e) {
|
||||
const auto i = &e - a_ptr; // &e expected to point into global memory
|
||||
return e + b_ptr[i];
|
||||
});
|
||||
|
||||
Here, :code:`thrust::transform` is invoked on the range of elements in :code:`a`.
|
||||
The lambda function computes the index :code:`i` based on the start of the buffer held by :code:`a`
|
||||
and the address of the parameter :code:`e`,
|
||||
thus assuming that the reference :code:`e` points into the same memory block that :code:`a` holds,
|
||||
e.g., global memory for the CUDA system.
|
||||
|
||||
While this example is contrived, such uses of Thrust exist and are currently valid.
|
||||
We strongly urge users though to not rely on parameter addresses,
|
||||
and we reserve the right to disallow this guarantee in the future.
|
||||
|
||||
Relying on the address of a parameter constrains the internal implementation
|
||||
to serve the arguments to the callable directly from the input buffer,
|
||||
which inhibits optimizations, like bulk copies or vectorized loads.
|
||||
To permit the implementation to take advantage of such features,
|
||||
a function object can be marked using :code:`proclaim_copyable_arguments`:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
thrust::transform(thrust::device, a.begin(), a.end(), a.begin(),
|
||||
cuda::std::proclaim_copyable_arguments([](const int& a, const int& b) {
|
||||
return a + b;
|
||||
}));
|
||||
|
||||
Wrapping a function object in :code:`proclaim_copyable_arguments` will attach a marker that the implementation can detect,
|
||||
and use for optimization.
|
||||
Many function objects in libcu++, CUB and Thrust are marked by default,
|
||||
but it does not hurt to mark them explicitly.
|
||||
6
cccl_upstream/docs/thrust/function_objects/adaptors.rst
Normal file
6
cccl_upstream/docs/thrust/function_objects/adaptors.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
.. _thrust-module-api-function-objects-adaptors:
|
||||
|
||||
Function Object Adaptors
|
||||
-------------------------
|
||||
|
||||
- :cpp:class:`thrust::zip_function <thrust::zip_function>`
|
||||
10
cccl_upstream/docs/thrust/function_objects/placeholder.rst
Normal file
10
cccl_upstream/docs/thrust/function_objects/placeholder.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-function-objects-placeholder:
|
||||
|
||||
Placeholder Objects
|
||||
--------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/*placeholder*
|
||||
11
cccl_upstream/docs/thrust/function_objects/predefined.rst
Normal file
11
cccl_upstream/docs/thrust/function_objects/predefined.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
.. _thrust-module-api-function-objects-predefined:
|
||||
|
||||
Function Objects
|
||||
----------------
|
||||
|
||||
Users are encouraged to use the standard C++ function objects available from `<cuda/std/functional>`.
|
||||
Thrust provides the following additional function objects:
|
||||
|
||||
- :cpp:struct:`thrust::square <thrust::square>`
|
||||
- :cpp:struct:`thrust::project1st <thrust::project1st>`
|
||||
- :cpp:struct:`thrust::project2nd <thrust::project2nd>`
|
||||
114
cccl_upstream/docs/thrust/index.rst
Normal file
114
cccl_upstream/docs/thrust/index.rst
Normal file
@@ -0,0 +1,114 @@
|
||||
.. _thrust-module:
|
||||
|
||||
Thrust
|
||||
======
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
:maxdepth: 2
|
||||
|
||||
Overview <self>
|
||||
algorithms
|
||||
containers
|
||||
function_objects
|
||||
iterators
|
||||
memory_management
|
||||
numerics
|
||||
parallel_execution_policies
|
||||
random
|
||||
system
|
||||
utility
|
||||
API reference <api/index>
|
||||
developer_overview
|
||||
|
||||
Thrust is the C++ parallel algorithms library which inspired the introduction of parallel algorithms to the
|
||||
C++ Standard Library. Thrust's **high-level** interface greatly enhances programmer **productivity** while
|
||||
enabling performance portability between GPUs and multicore CPUs.
|
||||
It builds on top of established parallel programming frameworks (such as CUDA, TBB, and OpenMP).
|
||||
It also provides a number of general-purpose facilities similar to those found in the C++ Standard Library.
|
||||
|
||||
Thrust is an open source project; it is available on `GitHub <https://github.com/NVIDIA/cccl>`__
|
||||
and included in the NVIDIA HPC SDK and CUDA Toolkit.
|
||||
If you have one of those SDKs installed, no additional installation or compiler flags are needed to use Thrust.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Thrust is best learned through examples.
|
||||
|
||||
-------------
|
||||
CMake Example
|
||||
-------------
|
||||
|
||||
A complete, standalone example project showing how to write a CMake build system that uses Thrust with any supported
|
||||
device system is available in the CCCL repository `here <https://github.com/NVIDIA/cccl/tree/main/examples/thrust_flexible_device_system>`__.
|
||||
|
||||
------------------
|
||||
Thrust API Example
|
||||
------------------
|
||||
|
||||
The following example generates random numbers serially and then transfers them
|
||||
to a parallel device where they are sorted.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <thrust/host_vector.h>
|
||||
#include <thrust/device_vector.h>
|
||||
#include <thrust/generate.h>
|
||||
#include <thrust/sort.h>
|
||||
#include <thrust/copy.h>
|
||||
#include <thrust/random.h>
|
||||
|
||||
int main() {
|
||||
// Generate 32M random numbers serially.
|
||||
thrust::default_random_engine rng(1337);
|
||||
thrust::uniform_int_distribution<int> dist;
|
||||
thrust::host_vector<int> h_vec(32 << 20);
|
||||
thrust::generate(h_vec.begin(), h_vec.end(), [&] { return dist(rng); });
|
||||
|
||||
// Transfer data to the device.
|
||||
thrust::device_vector<int> d_vec = h_vec;
|
||||
|
||||
// Sort data on the device.
|
||||
thrust::sort(d_vec.begin(), d_vec.end());
|
||||
|
||||
// Transfer data back to host.
|
||||
thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
|
||||
}
|
||||
|
||||
|
||||
`See it on Godbolt <https://godbolt.org/z/GeWEd8Er9>`__
|
||||
|
||||
This example demonstrates computing the sum of some random numbers in parallel:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <thrust/host_vector.h>
|
||||
#include <thrust/device_vector.h>
|
||||
#include <thrust/generate.h>
|
||||
#include <thrust/reduce.h>
|
||||
#include <thrust/functional.h>
|
||||
#include <thrust/random.h>
|
||||
|
||||
int main() {
|
||||
// Generate random data serially.
|
||||
thrust::default_random_engine rng(1337);
|
||||
thrust::uniform_real_distribution<double> dist(-50.0, 50.0);
|
||||
thrust::host_vector<double> h_vec(32 << 20);
|
||||
thrust::generate(h_vec.begin(), h_vec.end(), [&] { return dist(rng); });
|
||||
|
||||
// Transfer to device and compute the sum.
|
||||
thrust::device_vector<double> d_vec = h_vec;
|
||||
double x = thrust::reduce(d_vec.begin(), d_vec.end(), 0, thrust::plus<int>());
|
||||
}
|
||||
|
||||
`See it on Godbolt <https://godbolt.org/z/cnsbWWME7>`__
|
||||
|
||||
Getting The Thrust Source Code & Developing Thrust
|
||||
-----------------------------------------------------
|
||||
|
||||
Thrust started as a stand-alone project, but as of March 2024 Thrust is a part of the
|
||||
CUDA Core Compute Libraries (CCCL). Please refer to the
|
||||
`CCCL Getting Started section <https://github.com/NVIDIA/cccl?tab=readme-ov-file#getting-started>`__ and the
|
||||
`Contributing Guide: <https://github.com/NVIDIA/cccl/blob/main/CONTRIBUTING.md>`__ for instructions on how to
|
||||
get started developing the CCCL sources.
|
||||
88
cccl_upstream/docs/thrust/iterators.rst
Normal file
88
cccl_upstream/docs/thrust/iterators.rst
Normal file
@@ -0,0 +1,88 @@
|
||||
.. _thrust-module-api-iterators:
|
||||
|
||||
Iterators
|
||||
===========
|
||||
|
||||
Thrust provides a rich collection of iterators that extend beyond the C++ standard library.
|
||||
|
||||
.. important::
|
||||
|
||||
Many Thrust iterators have direct replacements in libcu++,
|
||||
which are newer and thus fix some of the shortcomings of Thrust's iterators.
|
||||
They should generally be preferred. See :ref:`libcudacxx-extended-api-iterators` for more.
|
||||
|
||||
|
||||
Fancy iterators
|
||||
-------------------------
|
||||
|
||||
Thrust provides the following fancy iterators:
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
api/group__fancyiterator_*
|
||||
|
||||
|
||||
Iterator traits
|
||||
-------------------------
|
||||
|
||||
Thrust offers the following traits to inspect iterators:
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
api/group__iterator__traits_*
|
||||
|
||||
Iterator tags
|
||||
-------------------------
|
||||
|
||||
Thrust provides the following iterator category tags:
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
api/group__iterator__tags_*
|
||||
|
||||
Additionally, the following utilities for working with iterator category tags are provided:
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
api/group__iterator__tag__utilities_*
|
||||
|
||||
Thrust provides the following iterator traversal tags:
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
api/structthrust*__traversal__tag
|
||||
|
||||
|
||||
Iterator model
|
||||
-------------------------
|
||||
|
||||
Thrust's iterators extend the C++ standard library iterator model and were inspired by Boost.Iterator.
|
||||
In the C++ standard library, iterators are mostly distinguished by their iterator category (before C++20),
|
||||
and their iterator concept (since C++20).
|
||||
This is governed by the nested ``iterator_category`` and ``iterator_concept`` types, respectively,
|
||||
which in standard C++ are one of:
|
||||
|
||||
- ``input_iterator_tag``
|
||||
- ``output_iterator_tag``
|
||||
- ``forward_iterator_tag``
|
||||
- ``bidirectional_iterator_tag``
|
||||
- ``random_access_iterator_tag``
|
||||
- ``contiguous_iterator_tag`` (since C++20)
|
||||
|
||||
Thrust extends this model by introducing the notion of an iterator traversal and an iterator system.
|
||||
In order to fit into the existing schema of iterators,
|
||||
it encodes this additional information into the ``iterator_category``,
|
||||
which is no longer one of the standard tags listed above,
|
||||
but a templated type carrying the iterator tag, iterator traversal and iterator system.
|
||||
This information can be extracted using the :cpp:class:`thrust::iterator_traversal <thrust::iterator_traversal>`
|
||||
and :cpp:class:`thrust::iterator_system <thrust::iterator_system>` traits.
|
||||
12
cccl_upstream/docs/thrust/memory_management.rst
Normal file
12
cccl_upstream/docs/thrust/memory_management.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-memory-management:
|
||||
|
||||
Memory Management
|
||||
==================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
memory_management/allocators
|
||||
memory_management/memory_resources
|
||||
api/group__memory__management*
|
||||
18
cccl_upstream/docs/thrust/memory_management/allocators.rst
Normal file
18
cccl_upstream/docs/thrust/memory_management/allocators.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
.. _thrust-module-api-memory-management-allocators:
|
||||
|
||||
Allocators
|
||||
-----------
|
||||
|
||||
- :cpp:class:`thrust::device_allocator <thrust::device_allocator>`
|
||||
- :cpp:class:`thrust::device_malloc_allocator <thrust::device_malloc_allocator>`
|
||||
- :cpp:class:`thrust::device_new_allocator <thrust::device_new_allocator>`
|
||||
- :cpp:class:`thrust::universal_allocator <thrust::universal_allocator>`
|
||||
- :cpp:class:`thrust::universal_host_pinned_allocator <thrust::universal_host_pinned_allocator>`
|
||||
- :cpp:class:`thrust::mr::allocator <thrust::mr::allocator>`
|
||||
- :cpp:class:`thrust::mr::stateless_resource_allocator <thrust::mr::stateless_resource_allocator>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__allocators*
|
||||
@@ -0,0 +1,18 @@
|
||||
.. _thrust-module-api-memory-management-memory-resources:
|
||||
|
||||
Memory Resources
|
||||
-----------------
|
||||
|
||||
- :cpp:class:`thrust::mr::disjoint_unsynchronized_pool_resource <thrust::mr::disjoint_unsynchronized_pool_resource>`
|
||||
- :cpp:struct:`thrust::mr::disjoint_synchronized_pool_resource <thrust::mr::disjoint_synchronized_pool_resource>`
|
||||
- :cpp:class:`thrust::mr::memory_resource <thrust::mr::memory_resource>`
|
||||
- :cpp:class:`thrust::mr::new_delete_resource <thrust::mr::new_delete_resource>`
|
||||
- :cpp:class:`thrust::mr::unsynchronized_pool_resource <thrust::mr::unsynchronized_pool_resource>`
|
||||
- :cpp:struct:`thrust::mr::pool_options <thrust::mr::pool_options>`
|
||||
- :cpp:struct:`thrust::mr::synchronized_pool_resource <thrust::mr::synchronized_pool_resource>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__memory__resources*
|
||||
12
cccl_upstream/docs/thrust/numerics.rst
Normal file
12
cccl_upstream/docs/thrust/numerics.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-numerics:
|
||||
|
||||
Numerics
|
||||
========
|
||||
|
||||
- :cpp:struct:`thrust::complex <thrust::complex>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
api/group__complex*
|
||||
13
cccl_upstream/docs/thrust/parallel_execution_policies.rst
Normal file
13
cccl_upstream/docs/thrust/parallel_execution_policies.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _thrust-module-api-parallel-execution-policies:
|
||||
|
||||
Parallel Execution Policies
|
||||
===========================
|
||||
|
||||
- :cpp:struct:`thrust::host_execution_policy <thrust::host_execution_policy>`
|
||||
- :cpp:struct:`thrust::device_execution_policy <thrust::device_execution_policy>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
api/group__execution__policies*
|
||||
13
cccl_upstream/docs/thrust/random.rst
Normal file
13
cccl_upstream/docs/thrust/random.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _thrust-module-api-random-number-generators:
|
||||
|
||||
Random Number Generators
|
||||
========================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
random/predefined
|
||||
random/distributions
|
||||
random/engine
|
||||
random/engine_adaptors
|
||||
14
cccl_upstream/docs/thrust/random/distributions.rst
Normal file
14
cccl_upstream/docs/thrust/random/distributions.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _thrust-module-api-random-number-generators-distributions:
|
||||
|
||||
Random Number Distributions
|
||||
----------------------------
|
||||
|
||||
- :cpp:class:`thrust::random::normal_distribution <thrust::random::normal_distribution>`
|
||||
- :cpp:class:`thrust::random::uniform_int_distribution <thrust::random::uniform_int_distribution>`
|
||||
- :cpp:class:`thrust::random::uniform_real_distribution <thrust::random::uniform_real_distribution>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__random__number__distributions*
|
||||
14
cccl_upstream/docs/thrust/random/engine.rst
Normal file
14
cccl_upstream/docs/thrust/random/engine.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _thrust-module-api-random-number-generators-engines:
|
||||
|
||||
Random Number Engines
|
||||
----------------------
|
||||
|
||||
- :cpp:class:`thrust::random::linear_congruential_engine <thrust::random::linear_congruential_engine>`
|
||||
- :cpp:class:`thrust::random::linear_feedback_shift_engine <thrust::random::linear_feedback_shift_engine>`
|
||||
- :cpp:class:`thrust::random::subtract_with_carry_engine <thrust::random::subtract_with_carry_engine>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__random__number__engine__templates*
|
||||
13
cccl_upstream/docs/thrust/random/engine_adaptors.rst
Normal file
13
cccl_upstream/docs/thrust/random/engine_adaptors.rst
Normal file
@@ -0,0 +1,13 @@
|
||||
.. _thrust-module-api-random-number-generators-engine-adaptors:
|
||||
|
||||
Random Number Engine Adaptors
|
||||
------------------------------
|
||||
|
||||
- :cpp:class:`thrust::random::discard_block_engine <thrust::random::discard_block_engine>`
|
||||
- :cpp:class:`thrust::random::xor_combine_engine <thrust::random::xor_combine_engine>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__random__number__engine__adaptors*
|
||||
10
cccl_upstream/docs/thrust/random/predefined.rst
Normal file
10
cccl_upstream/docs/thrust/random/predefined.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-random-number-generators-predefined:
|
||||
|
||||
Random Number Engines with Predefined Parameters
|
||||
-------------------------------------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__predefined__random*
|
||||
11
cccl_upstream/docs/thrust/system.rst
Normal file
11
cccl_upstream/docs/thrust/system.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
.. _thrust-module-api-system:
|
||||
|
||||
System
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
system/systems
|
||||
system/diagnostics
|
||||
17
cccl_upstream/docs/thrust/system/diagnostics.rst
Normal file
17
cccl_upstream/docs/thrust/system/diagnostics.rst
Normal file
@@ -0,0 +1,17 @@
|
||||
.. _thrust-module-api-system-diagnostics:
|
||||
|
||||
System Diagnostics
|
||||
----------------------------
|
||||
|
||||
- :cpp:struct:`thrust::system::is_error_code_enum <thrust::system::is_error_code_enum>`
|
||||
- :cpp:struct:`thrust::system::is_error_condition_enum <thrust::system::is_error_condition_enum>`
|
||||
- :cpp:class:`thrust::system::error_category <thrust::system::error_category>`
|
||||
- :cpp:class:`thrust::system::error_code <thrust::system::error_code>`
|
||||
- :cpp:class:`thrust::system::error_condition <thrust::system::error_condition>`
|
||||
- :cpp:class:`thrust::system::system_error <thrust::system::system_error>`
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__system__diagnostics*
|
||||
10
cccl_upstream/docs/thrust/system/systems.rst
Normal file
10
cccl_upstream/docs/thrust/system/systems.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
.. _thrust-module-api-system-systems:
|
||||
|
||||
Systems
|
||||
----------------------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/group__system__backends*
|
||||
12
cccl_upstream/docs/thrust/utility.rst
Normal file
12
cccl_upstream/docs/thrust/utility.rst
Normal file
@@ -0,0 +1,12 @@
|
||||
.. _thrust-module-api-utility:
|
||||
|
||||
Utility
|
||||
========
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 2
|
||||
|
||||
utility/pair
|
||||
utility/tuple
|
||||
utility/type_traits
|
||||
14
cccl_upstream/docs/thrust/utility/pair.rst
Normal file
14
cccl_upstream/docs/thrust/utility/pair.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _thrust-module-api-utility-pair:
|
||||
|
||||
Pair
|
||||
----
|
||||
|
||||
Thrust provides an implementations of `std::pair`, that is pulled in from `libcu++`.
|
||||
|
||||
It is recommended to replace `thrust::pair` and `thrust::make_pair` with `cuda::std::pair` and `cuda::std::make_pair`.
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/*pair*
|
||||
14
cccl_upstream/docs/thrust/utility/tuple.rst
Normal file
14
cccl_upstream/docs/thrust/utility/tuple.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
.. _thrust-module-api-utility-tuple:
|
||||
|
||||
Tuple
|
||||
------
|
||||
|
||||
Thrust provides an implementation of `std::tuple`, that is pulled in from `libcu++`.
|
||||
|
||||
It is recommended to replace `thrust::tuple` with `cuda::std::tuple`.
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/*tuple*
|
||||
11
cccl_upstream/docs/thrust/utility/type_traits.rst
Normal file
11
cccl_upstream/docs/thrust/utility/type_traits.rst
Normal file
@@ -0,0 +1,11 @@
|
||||
.. _thrust-module-api-utility-type-traits:
|
||||
|
||||
Type Traits
|
||||
-----------
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
../api/struct*proclaim__contiguous__iterator*
|
||||
../api/group__type__traits*
|
||||
Reference in New Issue
Block a user