Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- cuda_toolkit/include/__algorithm/swap_ranges.h +40 -0
- cuda_toolkit/include/__cccl/ptx_isa.h +105 -0
- cuda_toolkit/include/__cccl/version.h +23 -0
- cuda_toolkit/include/__cccl/visibility.h +46 -0
- cuda_toolkit/include/__concepts/_One_of.h +41 -0
- cuda_toolkit/include/__concepts/__concept_macros.h +299 -0
- cuda_toolkit/include/__concepts/arithmetic.h +61 -0
- cuda_toolkit/include/__concepts/assignable.h +64 -0
- cuda_toolkit/include/__concepts/boolean_testable.h +63 -0
- cuda_toolkit/include/__concepts/class_or_enum.h +47 -0
- cuda_toolkit/include/__concepts/common_reference_with.h +74 -0
- cuda_toolkit/include/__concepts/common_with.h +102 -0
- cuda_toolkit/include/__concepts/constructible.h +125 -0
- cuda_toolkit/include/__concepts/convertible_to.h +78 -0
- cuda_toolkit/include/__concepts/copyable.h +64 -0
- cuda_toolkit/include/__concepts/derived_from.h +58 -0
- cuda_toolkit/include/__concepts/destructible.h +78 -0
- cuda_toolkit/include/__concepts/different_from.h +40 -0
- cuda_toolkit/include/__concepts/equality_comparable.h +111 -0
- cuda_toolkit/include/__concepts/invocable.h +80 -0
- cuda_toolkit/include/__concepts/movable.h +62 -0
- cuda_toolkit/include/__concepts/predicate.h +56 -0
- cuda_toolkit/include/__concepts/regular.h +57 -0
- cuda_toolkit/include/__concepts/relation.h +78 -0
- cuda_toolkit/include/__concepts/same_as.h +44 -0
- cuda_toolkit/include/__concepts/semiregular.h +57 -0
- cuda_toolkit/include/__concepts/swappable.h +228 -0
- cuda_toolkit/include/__concepts/totally_ordered.h +113 -0
- cuda_toolkit/include/__cuda/atomic.h +264 -0
- cuda_toolkit/include/__cuda/atomic_prelude.h +56 -0
- cuda_toolkit/include/__cuda/barrier.h +1257 -0
- cuda_toolkit/include/__cuda/chrono.h +65 -0
- cuda_toolkit/include/__cuda/climits_prelude.h +95 -0
- cuda_toolkit/include/__cuda/cstddef_prelude.h +31 -0
- cuda_toolkit/include/__cuda/cstdint_prelude.h +84 -0
- cuda_toolkit/include/__cuda/latch.h +31 -0
- cuda_toolkit/include/__cuda/ptx.h +1373 -0
- cuda_toolkit/include/__cuda/ptx/parallel_synchronization_and_communication_instructions_mbarrier.h +1070 -0
- cuda_toolkit/include/__cuda/ptx/ptx_dot_variants.h +176 -0
- cuda_toolkit/include/__cuda/ptx/ptx_helper_functions.h +68 -0
- cuda_toolkit/include/__cuda/semaphore.h +46 -0
- cuda_toolkit/include/__expected/bad_expected_access.h +79 -0
- cuda_toolkit/include/__expected/expected.h +1790 -0
- cuda_toolkit/include/__expected/expected_base.h +1048 -0
- cuda_toolkit/include/__expected/unexpect.h +38 -0
- cuda_toolkit/include/__expected/unexpected.h +170 -0
- cuda_toolkit/include/__functional/binary_function.h +59 -0
- cuda_toolkit/include/__functional/binary_negate.h +59 -0
- cuda_toolkit/include/__functional/bind.h +417 -0
- cuda_toolkit/include/__functional/bind_back.h +79 -0
cuda_toolkit/include/__algorithm/swap_ranges.h
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___ALGORITHM_SWAP_RANGES_H
|
| 11 |
+
#define _LIBCUDACXX___ALGORITHM_SWAP_RANGES_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif // __cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__utility/swap.h"
|
| 18 |
+
|
| 19 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 20 |
+
# pragma GCC system_header
|
| 21 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 22 |
+
# pragma clang system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 24 |
+
# pragma system_header
|
| 25 |
+
#endif // no system header
|
| 26 |
+
|
| 27 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 28 |
+
|
| 29 |
+
template <class _ForwardIterator1, class _ForwardIterator2>
|
| 30 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 31 |
+
_ForwardIterator2 swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2)
|
| 32 |
+
{
|
| 33 |
+
for(; __first1 != __last1; ++__first1, (void) ++__first2)
|
| 34 |
+
swap(*__first1, *__first2);
|
| 35 |
+
return __first2;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 39 |
+
|
| 40 |
+
#endif // _LIBCUDACXX___ALGORITHM_SWAP_RANGES_H
|
cuda_toolkit/include/__cccl/ptx_isa.h
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 4 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef __CCCL_PTX_ISA_H_
|
| 12 |
+
#define __CCCL_PTX_ISA_H_
|
| 13 |
+
|
| 14 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 15 |
+
# pragma GCC system_header
|
| 16 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 17 |
+
# pragma clang system_header
|
| 18 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 19 |
+
# pragma system_header
|
| 20 |
+
#endif // no system header
|
| 21 |
+
|
| 22 |
+
#include <nv/target> // __CUDA_MINIMUM_ARCH__ and friends
|
| 23 |
+
|
| 24 |
+
/*
|
| 25 |
+
* Targeting macros
|
| 26 |
+
*
|
| 27 |
+
* Information from:
|
| 28 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes
|
| 29 |
+
*/
|
| 30 |
+
|
| 31 |
+
// PTX ISA 8.3 is available from CUDA 12.3, driver r545
|
| 32 |
+
// The first define is for future major versions of CUDACC.
|
| 33 |
+
// We make sure that these get the highest known PTX ISA version.
|
| 34 |
+
#if (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ > 12)) || (!defined(__CUDACC_VER_MAJOR__))
|
| 35 |
+
# define __cccl_ptx_isa 830ULL
|
| 36 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 12 && __CUDACC_VER_MINOR__ >= 3)) \
|
| 37 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 38 |
+
# define __cccl_ptx_isa 830ULL
|
| 39 |
+
// PTX ISA 8.2 is available from CUDA 12.2, driver r535
|
| 40 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 12 && __CUDACC_VER_MINOR__ >= 2)) \
|
| 41 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 42 |
+
# define __cccl_ptx_isa 820ULL
|
| 43 |
+
// PTX ISA 8.1 is available from CUDA 12.1, driver r530
|
| 44 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 12 && __CUDACC_VER_MINOR__ >= 1)) \
|
| 45 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 46 |
+
# define __cccl_ptx_isa 810ULL
|
| 47 |
+
// PTX ISA 8.0 is available from CUDA 12.0, driver r525
|
| 48 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 12 && __CUDACC_VER_MINOR__ >= 0)) \
|
| 49 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 50 |
+
# define __cccl_ptx_isa 800ULL
|
| 51 |
+
// PTX ISA 7.8 is available from CUDA 11.8, driver r520
|
| 52 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 8)) \
|
| 53 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 54 |
+
# define __cccl_ptx_isa 780ULL
|
| 55 |
+
// PTX ISA 7.7 is available from CUDA 11.7, driver r515
|
| 56 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 7)) \
|
| 57 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 58 |
+
# define __cccl_ptx_isa 770ULL
|
| 59 |
+
// PTX ISA 7.6 is available from CUDA 11.6, driver r510
|
| 60 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 6)) \
|
| 61 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 62 |
+
# define __cccl_ptx_isa 760ULL
|
| 63 |
+
// PTX ISA 7.5 is available from CUDA 11.5, driver r495
|
| 64 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 5)) \
|
| 65 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 66 |
+
# define __cccl_ptx_isa 750ULL
|
| 67 |
+
// PTX ISA 7.4 is available from CUDA 11.4, driver r470
|
| 68 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 4)) \
|
| 69 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 70 |
+
# define __cccl_ptx_isa 740ULL
|
| 71 |
+
// PTX ISA 7.3 is available from CUDA 11.3, driver r465
|
| 72 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 3)) \
|
| 73 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 74 |
+
# define __cccl_ptx_isa 730ULL
|
| 75 |
+
// PTX ISA 7.2 is available from CUDA 11.2, driver r460
|
| 76 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 2)) \
|
| 77 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 78 |
+
# define __cccl_ptx_isa 720ULL
|
| 79 |
+
// PTX ISA 7.1 is available from CUDA 11.1, driver r455
|
| 80 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 1)) \
|
| 81 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 82 |
+
# define __cccl_ptx_isa 710ULL
|
| 83 |
+
// PTX ISA 7.0 is available from CUDA 11.0, driver r445
|
| 84 |
+
#elif (defined(__CUDACC_VER_MAJOR__) && (__CUDACC_VER_MAJOR__ >= 11 && __CUDACC_VER_MINOR__ >= 0)) \
|
| 85 |
+
|| (!defined(__CUDACC_VER_MAJOR__))
|
| 86 |
+
# define __cccl_ptx_isa 700ULL
|
| 87 |
+
// Fallback case. Define the ISA version to be zero. This ensures that the macro is always defined.
|
| 88 |
+
#else
|
| 89 |
+
# define __cccl_ptx_isa 0ULL
|
| 90 |
+
#endif
|
| 91 |
+
|
| 92 |
+
// We define certain feature test macros depending on availability. When
|
| 93 |
+
// __CUDA_MINIMUM_ARCH__ is not available, we define the following features
|
| 94 |
+
// depending on PTX ISA. This permits checking for the feature in host code.
|
| 95 |
+
// When __CUDA_MINIMUM_ARCH__ is available, we only enable the feature when the
|
| 96 |
+
// hardware supports it.
|
| 97 |
+
#if __cccl_ptx_isa >= 800
|
| 98 |
+
#if (!defined(__CUDA_MINIMUM_ARCH__)) \
|
| 99 |
+
|| (defined(__CUDA_MINIMUM_ARCH__) && 900 <= __CUDA_MINIMUM_ARCH__)
|
| 100 |
+
# define __cccl_lib_local_barrier_arrive_tx
|
| 101 |
+
# define __cccl_lib_experimental_ctk12_cp_async_exposure
|
| 102 |
+
#endif
|
| 103 |
+
#endif // __cccl_ptx_isa >= 800
|
| 104 |
+
|
| 105 |
+
#endif // __CCCL_PTX_ISA_H_
|
cuda_toolkit/include/__cccl/version.h
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 4 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef __CCCL_VERSION_H
|
| 12 |
+
#define __CCCL_VERSION_H
|
| 13 |
+
|
| 14 |
+
#define CCCL_VERSION 2003002
|
| 15 |
+
#define CCCL_MAJOR_VERSION (CCCL_VERSION / 1000000)
|
| 16 |
+
#define CCCL_MINOR_VERSION (((CCCL_VERSION / 1000) % 1000))
|
| 17 |
+
#define CCCL_PATCH_VERSION (CCCL_VERSION % 1000)
|
| 18 |
+
|
| 19 |
+
#if CCCL_PATCH_VERSION > 99
|
| 20 |
+
#error "CCCL patch version cannot be greater than 99 for compatibility with Thrust/CUB's MMMmmmpp format."
|
| 21 |
+
#endif
|
| 22 |
+
|
| 23 |
+
#endif // __CCCL_VERSION_H
|
cuda_toolkit/include/__cccl/visibility.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 4 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef __CCCL_VISIBILITY_H
|
| 12 |
+
#define __CCCL_VISIBILITY_H
|
| 13 |
+
|
| 14 |
+
#ifndef __CCCL_CONFIG
|
| 15 |
+
#error "<__cccl/visibility.h> should only be included in from <cuda/__cccl_config>"
|
| 16 |
+
#endif // __CCCL_CONFIG
|
| 17 |
+
|
| 18 |
+
// We want to ensure that all warning emmiting from this header are supressed
|
| 19 |
+
#if defined(_CCCL_FORCE_SYSTEM_HEADER_GCC)
|
| 20 |
+
# pragma GCC system_header
|
| 21 |
+
#elif defined(_CCCL_FORCE_SYSTEM_HEADER_CLANG)
|
| 22 |
+
# pragma clang system_header
|
| 23 |
+
#elif defined(_CCCL_FORCE_SYSTEM_HEADER_MSVC)
|
| 24 |
+
# pragma system_header
|
| 25 |
+
#endif // no system header
|
| 26 |
+
|
| 27 |
+
// For unknown reasons, nvc++ need to selectively disable this warning
|
| 28 |
+
// We do not want to use our usual macro because that would have push / pop semantics
|
| 29 |
+
#if defined(_CCCL_COMPILER_NVHPC)
|
| 30 |
+
# pragma nv_diag_suppress 1407
|
| 31 |
+
#endif // _CCCL_COMPILER_NVHPC
|
| 32 |
+
|
| 33 |
+
// Enable us to hide kernels
|
| 34 |
+
#if defined(_CCCL_COMPILER_MSVC)
|
| 35 |
+
# define _CCCL_ATTRIBUTE_HIDDEN
|
| 36 |
+
#elif defined(_CCCL_COMPILER_NVRTC)
|
| 37 |
+
# define _CCCL_ATTRIBUTE_HIDDEN
|
| 38 |
+
#else // ^^^ _CCCL_COMPILER_NVRTC ^^^ / vvv _CCCL_COMPILER_NVRTC vvv
|
| 39 |
+
# define _CCCL_ATTRIBUTE_HIDDEN __attribute__ ((__visibility__("hidden")))
|
| 40 |
+
#endif // !_CCCL_COMPILER_NVRTC
|
| 41 |
+
|
| 42 |
+
#if !defined(CCCL_DETAIL_KERNEL_ATTRIBUTES)
|
| 43 |
+
# define CCCL_DETAIL_KERNEL_ATTRIBUTES __global__ _CCCL_ATTRIBUTE_HIDDEN
|
| 44 |
+
#endif // !CCCL_DETAIL_KERNEL_ATTRIBUTES
|
| 45 |
+
|
| 46 |
+
#endif // __CCCL_VISIBILITY_H
|
cuda_toolkit/include/__concepts/_One_of.h
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_ONE_OF_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_ONE_OF_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/disjunction.h"
|
| 19 |
+
#include "../__type_traits/is_same.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 14
|
| 32 |
+
template <class _Ty, class... _Others>
|
| 33 |
+
_LIBCUDACXX_CONCEPT _One_of = (is_same_v<_Ty, _Others> || ...);
|
| 34 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 35 |
+
template <class _Ty, class... _Others>
|
| 36 |
+
_LIBCUDACXX_CONCEPT _One_of = _LIBCUDACXX_TRAIT(disjunction, is_same<_Ty, _Others>...);
|
| 37 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 38 |
+
|
| 39 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 40 |
+
|
| 41 |
+
#endif // _LIBCUDACXX___CONCEPTS_ONE_OF_H
|
cuda_toolkit/include/__concepts/__concept_macros.h
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Copyright (c) Facebook, Inc. and its affiliates.
|
| 4 |
+
// Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
| 5 |
+
//
|
| 6 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 7 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 8 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 9 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 10 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 11 |
+
//
|
| 12 |
+
//===----------------------------------------------------------------------===//
|
| 13 |
+
|
| 14 |
+
#ifndef _CUDA___CONCEPTS
|
| 15 |
+
#define _CUDA___CONCEPTS
|
| 16 |
+
|
| 17 |
+
#ifndef __cuda_std__
|
| 18 |
+
#include <__config>
|
| 19 |
+
#endif //__cuda_std__
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 30 |
+
|
| 31 |
+
#define _LIBCUDACXX_PP_CAT_(_Xp, ...) _Xp##__VA_ARGS__
|
| 32 |
+
#define _LIBCUDACXX_PP_CAT(_Xp, ...) _LIBCUDACXX_PP_CAT_(_Xp, __VA_ARGS__)
|
| 33 |
+
|
| 34 |
+
#define _LIBCUDACXX_PP_CAT2_(_Xp, ...) _Xp##__VA_ARGS__
|
| 35 |
+
#define _LIBCUDACXX_PP_CAT2(_Xp, ...) _LIBCUDACXX_PP_CAT2_(_Xp, __VA_ARGS__)
|
| 36 |
+
|
| 37 |
+
#define _LIBCUDACXX_PP_CAT3_(_Xp, ...) _Xp##__VA_ARGS__
|
| 38 |
+
#define _LIBCUDACXX_PP_CAT3(_Xp, ...) _LIBCUDACXX_PP_CAT3_(_Xp, __VA_ARGS__)
|
| 39 |
+
|
| 40 |
+
#define _LIBCUDACXX_PP_CAT4_(_Xp, ...) _Xp##__VA_ARGS__
|
| 41 |
+
#define _LIBCUDACXX_PP_CAT4(_Xp, ...) _LIBCUDACXX_PP_CAT4_(_Xp, __VA_ARGS__)
|
| 42 |
+
|
| 43 |
+
#define _LIBCUDACXX_PP_EVAL_(_Xp, _ARGS) _Xp _ARGS
|
| 44 |
+
#define _LIBCUDACXX_PP_EVAL(_Xp, ...) _LIBCUDACXX_PP_EVAL_(_Xp, (__VA_ARGS__))
|
| 45 |
+
|
| 46 |
+
#define _LIBCUDACXX_PP_EVAL2_(_Xp, _ARGS) _Xp _ARGS
|
| 47 |
+
#define _LIBCUDACXX_PP_EVAL2(_Xp, ...) _LIBCUDACXX_PP_EVAL2_(_Xp, (__VA_ARGS__))
|
| 48 |
+
|
| 49 |
+
#define _LIBCUDACXX_PP_EXPAND(...) __VA_ARGS__
|
| 50 |
+
#define _LIBCUDACXX_PP_EAT(...)
|
| 51 |
+
|
| 52 |
+
#define _LIBCUDACXX_PP_CHECK(...) \
|
| 53 |
+
_LIBCUDACXX_PP_EXPAND(_LIBCUDACXX_PP_CHECK_N(__VA_ARGS__, 0, ))
|
| 54 |
+
#define _LIBCUDACXX_PP_CHECK_N(_Xp, _Num, ...) _Num
|
| 55 |
+
#define _LIBCUDACXX_PP_PROBE(_Xp) _Xp, 1,
|
| 56 |
+
#define _LIBCUDACXX_PP_PROBE_N(_Xp, _Num) _Xp, _Num,
|
| 57 |
+
|
| 58 |
+
#define _LIBCUDACXX_PP_IS_PAREN(_Xp) \
|
| 59 |
+
_LIBCUDACXX_PP_CHECK(_LIBCUDACXX_PP_IS_PAREN_PROBE _Xp)
|
| 60 |
+
#define _LIBCUDACXX_PP_IS_PAREN_PROBE(...) _LIBCUDACXX_PP_PROBE(~)
|
| 61 |
+
|
| 62 |
+
// The final _LIBCUDACXX_PP_EXPAND here is to avoid
|
| 63 |
+
// https://stackoverflow.com/questions/5134523/msvc-doesnt-expand-va-args-correctly
|
| 64 |
+
#define _LIBCUDACXX_PP_COUNT(...) \
|
| 65 |
+
_LIBCUDACXX_PP_EXPAND(_LIBCUDACXX_PP_COUNT_( \
|
| 66 |
+
__VA_ARGS__, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, \
|
| 67 |
+
35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, \
|
| 68 |
+
17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, )) \
|
| 69 |
+
/**/
|
| 70 |
+
#define _LIBCUDACXX_PP_COUNT_( \
|
| 71 |
+
_01, _02, _03, _04, _05, _06, _07, _08, _09, _10, _11, _12, _13, _14, _15, \
|
| 72 |
+
_16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
|
| 73 |
+
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, \
|
| 74 |
+
_46, _47, _48, _49, _50, _Np, ...) \
|
| 75 |
+
_Np /**/
|
| 76 |
+
|
| 77 |
+
#define _LIBCUDACXX_PP_IIF(_BIT) _LIBCUDACXX_PP_CAT_(_LIBCUDACXX_PP_IIF_, _BIT)
|
| 78 |
+
#define _LIBCUDACXX_PP_IIF_0(_TRUE, ...) __VA_ARGS__
|
| 79 |
+
#define _LIBCUDACXX_PP_IIF_1(_TRUE, ...) _TRUE
|
| 80 |
+
|
| 81 |
+
#define _LIBCUDACXX_PP_LPAREN (
|
| 82 |
+
|
| 83 |
+
#define _LIBCUDACXX_PP_NOT(_BIT) _LIBCUDACXX_PP_CAT_(_LIBCUDACXX_PP_NOT_, _BIT)
|
| 84 |
+
#define _LIBCUDACXX_PP_NOT_0 1
|
| 85 |
+
#define _LIBCUDACXX_PP_NOT_1 0
|
| 86 |
+
|
| 87 |
+
#define _LIBCUDACXX_PP_EMPTY()
|
| 88 |
+
#define _LIBCUDACXX_PP_COMMA() ,
|
| 89 |
+
#define _LIBCUDACXX_PP_LBRACE() {
|
| 90 |
+
#define _LIBCUDACXX_PP_RBRACE() }
|
| 91 |
+
#define _LIBCUDACXX_PP_COMMA_IIF(_Xp) \
|
| 92 |
+
_LIBCUDACXX_PP_IIF(_Xp)(_LIBCUDACXX_PP_EMPTY, _LIBCUDACXX_PP_COMMA)() /**/
|
| 93 |
+
|
| 94 |
+
#define _LIBCUDACXX_PP_FOR_EACH(_Mp, ...) \
|
| 95 |
+
_LIBCUDACXX_PP_FOR_EACH_N(_LIBCUDACXX_PP_COUNT(__VA_ARGS__), _Mp, __VA_ARGS__)
|
| 96 |
+
#define _LIBCUDACXX_PP_FOR_EACH_N(_Np, _Mp, ...) \
|
| 97 |
+
_LIBCUDACXX_PP_CAT2(_LIBCUDACXX_PP_FOR_EACH_, _Np)(_Mp, __VA_ARGS__)
|
| 98 |
+
#define _LIBCUDACXX_PP_FOR_EACH_1(_Mp, _1) _Mp(_1)
|
| 99 |
+
#define _LIBCUDACXX_PP_FOR_EACH_2(_Mp, _1, _2) _Mp(_1) _Mp(_2)
|
| 100 |
+
#define _LIBCUDACXX_PP_FOR_EACH_3(_Mp, _1, _2, _3) _Mp(_1) _Mp(_2) _Mp(_3)
|
| 101 |
+
#define _LIBCUDACXX_PP_FOR_EACH_4(_Mp, _1, _2, _3, _4) \
|
| 102 |
+
_Mp(_1) _Mp(_2) _Mp(_3) _Mp(_4)
|
| 103 |
+
#define _LIBCUDACXX_PP_FOR_EACH_5(_Mp, _1, _2, _3, _4, _5) \
|
| 104 |
+
_Mp(_1) _Mp(_2) _Mp(_3) _Mp(_4) _Mp(_5)
|
| 105 |
+
#define _LIBCUDACXX_PP_FOR_EACH_6(_Mp, _1, _2, _3, _4, _5, _6) \
|
| 106 |
+
_Mp(_1) _Mp(_2) _Mp(_3) _Mp(_4) _Mp(_5) _Mp(_6)
|
| 107 |
+
#define _LIBCUDACXX_PP_FOR_EACH_7(_Mp, _1, _2, _3, _4, _5, _6, _7) \
|
| 108 |
+
_Mp(_1) _Mp(_2) _Mp(_3) _Mp(_4) _Mp(_5) _Mp(_6) _Mp(_7)
|
| 109 |
+
#define _LIBCUDACXX_PP_FOR_EACH_8(_Mp, _1, _2, _3, _4, _5, _6, _7, _8) \
|
| 110 |
+
_Mp(_1) _Mp(_2) _Mp(_3) _Mp(_4) _Mp(_5) _Mp(_6) _Mp(_7) _Mp(_8)
|
| 111 |
+
|
| 112 |
+
#define _LIBCUDACXX_PP_PROBE_EMPTY_PROBE__LIBCUDACXX_PP_PROBE_EMPTY \
|
| 113 |
+
_LIBCUDACXX_PP_PROBE(~)
|
| 114 |
+
|
| 115 |
+
#define _LIBCUDACXX_PP_PROBE_EMPTY()
|
| 116 |
+
#define _LIBCUDACXX_PP_IS_NOT_EMPTY(...) \
|
| 117 |
+
_LIBCUDACXX_PP_EVAL( \
|
| 118 |
+
_LIBCUDACXX_PP_CHECK, \
|
| 119 |
+
_LIBCUDACXX_PP_CAT(_LIBCUDACXX_PP_PROBE_EMPTY_PROBE_, \
|
| 120 |
+
_LIBCUDACXX_PP_PROBE_EMPTY __VA_ARGS__())) \
|
| 121 |
+
/**/
|
| 122 |
+
|
| 123 |
+
#define _LIBCUDACXX_PP_TAIL(_, ...) __VA_ARGS__
|
| 124 |
+
|
| 125 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M0(_REQ) \
|
| 126 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_(_REQ)(_REQ)
|
| 127 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M1(_REQ) _LIBCUDACXX_PP_EXPAND _REQ
|
| 128 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_(...) \
|
| 129 |
+
{ _LIBCUDACXX_PP_FOR_EACH(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) }
|
| 130 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_(_REQ) \
|
| 131 |
+
_LIBCUDACXX_PP_CAT3( \
|
| 132 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_, \
|
| 133 |
+
_LIBCUDACXX_PP_EVAL( \
|
| 134 |
+
_LIBCUDACXX_PP_CHECK, \
|
| 135 |
+
_LIBCUDACXX_PP_CAT3(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_, \
|
| 136 |
+
_REQ))) \
|
| 137 |
+
/**/
|
| 138 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_requires \
|
| 139 |
+
_LIBCUDACXX_PP_PROBE_N(~, 1)
|
| 140 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_noexcept \
|
| 141 |
+
_LIBCUDACXX_PP_PROBE_N(~, 2)
|
| 142 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_PROBE_typename \
|
| 143 |
+
_LIBCUDACXX_PP_PROBE_N(~, 3)
|
| 144 |
+
|
| 145 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_0 _LIBCUDACXX_PP_EXPAND
|
| 146 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_1 \
|
| 147 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT
|
| 148 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_2 \
|
| 149 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT
|
| 150 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_SELECT_3 \
|
| 151 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT
|
| 152 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_OR_NOEXCEPT(_REQ) \
|
| 153 |
+
_LIBCUDACXX_PP_CAT4(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_, _REQ)
|
| 154 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_PROBE_typename _LIBCUDACXX_PP_PROBE(~)
|
| 155 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_SELECT_(_Xp, ...) \
|
| 156 |
+
_LIBCUDACXX_PP_CAT3( \
|
| 157 |
+
_LIBCUDACXX_PP_EAT_TYPENAME_SELECT_, \
|
| 158 |
+
_LIBCUDACXX_PP_EVAL( \
|
| 159 |
+
_LIBCUDACXX_PP_CHECK, \
|
| 160 |
+
_LIBCUDACXX_PP_CAT3(_LIBCUDACXX_PP_EAT_TYPENAME_PROBE_, _Xp)))
|
| 161 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_(...) \
|
| 162 |
+
_LIBCUDACXX_PP_EVAL2(_LIBCUDACXX_PP_EAT_TYPENAME_SELECT_, __VA_ARGS__, ) \
|
| 163 |
+
(__VA_ARGS__)
|
| 164 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_SELECT_0(...) __VA_ARGS__
|
| 165 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_SELECT_1(...) \
|
| 166 |
+
_LIBCUDACXX_PP_CAT3(_LIBCUDACXX_PP_EAT_TYPENAME_, __VA_ARGS__)
|
| 167 |
+
#define _LIBCUDACXX_PP_EAT_TYPENAME_typename
|
| 168 |
+
|
| 169 |
+
#if (defined(__cpp_concepts) && _LIBCUDACXX_STD_VER >= 20) || \
|
| 170 |
+
defined(_LIBCUDACXX_DOXYGEN_INVOKED)
|
| 171 |
+
|
| 172 |
+
#define _LIBCUDACXX_CONCEPT concept
|
| 173 |
+
|
| 174 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT(_NAME, ...) \
|
| 175 |
+
concept _NAME = \
|
| 176 |
+
_LIBCUDACXX_PP_CAT(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_, __VA_ARGS__)
|
| 177 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_requires(...) \
|
| 178 |
+
requires(__VA_ARGS__) _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_
|
| 179 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M(_REQ) \
|
| 180 |
+
_LIBCUDACXX_PP_CAT2(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M, \
|
| 181 |
+
_LIBCUDACXX_PP_IS_PAREN(_REQ)) \
|
| 182 |
+
(_REQ);
|
| 183 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_requires(...) \
|
| 184 |
+
requires __VA_ARGS__
|
| 185 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_typename(...) \
|
| 186 |
+
typename _LIBCUDACXX_PP_EAT_TYPENAME_(__VA_ARGS__)
|
| 187 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept(...) \
|
| 188 |
+
{ __VA_ARGS__ } \
|
| 189 |
+
noexcept
|
| 190 |
+
|
| 191 |
+
#define _LIBCUDACXX_FRAGMENT(_NAME, ...) _NAME<__VA_ARGS__>
|
| 192 |
+
|
| 193 |
+
#else
|
| 194 |
+
|
| 195 |
+
#define _LIBCUDACXX_CONCEPT _LIBCUDACXX_INLINE_VAR constexpr bool
|
| 196 |
+
|
| 197 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT(_NAME, ...) \
|
| 198 |
+
_LIBCUDACXX_INLINE_VISIBILITY auto _NAME##_LIBCUDACXX_CONCEPT_FRAGMENT_impl_ \
|
| 199 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_##__VA_ARGS__ > {} \
|
| 200 |
+
template <typename... _As> \
|
| 201 |
+
_LIBCUDACXX_INLINE_VISIBILITY char _NAME##_LIBCUDACXX_CONCEPT_FRAGMENT_( \
|
| 202 |
+
_Concept::_Tag<_As...> *, \
|
| 203 |
+
decltype(&_NAME##_LIBCUDACXX_CONCEPT_FRAGMENT_impl_<_As...>)); \
|
| 204 |
+
_LIBCUDACXX_INLINE_VISIBILITY char( \
|
| 205 |
+
&_NAME##_LIBCUDACXX_CONCEPT_FRAGMENT_(...))[2] /**/
|
| 206 |
+
#if defined(_MSC_VER) && !defined(__clang__)
|
| 207 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_TRUE(...) \
|
| 208 |
+
_Concept::_Is_true<decltype(_LIBCUDACXX_PP_FOR_EACH( \
|
| 209 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M, __VA_ARGS__) void())>()
|
| 210 |
+
#else
|
| 211 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_TRUE(...) \
|
| 212 |
+
!(decltype(_LIBCUDACXX_PP_FOR_EACH(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M, \
|
| 213 |
+
__VA_ARGS__) void(), \
|
| 214 |
+
false){})
|
| 215 |
+
#endif
|
| 216 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_requires(...) \
|
| 217 |
+
(__VA_ARGS__)->_Concept::_Enable_if_t < _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_2_
|
| 218 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_2_(...) \
|
| 219 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT_TRUE(__VA_ARGS__)
|
| 220 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M(_REQ) \
|
| 221 |
+
_LIBCUDACXX_PP_CAT2(_LIBCUDACXX_CONCEPT_FRAGMENT_REQS_M, \
|
| 222 |
+
_LIBCUDACXX_PP_IS_PAREN(_REQ)) \
|
| 223 |
+
(_REQ),
|
| 224 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_requires(...) \
|
| 225 |
+
_Concept::_Requires<__VA_ARGS__>
|
| 226 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_typename(...) \
|
| 227 |
+
static_cast<_Concept::_Tag<__VA_ARGS__> *>(nullptr)
|
| 228 |
+
#if defined(_LIBCUDACXX_COMPILER_GCC)
|
| 229 |
+
// GCC can't mangle noexcept expressions, so just check that the
|
| 230 |
+
// expression is well-formed.
|
| 231 |
+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70790
|
| 232 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept(...) __VA_ARGS__
|
| 233 |
+
#else
|
| 234 |
+
#define _LIBCUDACXX_CONCEPT_FRAGMENT_REQS_REQUIRES_noexcept(...) \
|
| 235 |
+
_Concept::_Requires<noexcept(__VA_ARGS__)>
|
| 236 |
+
#endif
|
| 237 |
+
|
| 238 |
+
#define _LIBCUDACXX_FRAGMENT(_NAME, ...) \
|
| 239 |
+
(1u == sizeof(_NAME##_LIBCUDACXX_CONCEPT_FRAGMENT_( \
|
| 240 |
+
static_cast<_Concept::_Tag<__VA_ARGS__> *>(nullptr), nullptr)))
|
| 241 |
+
|
| 242 |
+
#endif
|
| 243 |
+
|
| 244 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 245 |
+
// _LIBCUDACXX_TEMPLATE
|
| 246 |
+
// Usage:
|
| 247 |
+
// _LIBCUDACXX_TEMPLATE(typename A, typename _Bp)
|
| 248 |
+
// _LIBCUDACXX_REQUIRES( Concept1<A> _LIBCUDACXX_AND Concept2<_Bp>)
|
| 249 |
+
// void foo(A a, _Bp b)
|
| 250 |
+
// {}
|
| 251 |
+
#if (defined(__cpp_concepts) && _LIBCUDACXX_STD_VER >= 20)
|
| 252 |
+
#define _LIBCUDACXX_TEMPLATE(...) template <__VA_ARGS__>
|
| 253 |
+
#define _LIBCUDACXX_REQUIRES(...) requires __VA_ARGS__
|
| 254 |
+
#define _LIBCUDACXX_AND &&
|
| 255 |
+
#define _LIBCUDACXX_TRAILING_REQUIRES(...) -> __VA_ARGS__ requires _LIBCUDACXX_PP_EXPAND
|
| 256 |
+
#else
|
| 257 |
+
#define _LIBCUDACXX_TEMPLATE(...) template <__VA_ARGS__
|
| 258 |
+
#define _LIBCUDACXX_REQUIRES(...) \
|
| 259 |
+
, bool _LIBCUDACXX_true_ = true, \
|
| 260 |
+
_Concept::_Enable_if_t <__VA_ARGS__ && \
|
| 261 |
+
_LIBCUDACXX_true_, \
|
| 262 |
+
int > = 0 > /**/
|
| 263 |
+
#define _LIBCUDACXX_AND \
|
| 264 |
+
&& _LIBCUDACXX_true_, int > = 0, _Concept::_Enable_if_t <
|
| 265 |
+
#define _LIBCUDACXX_TRAILING_REQUIRES_AUX_(...) \
|
| 266 |
+
, __VA_ARGS__>
|
| 267 |
+
#define _LIBCUDACXX_TRAILING_REQUIRES(...) \
|
| 268 |
+
-> _Concept::_Requires_t<__VA_ARGS__ _LIBCUDACXX_TRAILING_REQUIRES_AUX_
|
| 269 |
+
#endif
|
| 270 |
+
|
| 271 |
+
namespace _Concept {
|
| 272 |
+
template <bool> struct _Select {};
|
| 273 |
+
|
| 274 |
+
template <> struct _Select<true> { template <class _Tp> using type = _Tp; };
|
| 275 |
+
|
| 276 |
+
template <bool _Bp, class _Tp = void>
|
| 277 |
+
using _Enable_if_t = typename _Select<_Bp>::template type<_Tp>;
|
| 278 |
+
|
| 279 |
+
template <class _Tp, bool _Bp>
|
| 280 |
+
using _Requires_t = typename _Select<_Bp>::template type<_Tp>;
|
| 281 |
+
|
| 282 |
+
template <typename...> struct _Tag;
|
| 283 |
+
template <class>
|
| 284 |
+
_LIBCUDACXX_INLINE_VISIBILITY inline constexpr bool _Is_true() {
|
| 285 |
+
return true;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
#if defined(_LIBCUDACXX_COMPILER_CLANG) || defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 289 |
+
template <bool _Bp>
|
| 290 |
+
_LIBCUDACXX_INLINE_VISIBILITY _Concept::_Enable_if_t<_Bp> _Requires() {}
|
| 291 |
+
#else
|
| 292 |
+
template <bool _Bp, _Concept::_Enable_if_t<_Bp, int> = 0>
|
| 293 |
+
_LIBCUDACXX_INLINE_VAR constexpr int _Requires = 0;
|
| 294 |
+
#endif
|
| 295 |
+
} // namespace _Concept
|
| 296 |
+
|
| 297 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 298 |
+
|
| 299 |
+
#endif //_CUDA___CONCEPTS
|
cuda_toolkit/include/__concepts/arithmetic.h
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_ARITHMETIC_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_ARITHMETIC_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/is_arithmetic.h"
|
| 19 |
+
#include "../__type_traits/is_floating_point.h"
|
| 20 |
+
#include "../__type_traits/is_integral.h"
|
| 21 |
+
#include "../__type_traits/is_signed_integer.h"
|
| 22 |
+
#include "../__type_traits/is_signed.h"
|
| 23 |
+
#include "../__type_traits/is_unsigned_integer.h"
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 34 |
+
|
| 35 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 36 |
+
|
| 37 |
+
// [concepts.arithmetic], arithmetic concepts
|
| 38 |
+
|
| 39 |
+
template<class _Tp>
|
| 40 |
+
_LIBCUDACXX_CONCEPT integral = _LIBCUDACXX_TRAIT(is_integral, _Tp);
|
| 41 |
+
|
| 42 |
+
template<class _Tp>
|
| 43 |
+
_LIBCUDACXX_CONCEPT signed_integral = integral<_Tp> && _LIBCUDACXX_TRAIT(is_signed, _Tp);
|
| 44 |
+
|
| 45 |
+
template<class _Tp>
|
| 46 |
+
_LIBCUDACXX_CONCEPT unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
|
| 47 |
+
|
| 48 |
+
template<class _Tp>
|
| 49 |
+
_LIBCUDACXX_CONCEPT floating_point = _LIBCUDACXX_TRAIT(is_floating_point, _Tp);
|
| 50 |
+
|
| 51 |
+
// Concept helpers for the internal type traits for the fundamental types.
|
| 52 |
+
template <class _Tp>
|
| 53 |
+
_LIBCUDACXX_CONCEPT __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
|
| 54 |
+
template <class _Tp>
|
| 55 |
+
_LIBCUDACXX_CONCEPT __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
|
| 56 |
+
|
| 57 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 58 |
+
|
| 59 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 60 |
+
|
| 61 |
+
#endif // _LIBCUDACXX___CONCEPTS_ARITHMETIC_H
|
cuda_toolkit/include/__concepts/assignable.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_ASSIGNABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_ASSIGNABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/common_reference_with.h"
|
| 19 |
+
#include "../__concepts/same_as.h"
|
| 20 |
+
#include "../__type_traits/is_reference.h"
|
| 21 |
+
#include "../__type_traits/make_const_lvalue_ref.h"
|
| 22 |
+
#include "../__utility/forward.h"
|
| 23 |
+
|
| 24 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 25 |
+
# pragma GCC system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 27 |
+
# pragma clang system_header
|
| 28 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 29 |
+
# pragma system_header
|
| 30 |
+
#endif // no system header
|
| 31 |
+
|
| 32 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 33 |
+
|
| 34 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 35 |
+
|
| 36 |
+
// [concept.assignable]
|
| 37 |
+
|
| 38 |
+
template<class _Lhs, class _Rhs>
|
| 39 |
+
concept assignable_from =
|
| 40 |
+
is_lvalue_reference_v<_Lhs> &&
|
| 41 |
+
common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> &&
|
| 42 |
+
requires (_Lhs __lhs, _Rhs&& __rhs) {
|
| 43 |
+
{ __lhs = _CUDA_VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 47 |
+
|
| 48 |
+
template<class _Lhs, class _Rhs>
|
| 49 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 50 |
+
__assignable_from_,
|
| 51 |
+
requires(_Lhs __lhs, _Rhs&& __rhs)(
|
| 52 |
+
requires(_LIBCUDACXX_TRAIT(is_lvalue_reference, _Lhs)),
|
| 53 |
+
requires(common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>>),
|
| 54 |
+
requires(same_as<_Lhs, decltype(__lhs = _CUDA_VSTD::forward<_Rhs>(__rhs))>)
|
| 55 |
+
));
|
| 56 |
+
|
| 57 |
+
template<class _Lhs, class _Rhs>
|
| 58 |
+
_LIBCUDACXX_CONCEPT assignable_from = _LIBCUDACXX_FRAGMENT(__assignable_from_, _Lhs, _Rhs);
|
| 59 |
+
|
| 60 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 61 |
+
|
| 62 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 63 |
+
|
| 64 |
+
#endif // _LIBCUDACXX___CONCEPTS_ASSIGNABLE_H
|
cuda_toolkit/include/__concepts/boolean_testable.h
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_BOOLEAN_TESTABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_BOOLEAN_TESTABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/convertible_to.h"
|
| 19 |
+
#include "../__utility/forward.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 32 |
+
|
| 33 |
+
// [concepts.booleantestable]
|
| 34 |
+
|
| 35 |
+
template<class _Tp>
|
| 36 |
+
concept __boolean_testable_impl = convertible_to<_Tp, bool>;
|
| 37 |
+
|
| 38 |
+
template<class _Tp>
|
| 39 |
+
concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) {
|
| 40 |
+
{ !_CUDA_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl;
|
| 41 |
+
};
|
| 42 |
+
|
| 43 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 44 |
+
|
| 45 |
+
template<class _Tp>
|
| 46 |
+
_LIBCUDACXX_CONCEPT __boolean_testable_impl = convertible_to<_Tp, bool>;
|
| 47 |
+
|
| 48 |
+
template<class _Tp>
|
| 49 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 50 |
+
__boolean_testable_,
|
| 51 |
+
requires(_Tp&& __t)(
|
| 52 |
+
requires(__boolean_testable_impl<_Tp>),
|
| 53 |
+
requires(__boolean_testable_impl<decltype(!_CUDA_VSTD::forward<_Tp>(__t))>)
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
template<class _Tp>
|
| 57 |
+
_LIBCUDACXX_CONCEPT __boolean_testable = _LIBCUDACXX_FRAGMENT(__boolean_testable_, _Tp);
|
| 58 |
+
|
| 59 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 60 |
+
|
| 61 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 62 |
+
|
| 63 |
+
#endif // _LIBCUDACXX___CONCEPTS_BOOLEAN_TESTABLE_H
|
cuda_toolkit/include/__concepts/class_or_enum.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_CLASS_OR_ENUM_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_CLASS_OR_ENUM_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/is_class.h"
|
| 19 |
+
#include "../__type_traits/is_enum.h"
|
| 20 |
+
#include "../__type_traits/is_union.h"
|
| 21 |
+
#include "../__type_traits/remove_cvref.h"
|
| 22 |
+
|
| 23 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 24 |
+
# pragma GCC system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 26 |
+
# pragma clang system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 28 |
+
# pragma system_header
|
| 29 |
+
#endif // no system header
|
| 30 |
+
|
| 31 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 32 |
+
|
| 33 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 34 |
+
|
| 35 |
+
template<class _Tp>
|
| 36 |
+
_LIBCUDACXX_CONCEPT __class_or_enum = _LIBCUDACXX_TRAIT(is_class, _Tp) || _LIBCUDACXX_TRAIT(is_union, _Tp) || _LIBCUDACXX_TRAIT(is_enum, _Tp);
|
| 37 |
+
|
| 38 |
+
// Work around Clang bug https://llvm.org/PR52970
|
| 39 |
+
// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
|
| 40 |
+
template<class _Tp>
|
| 41 |
+
_LIBCUDACXX_CONCEPT __workaround_52970 = _LIBCUDACXX_TRAIT(is_class, remove_cvref_t<_Tp>) || _LIBCUDACXX_TRAIT(is_union, remove_cvref_t<_Tp>);
|
| 42 |
+
|
| 43 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 44 |
+
|
| 45 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 46 |
+
|
| 47 |
+
#endif // _LIBCUDACXX___CONCEPTS_CLASS_OR_ENUM_H
|
cuda_toolkit/include/__concepts/common_reference_with.h
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_COMMON_REFERENCE_WITH_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_COMMON_REFERENCE_WITH_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/convertible_to.h"
|
| 19 |
+
#include "../__concepts/same_as.h"
|
| 20 |
+
#include "../__type_traits/common_reference.h"
|
| 21 |
+
#include "../__type_traits/copy_cv.h"
|
| 22 |
+
#include "../__type_traits/copy_cvref.h"
|
| 23 |
+
|
| 24 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 25 |
+
# pragma GCC system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 27 |
+
# pragma clang system_header
|
| 28 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 29 |
+
# pragma system_header
|
| 30 |
+
#endif // no system header
|
| 31 |
+
|
| 32 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 33 |
+
|
| 34 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 35 |
+
|
| 36 |
+
// [concept.commonref]
|
| 37 |
+
|
| 38 |
+
template<class _Tp, class _Up>
|
| 39 |
+
concept common_reference_with =
|
| 40 |
+
same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> &&
|
| 41 |
+
convertible_to<_Tp, common_reference_t<_Tp, _Up>> &&
|
| 42 |
+
convertible_to<_Up, common_reference_t<_Tp, _Up>>;
|
| 43 |
+
|
| 44 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 45 |
+
|
| 46 |
+
template<class _Tp, class _Up>
|
| 47 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 48 |
+
__common_reference_exists_,
|
| 49 |
+
requires()(
|
| 50 |
+
typename(common_reference_t<_Tp, _Up>),
|
| 51 |
+
typename(common_reference_t<_Up, _Tp>)
|
| 52 |
+
));
|
| 53 |
+
|
| 54 |
+
template<class _Tp, class _Up>
|
| 55 |
+
_LIBCUDACXX_CONCEPT _Common_reference_exists = _LIBCUDACXX_FRAGMENT(__common_reference_exists_, _Tp, _Up);
|
| 56 |
+
|
| 57 |
+
template<class _Tp, class _Up>
|
| 58 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 59 |
+
__common_reference_with_,
|
| 60 |
+
requires()(
|
| 61 |
+
requires(_Common_reference_exists<_Tp, _Up>),
|
| 62 |
+
requires(same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>>),
|
| 63 |
+
requires(convertible_to<_Tp, common_reference_t<_Tp, _Up>>),
|
| 64 |
+
requires(convertible_to<_Up, common_reference_t<_Tp, _Up>>)
|
| 65 |
+
));
|
| 66 |
+
|
| 67 |
+
template<class _Tp, class _Up>
|
| 68 |
+
_LIBCUDACXX_CONCEPT common_reference_with = _LIBCUDACXX_FRAGMENT(__common_reference_with_, _Tp, _Up);
|
| 69 |
+
|
| 70 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 71 |
+
|
| 72 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 73 |
+
|
| 74 |
+
#endif // _LIBCUDACXX___CONCEPTS_COMMON_REFERENCE_WITH_H
|
cuda_toolkit/include/__concepts/common_with.h
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_COMMON_WITH_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_COMMON_WITH_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/common_reference_with.h"
|
| 19 |
+
#include "../__concepts/same_as.h"
|
| 20 |
+
#include "../__type_traits/add_lvalue_reference.h"
|
| 21 |
+
#include "../__type_traits/common_type.h"
|
| 22 |
+
#include "../__utility/declval.h"
|
| 23 |
+
|
| 24 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 25 |
+
# pragma GCC system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 27 |
+
# pragma clang system_header
|
| 28 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 29 |
+
# pragma system_header
|
| 30 |
+
#endif // no system header
|
| 31 |
+
|
| 32 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 33 |
+
|
| 34 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 35 |
+
|
| 36 |
+
// [concept.common]
|
| 37 |
+
|
| 38 |
+
template<class _Tp, class _Up>
|
| 39 |
+
concept common_with =
|
| 40 |
+
same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> &&
|
| 41 |
+
requires {
|
| 42 |
+
static_cast<common_type_t<_Tp, _Up>>(_CUDA_VSTD::declval<_Tp>());
|
| 43 |
+
static_cast<common_type_t<_Tp, _Up>>(_CUDA_VSTD::declval<_Up>());
|
| 44 |
+
} &&
|
| 45 |
+
common_reference_with<
|
| 46 |
+
add_lvalue_reference_t<const _Tp>,
|
| 47 |
+
add_lvalue_reference_t<const _Up>> &&
|
| 48 |
+
common_reference_with<
|
| 49 |
+
add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
|
| 50 |
+
common_reference_t<
|
| 51 |
+
add_lvalue_reference_t<const _Tp>,
|
| 52 |
+
add_lvalue_reference_t<const _Up>>>;
|
| 53 |
+
|
| 54 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 55 |
+
|
| 56 |
+
template<class _Tp, class _Up>
|
| 57 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 58 |
+
__common_type_exists_,
|
| 59 |
+
requires()(
|
| 60 |
+
typename(common_type_t<_Tp, _Up>),
|
| 61 |
+
typename(common_type_t<_Up, _Tp>)
|
| 62 |
+
));
|
| 63 |
+
|
| 64 |
+
template<class _Tp, class _Up>
|
| 65 |
+
_LIBCUDACXX_CONCEPT _Common_type_exists = _LIBCUDACXX_FRAGMENT(__common_type_exists_, _Tp, _Up);
|
| 66 |
+
|
| 67 |
+
template<class _Tp, class _Up>
|
| 68 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 69 |
+
__common_type_constructible_,
|
| 70 |
+
requires()(
|
| 71 |
+
requires(_Common_type_exists<_Tp, _Up>),
|
| 72 |
+
static_cast<common_type_t<_Tp, _Up>>(_CUDA_VSTD::declval<_Tp>()),
|
| 73 |
+
static_cast<common_type_t<_Tp, _Up>>(_CUDA_VSTD::declval<_Up>())
|
| 74 |
+
));
|
| 75 |
+
|
| 76 |
+
template<class _Tp, class _Up>
|
| 77 |
+
_LIBCUDACXX_CONCEPT _Common_type_constructible = _LIBCUDACXX_FRAGMENT(__common_type_constructible_, _Tp, _Up);
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
template<class _Tp, class _Up>
|
| 81 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 82 |
+
__common_with_,
|
| 83 |
+
requires()(
|
| 84 |
+
requires(_Common_type_constructible<_Tp, _Up>),
|
| 85 |
+
requires(same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>>),
|
| 86 |
+
requires(common_reference_with<
|
| 87 |
+
add_lvalue_reference_t<const _Tp>,
|
| 88 |
+
add_lvalue_reference_t<const _Up>>),
|
| 89 |
+
requires(common_reference_with<
|
| 90 |
+
add_lvalue_reference_t<common_type_t<_Tp, _Up>>,
|
| 91 |
+
common_reference_t<
|
| 92 |
+
add_lvalue_reference_t<const _Tp>,
|
| 93 |
+
add_lvalue_reference_t<const _Up>>>)));
|
| 94 |
+
|
| 95 |
+
template<class _Tp, class _Up>
|
| 96 |
+
_LIBCUDACXX_CONCEPT common_with = _LIBCUDACXX_FRAGMENT(__common_with_, _Tp, _Up);
|
| 97 |
+
|
| 98 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 99 |
+
|
| 100 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 101 |
+
|
| 102 |
+
#endif // _LIBCUDACXX___CONCEPTS_COMMON_WITH_H
|
cuda_toolkit/include/__concepts/constructible.h
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_CONSTRUCTIBLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_CONSTRUCTIBLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/convertible_to.h"
|
| 19 |
+
#include "../__concepts/destructible.h"
|
| 20 |
+
#include "../__type_traits/add_lvalue_reference.h"
|
| 21 |
+
#include "../__type_traits/is_constructible.h"
|
| 22 |
+
|
| 23 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 24 |
+
# pragma GCC system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 26 |
+
# pragma clang system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 28 |
+
# pragma system_header
|
| 29 |
+
#endif // no system header
|
| 30 |
+
|
| 31 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 32 |
+
|
| 33 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 34 |
+
|
| 35 |
+
// [concept.constructible]
|
| 36 |
+
template<class _Tp, class... _Args>
|
| 37 |
+
concept constructible_from =
|
| 38 |
+
destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
|
| 39 |
+
|
| 40 |
+
// [concept.default.init]
|
| 41 |
+
template<class _Tp>
|
| 42 |
+
concept __default_initializable = requires { ::new _Tp; };
|
| 43 |
+
|
| 44 |
+
template<class _Tp>
|
| 45 |
+
concept default_initializable = constructible_from<_Tp> &&
|
| 46 |
+
requires { _Tp{}; } && __default_initializable<_Tp>;
|
| 47 |
+
|
| 48 |
+
// [concept.moveconstructible]
|
| 49 |
+
template<class _Tp>
|
| 50 |
+
concept move_constructible =
|
| 51 |
+
constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
|
| 52 |
+
|
| 53 |
+
// [concept.copyconstructible]
|
| 54 |
+
template<class _Tp>
|
| 55 |
+
concept copy_constructible =
|
| 56 |
+
move_constructible<_Tp> &&
|
| 57 |
+
constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
|
| 58 |
+
constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
|
| 59 |
+
constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
|
| 60 |
+
|
| 61 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 62 |
+
|
| 63 |
+
template<class _Tp, class... _Args>
|
| 64 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 65 |
+
__constructible_from_,
|
| 66 |
+
requires()(
|
| 67 |
+
requires(destructible<_Tp>),
|
| 68 |
+
requires(_LIBCUDACXX_TRAIT(is_constructible, _Tp, _Args...))
|
| 69 |
+
));
|
| 70 |
+
|
| 71 |
+
template<class _Tp, class... _Args>
|
| 72 |
+
_LIBCUDACXX_CONCEPT constructible_from = _LIBCUDACXX_FRAGMENT(__constructible_from_, _Tp, _Args...);
|
| 73 |
+
|
| 74 |
+
template<class _Tp>
|
| 75 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 76 |
+
__default_initializable_,
|
| 77 |
+
requires()(
|
| 78 |
+
(::new _Tp)
|
| 79 |
+
));
|
| 80 |
+
|
| 81 |
+
template<class _Tp>
|
| 82 |
+
_LIBCUDACXX_CONCEPT __default_initializable = _LIBCUDACXX_FRAGMENT(__default_initializable_, _Tp);
|
| 83 |
+
|
| 84 |
+
template<class _Tp>
|
| 85 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 86 |
+
_Default_initializable_,
|
| 87 |
+
requires(_Tp = _Tp{}) (
|
| 88 |
+
requires(constructible_from<_Tp>),
|
| 89 |
+
requires(__default_initializable<_Tp>)
|
| 90 |
+
));
|
| 91 |
+
|
| 92 |
+
template<class _Tp>
|
| 93 |
+
_LIBCUDACXX_CONCEPT default_initializable = _LIBCUDACXX_FRAGMENT(_Default_initializable_, _Tp);
|
| 94 |
+
|
| 95 |
+
// [concept.moveconstructible]
|
| 96 |
+
template<class _Tp>
|
| 97 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 98 |
+
__move_constructible_,
|
| 99 |
+
requires()(
|
| 100 |
+
requires(constructible_from<_Tp, _Tp>),
|
| 101 |
+
requires(convertible_to<_Tp, _Tp>)
|
| 102 |
+
));
|
| 103 |
+
|
| 104 |
+
template<class _Tp>
|
| 105 |
+
_LIBCUDACXX_CONCEPT move_constructible = _LIBCUDACXX_FRAGMENT(__move_constructible_, _Tp);
|
| 106 |
+
|
| 107 |
+
// [concept.copyconstructible]
|
| 108 |
+
template<class _Tp>
|
| 109 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 110 |
+
__copy_constructible_,
|
| 111 |
+
requires()(
|
| 112 |
+
requires(move_constructible<_Tp>),
|
| 113 |
+
requires(constructible_from<_Tp, add_lvalue_reference_t<_Tp>> && convertible_to<add_lvalue_reference_t<_Tp>, _Tp>),
|
| 114 |
+
requires(constructible_from<_Tp, const add_lvalue_reference_t<_Tp>> && convertible_to<const add_lvalue_reference_t<_Tp>, _Tp>),
|
| 115 |
+
requires(constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>)
|
| 116 |
+
));
|
| 117 |
+
|
| 118 |
+
template<class _Tp>
|
| 119 |
+
_LIBCUDACXX_CONCEPT copy_constructible = _LIBCUDACXX_FRAGMENT(__copy_constructible_, _Tp);
|
| 120 |
+
|
| 121 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 122 |
+
|
| 123 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 124 |
+
|
| 125 |
+
#endif // _LIBCUDACXX___CONCEPTS_CONSTRUCTIBLE_H
|
cuda_toolkit/include/__concepts/convertible_to.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_CONVERTIBLE_TO_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_CONVERTIBLE_TO_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/is_convertible.h"
|
| 19 |
+
#include "../__utility/declval.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 32 |
+
|
| 33 |
+
// [concept.convertible]
|
| 34 |
+
|
| 35 |
+
template<class _From, class _To>
|
| 36 |
+
concept convertible_to =
|
| 37 |
+
is_convertible_v<_From, _To> &&
|
| 38 |
+
requires {
|
| 39 |
+
static_cast<_To>(_CUDA_VSTD::declval<_From>());
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 43 |
+
|
| 44 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 45 |
+
_LIBCUDACXX_NV_DIAG_SUPPRESS(1211) // nonstandard cast to array type ignored
|
| 46 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 47 |
+
|
| 48 |
+
// We cannot put this conversion check with the other constraint, as types with deleted operator will break here
|
| 49 |
+
template<class _From, class _To>
|
| 50 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 51 |
+
__test_conversion_,
|
| 52 |
+
requires()(
|
| 53 |
+
static_cast<_To>(_CUDA_VSTD::declval<_From>())
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
template<class _From, class _To>
|
| 57 |
+
_LIBCUDACXX_CONCEPT __test_conversion = _LIBCUDACXX_FRAGMENT(__test_conversion_, _From, _To);
|
| 58 |
+
|
| 59 |
+
template<class _From, class _To>
|
| 60 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 61 |
+
__convertible_to_,
|
| 62 |
+
requires()(
|
| 63 |
+
requires(_LIBCUDACXX_TRAIT(is_convertible, _From, _To)),
|
| 64 |
+
requires(__test_conversion<_From, _To>)
|
| 65 |
+
));
|
| 66 |
+
|
| 67 |
+
template<class _From, class _To>
|
| 68 |
+
_LIBCUDACXX_CONCEPT convertible_to = _LIBCUDACXX_FRAGMENT(__convertible_to_, _From, _To);
|
| 69 |
+
|
| 70 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 71 |
+
_LIBCUDACXX_NV_DIAG_DEFAULT(1211) // nonstandard cast to array type ignored
|
| 72 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 73 |
+
|
| 74 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 75 |
+
|
| 76 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 77 |
+
|
| 78 |
+
#endif // _LIBCUDACXX___CONCEPTS_CONVERTIBLE_TO_H
|
cuda_toolkit/include/__concepts/copyable.h
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_COPYABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_COPYABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/assignable.h"
|
| 19 |
+
#include "../__concepts/constructible.h"
|
| 20 |
+
#include "../__concepts/movable.h"
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 31 |
+
|
| 32 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 33 |
+
|
| 34 |
+
// [concepts.object]
|
| 35 |
+
|
| 36 |
+
template<class _Tp>
|
| 37 |
+
concept copyable =
|
| 38 |
+
copy_constructible<_Tp> &&
|
| 39 |
+
movable<_Tp> &&
|
| 40 |
+
assignable_from<_Tp&, _Tp&> &&
|
| 41 |
+
assignable_from<_Tp&, const _Tp&> &&
|
| 42 |
+
assignable_from<_Tp&, const _Tp>;
|
| 43 |
+
|
| 44 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 45 |
+
|
| 46 |
+
template<class _Tp>
|
| 47 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 48 |
+
__copyable_,
|
| 49 |
+
requires()(
|
| 50 |
+
requires(copy_constructible<_Tp>),
|
| 51 |
+
requires(movable<_Tp>),
|
| 52 |
+
requires(assignable_from<_Tp&, _Tp&>),
|
| 53 |
+
requires(assignable_from<_Tp&, const _Tp&>),
|
| 54 |
+
requires(assignable_from<_Tp&, const _Tp>)
|
| 55 |
+
));
|
| 56 |
+
|
| 57 |
+
template<class _Tp>
|
| 58 |
+
_LIBCUDACXX_CONCEPT copyable = _LIBCUDACXX_FRAGMENT(__copyable_,_Tp);
|
| 59 |
+
|
| 60 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 61 |
+
|
| 62 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 63 |
+
|
| 64 |
+
#endif // _LIBCUDACXX___CONCEPTS_COPYABLE_H
|
cuda_toolkit/include/__concepts/derived_from.h
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_DERIVED_FROM_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_DERIVED_FROM_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/add_pointer.h"
|
| 19 |
+
#include "../__type_traits/is_base_of.h"
|
| 20 |
+
#include "../__type_traits/is_convertible.h"
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 31 |
+
|
| 32 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 33 |
+
|
| 34 |
+
// [concept.derived]
|
| 35 |
+
|
| 36 |
+
template<class _Dp, class _Bp>
|
| 37 |
+
concept derived_from =
|
| 38 |
+
is_base_of_v<_Bp, _Dp> &&
|
| 39 |
+
is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
|
| 40 |
+
|
| 41 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 42 |
+
|
| 43 |
+
template<class _Dp, class _Bp>
|
| 44 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 45 |
+
__derived_from_,
|
| 46 |
+
requires()(
|
| 47 |
+
requires(_LIBCUDACXX_TRAIT(is_base_of, _Bp, _Dp)),
|
| 48 |
+
requires(_LIBCUDACXX_TRAIT(is_convertible, add_pointer_t<const volatile _Dp>, add_pointer_t<const volatile _Bp>))
|
| 49 |
+
));
|
| 50 |
+
|
| 51 |
+
template<class _Dp, class _Bp>
|
| 52 |
+
_LIBCUDACXX_CONCEPT derived_from = _LIBCUDACXX_FRAGMENT(__derived_from_, _Dp, _Bp);
|
| 53 |
+
|
| 54 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 55 |
+
|
| 56 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 57 |
+
|
| 58 |
+
#endif // _LIBCUDACXX___CONCEPTS_DERIVED_FROM_H
|
cuda_toolkit/include/__concepts/destructible.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_DESTRUCTIBLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_DESTRUCTIBLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/enable_if.h"
|
| 19 |
+
#include "../__type_traits/is_destructible.h"
|
| 20 |
+
#include "../__type_traits/is_object.h"
|
| 21 |
+
#include "../__type_traits/is_nothrow_destructible.h"
|
| 22 |
+
#include "../__type_traits/void_t.h"
|
| 23 |
+
#include "../__utility/declval.h"
|
| 24 |
+
|
| 25 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 26 |
+
# pragma GCC system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 28 |
+
# pragma clang system_header
|
| 29 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 30 |
+
# pragma system_header
|
| 31 |
+
#endif // no system header
|
| 32 |
+
|
| 33 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 34 |
+
|
| 35 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 36 |
+
|
| 37 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 38 |
+
|
| 39 |
+
template<class _Tp>
|
| 40 |
+
_LIBCUDACXX_CONCEPT destructible = __is_nothrow_destructible(_Tp);
|
| 41 |
+
|
| 42 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_MSVC ^^^ / vvv !_LIBCUDACXX_COMPILER_MSVC vvv
|
| 43 |
+
|
| 44 |
+
template<class _Tp, class = void, class = void>
|
| 45 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible_impl = false;
|
| 46 |
+
|
| 47 |
+
template<class _Tp>
|
| 48 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible_impl<_Tp,
|
| 49 |
+
__enable_if_t<_LIBCUDACXX_TRAIT(is_object, _Tp)>,
|
| 50 |
+
#if defined(_LIBCUDACXX_COMPILER_GCC)
|
| 51 |
+
__enable_if_t<_LIBCUDACXX_TRAIT(is_destructible, _Tp)>>
|
| 52 |
+
#else // ^^^ defined(_LIBCUDACXX_COMPILER_GCC) ^^^ / vvv !_LIBCUDACXX_COMPILER_GCC vvv
|
| 53 |
+
__void_t<decltype(_CUDA_VSTD::declval<_Tp>().~_Tp())>>
|
| 54 |
+
#endif // !_LIBCUDACXX_COMPILER_GCC
|
| 55 |
+
= noexcept(_CUDA_VSTD::declval<_Tp>().~_Tp());
|
| 56 |
+
|
| 57 |
+
template<class _Tp>
|
| 58 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible = __destructible_impl<_Tp>;
|
| 59 |
+
|
| 60 |
+
template<class _Tp>
|
| 61 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible<_Tp&> = true;
|
| 62 |
+
|
| 63 |
+
template<class _Tp>
|
| 64 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible<_Tp&&> = true;
|
| 65 |
+
|
| 66 |
+
template<class _Tp, size_t _Nm>
|
| 67 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __destructible<_Tp[_Nm]> = __destructible<_Tp>;
|
| 68 |
+
|
| 69 |
+
template<class _Tp>
|
| 70 |
+
_LIBCUDACXX_CONCEPT destructible = __destructible<_Tp>;
|
| 71 |
+
|
| 72 |
+
#endif // !_LIBCUDACXX_COMPILER_MSVC
|
| 73 |
+
|
| 74 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 75 |
+
|
| 76 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 77 |
+
|
| 78 |
+
#endif // _LIBCUDACXX___CONCEPTS_DESTRUCTIBLE_H
|
cuda_toolkit/include/__concepts/different_from.h
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_DIFFERENT_FROM_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_DIFFERENT_FROM_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/same_as.h"
|
| 19 |
+
#include "../__type_traits/remove_cvref.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 32 |
+
|
| 33 |
+
template<class _Tp, class _Up>
|
| 34 |
+
_LIBCUDACXX_CONCEPT __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
|
| 35 |
+
|
| 36 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 37 |
+
|
| 38 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 39 |
+
|
| 40 |
+
#endif // _LIBCUDACXX___CONCEPTS_DIFFERENT_FROM_H
|
cuda_toolkit/include/__concepts/equality_comparable.h
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_EQUALITY_COMPARABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_EQUALITY_COMPARABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/boolean_testable.h"
|
| 19 |
+
#include "../__concepts/common_reference_with.h"
|
| 20 |
+
#include "../__type_traits/common_reference.h"
|
| 21 |
+
#include "../__type_traits/make_const_lvalue_ref.h"
|
| 22 |
+
|
| 23 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 24 |
+
# pragma GCC system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 26 |
+
# pragma clang system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 28 |
+
# pragma system_header
|
| 29 |
+
#endif // no system header
|
| 30 |
+
|
| 31 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 32 |
+
|
| 33 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 34 |
+
|
| 35 |
+
// [concept.equalitycomparable]
|
| 36 |
+
|
| 37 |
+
template<class _Tp, class _Up>
|
| 38 |
+
concept __weakly_equality_comparable_with =
|
| 39 |
+
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
|
| 40 |
+
{ __t == __u } -> __boolean_testable;
|
| 41 |
+
{ __t != __u } -> __boolean_testable;
|
| 42 |
+
{ __u == __t } -> __boolean_testable;
|
| 43 |
+
{ __u != __t } -> __boolean_testable;
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
template<class _Tp>
|
| 47 |
+
concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>;
|
| 48 |
+
|
| 49 |
+
template<class _Tp, class _Up>
|
| 50 |
+
concept equality_comparable_with =
|
| 51 |
+
equality_comparable<_Tp> && equality_comparable<_Up> &&
|
| 52 |
+
common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
|
| 53 |
+
equality_comparable<
|
| 54 |
+
common_reference_t<
|
| 55 |
+
__make_const_lvalue_ref<_Tp>,
|
| 56 |
+
__make_const_lvalue_ref<_Up>>> &&
|
| 57 |
+
__weakly_equality_comparable_with<_Tp, _Up>;
|
| 58 |
+
|
| 59 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 60 |
+
|
| 61 |
+
template<class _Tp>
|
| 62 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 63 |
+
__with_lvalue_reference_,
|
| 64 |
+
requires()(
|
| 65 |
+
typename(__make_const_lvalue_ref<_Tp>)
|
| 66 |
+
));
|
| 67 |
+
|
| 68 |
+
template<class _Tp>
|
| 69 |
+
_LIBCUDACXX_CONCEPT _With_lvalue_reference = _LIBCUDACXX_FRAGMENT(__with_lvalue_reference_, _Tp);
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
template<class _Tp, class _Up>
|
| 73 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 74 |
+
__weakly_equality_comparable_with_,
|
| 75 |
+
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u)(
|
| 76 |
+
requires(_With_lvalue_reference<_Tp>),
|
| 77 |
+
requires(_With_lvalue_reference<_Up>),
|
| 78 |
+
requires(__boolean_testable<decltype(__t == __u)>),
|
| 79 |
+
requires(__boolean_testable<decltype(__t != __u)>),
|
| 80 |
+
requires(__boolean_testable<decltype(__u == __t)>),
|
| 81 |
+
requires(__boolean_testable<decltype(__u != __t)>)
|
| 82 |
+
));
|
| 83 |
+
|
| 84 |
+
template<class _Tp, class _Up>
|
| 85 |
+
_LIBCUDACXX_CONCEPT __weakly_equality_comparable_with =
|
| 86 |
+
_LIBCUDACXX_FRAGMENT(__weakly_equality_comparable_with_, _Tp, _Up);
|
| 87 |
+
|
| 88 |
+
template<class _Tp>
|
| 89 |
+
_LIBCUDACXX_CONCEPT equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>;
|
| 90 |
+
|
| 91 |
+
template<class _Tp, class _Up>
|
| 92 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 93 |
+
__equality_comparable_with_,
|
| 94 |
+
requires()(
|
| 95 |
+
requires(equality_comparable<_Tp>),
|
| 96 |
+
requires(equality_comparable<_Up>),
|
| 97 |
+
requires(common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>),
|
| 98 |
+
requires(equality_comparable<
|
| 99 |
+
common_reference_t<
|
| 100 |
+
__make_const_lvalue_ref<_Tp>,
|
| 101 |
+
__make_const_lvalue_ref<_Up>>>),
|
| 102 |
+
requires(__weakly_equality_comparable_with<_Tp, _Up>)));
|
| 103 |
+
|
| 104 |
+
template<class _Tp, class _Up>
|
| 105 |
+
_LIBCUDACXX_CONCEPT equality_comparable_with = _LIBCUDACXX_FRAGMENT(__equality_comparable_with_, _Tp, _Up);
|
| 106 |
+
|
| 107 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 108 |
+
|
| 109 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 110 |
+
|
| 111 |
+
#endif // _LIBCUDACXX___CONCEPTS_EQUALITY_COMPARABLE_H
|
cuda_toolkit/include/__concepts/invocable.h
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_INVOCABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_INVOCABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__functional/invoke.h"
|
| 19 |
+
#include "../__utility/forward.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 32 |
+
|
| 33 |
+
// [concept.invocable]
|
| 34 |
+
|
| 35 |
+
template<class _Fn, class... _Args>
|
| 36 |
+
concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
|
| 37 |
+
_CUDA_VSTD::__invoke(_CUDA_VSTD::forward<_Fn>(__fn), _CUDA_VSTD::forward<_Args>(__args)...); // not required to be equality preserving
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
// [concept.regular.invocable]
|
| 41 |
+
|
| 42 |
+
template<class _Fn, class... _Args>
|
| 43 |
+
concept regular_invocable = invocable<_Fn, _Args...>;
|
| 44 |
+
|
| 45 |
+
template <class _Fun, class... _Args>
|
| 46 |
+
concept __invoke_constructible = requires(_Fun&& __fun, _Args&&... __args) {
|
| 47 |
+
static_cast<remove_cvref_t<invoke_result_t<_Fun, _Args...>>>(
|
| 48 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...));
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 52 |
+
|
| 53 |
+
template<class _Fn, class... _Args>
|
| 54 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 55 |
+
_Invocable_,
|
| 56 |
+
requires(_Fn&& __fn, _Args&&... __args)(
|
| 57 |
+
(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fn>(__fn), _CUDA_VSTD::forward<_Args>(__args)...))
|
| 58 |
+
));
|
| 59 |
+
|
| 60 |
+
template<class _Fn, class... _Args>
|
| 61 |
+
_LIBCUDACXX_CONCEPT invocable = _LIBCUDACXX_FRAGMENT(_Invocable_, _Fn, _Args...);
|
| 62 |
+
|
| 63 |
+
template<class _Fn, class... _Args>
|
| 64 |
+
_LIBCUDACXX_CONCEPT regular_invocable = invocable<_Fn, _Args...>;
|
| 65 |
+
|
| 66 |
+
template <class _Fun, class... _Args>
|
| 67 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 68 |
+
__invoke_constructible_,
|
| 69 |
+
requires(_Fun&& __fun, _Args&&... __args)(
|
| 70 |
+
(static_cast<__remove_cvref_t<invoke_result_t<_Fun, _Args...>>>(
|
| 71 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)))
|
| 72 |
+
));
|
| 73 |
+
template <class _Fun, class... _Args>
|
| 74 |
+
_LIBCUDACXX_CONCEPT __invoke_constructible = _LIBCUDACXX_FRAGMENT(__invoke_constructible_, _Fun, _Args...);
|
| 75 |
+
|
| 76 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 77 |
+
|
| 78 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 79 |
+
|
| 80 |
+
#endif // _LIBCUDACXX___CONCEPTS_INVOCABLE_H
|
cuda_toolkit/include/__concepts/movable.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_MOVABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_MOVABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/assignable.h"
|
| 19 |
+
#include "../__concepts/constructible.h"
|
| 20 |
+
#include "../__concepts/swappable.h"
|
| 21 |
+
#include "../__type_traits/is_object.h"
|
| 22 |
+
|
| 23 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 24 |
+
# pragma GCC system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 26 |
+
# pragma clang system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 28 |
+
# pragma system_header
|
| 29 |
+
#endif // no system header
|
| 30 |
+
|
| 31 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 32 |
+
|
| 33 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 34 |
+
|
| 35 |
+
template<class _Tp>
|
| 36 |
+
concept movable =
|
| 37 |
+
is_object_v<_Tp> &&
|
| 38 |
+
move_constructible<_Tp>&&
|
| 39 |
+
assignable_from<_Tp&, _Tp> &&
|
| 40 |
+
swappable<_Tp>;
|
| 41 |
+
|
| 42 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 43 |
+
|
| 44 |
+
// [concepts.object]
|
| 45 |
+
template<class _Tp>
|
| 46 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 47 |
+
_Movable_,
|
| 48 |
+
requires()(//
|
| 49 |
+
requires(is_object_v<_Tp>),
|
| 50 |
+
requires(move_constructible<_Tp>),
|
| 51 |
+
requires(assignable_from<_Tp&, _Tp>),
|
| 52 |
+
requires(swappable<_Tp>)
|
| 53 |
+
));
|
| 54 |
+
|
| 55 |
+
template<class _Tp>
|
| 56 |
+
_LIBCUDACXX_CONCEPT movable = _LIBCUDACXX_FRAGMENT(_Movable_, _Tp);
|
| 57 |
+
|
| 58 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 59 |
+
|
| 60 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 61 |
+
|
| 62 |
+
#endif // _LIBCUDACXX___CONCEPTS_MOVABLE_H
|
cuda_toolkit/include/__concepts/predicate.h
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_PREDICATE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_PREDICATE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/boolean_testable.h"
|
| 19 |
+
#include "../__concepts/invocable.h"
|
| 20 |
+
#include "../__functional/invoke.h"
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 31 |
+
|
| 32 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 33 |
+
|
| 34 |
+
template<class _Fn, class... _Args>
|
| 35 |
+
concept predicate =
|
| 36 |
+
regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
|
| 37 |
+
|
| 38 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 39 |
+
|
| 40 |
+
// [concept.predicate]
|
| 41 |
+
template<class _Fn, class... _Args>
|
| 42 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 43 |
+
_Predicate_,
|
| 44 |
+
requires()(//
|
| 45 |
+
requires(regular_invocable<_Fn, _Args...>),
|
| 46 |
+
requires(__boolean_testable<invoke_result_t<_Fn, _Args...>>)
|
| 47 |
+
));
|
| 48 |
+
|
| 49 |
+
template<class _Fn, class... _Args>
|
| 50 |
+
_LIBCUDACXX_CONCEPT predicate = _LIBCUDACXX_FRAGMENT(_Predicate_, _Fn, _Args...);
|
| 51 |
+
|
| 52 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 53 |
+
|
| 54 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 55 |
+
|
| 56 |
+
#endif // _LIBCUDACXX___CONCEPTS_PREDICATE_H
|
cuda_toolkit/include/__concepts/regular.h
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_REGULAR_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_REGULAR_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/equality_comparable.h"
|
| 19 |
+
#include "../__concepts/semiregular.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 32 |
+
|
| 33 |
+
// [concept.object]
|
| 34 |
+
|
| 35 |
+
template<class _Tp>
|
| 36 |
+
concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
|
| 37 |
+
|
| 38 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 39 |
+
|
| 40 |
+
// [concept.object]
|
| 41 |
+
|
| 42 |
+
template<class _Tp>
|
| 43 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 44 |
+
__regular_,
|
| 45 |
+
requires()(
|
| 46 |
+
requires(semiregular<_Tp>),
|
| 47 |
+
requires(equality_comparable<_Tp>)
|
| 48 |
+
));
|
| 49 |
+
|
| 50 |
+
template<class _Tp>
|
| 51 |
+
_LIBCUDACXX_CONCEPT regular = _LIBCUDACXX_FRAGMENT(__regular_, _Tp);
|
| 52 |
+
|
| 53 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 54 |
+
|
| 55 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 56 |
+
|
| 57 |
+
#endif // _LIBCUDACXX___CONCEPTS_REGULAR_H
|
cuda_toolkit/include/__concepts/relation.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_RELATION_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_RELATION_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/predicate.h"
|
| 19 |
+
|
| 20 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 21 |
+
# pragma GCC system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 23 |
+
# pragma clang system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 25 |
+
# pragma system_header
|
| 26 |
+
#endif // no system header
|
| 27 |
+
|
| 28 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 29 |
+
|
| 30 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 31 |
+
|
| 32 |
+
// [concept.relation]
|
| 33 |
+
|
| 34 |
+
template<class _Rp, class _Tp, class _Up>
|
| 35 |
+
concept relation =
|
| 36 |
+
predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> &&
|
| 37 |
+
predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>;
|
| 38 |
+
|
| 39 |
+
// [concept.equiv]
|
| 40 |
+
|
| 41 |
+
template<class _Rp, class _Tp, class _Up>
|
| 42 |
+
concept equivalence_relation = relation<_Rp, _Tp, _Up>;
|
| 43 |
+
|
| 44 |
+
// [concept.strictweakorder]
|
| 45 |
+
|
| 46 |
+
template<class _Rp, class _Tp, class _Up>
|
| 47 |
+
concept strict_weak_order = relation<_Rp, _Tp, _Up>;
|
| 48 |
+
|
| 49 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 50 |
+
|
| 51 |
+
template<class _Rp, class _Tp, class _Up>
|
| 52 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 53 |
+
__relation_,
|
| 54 |
+
requires()(
|
| 55 |
+
requires(predicate<_Rp, _Tp, _Tp>),
|
| 56 |
+
requires(predicate<_Rp, _Up, _Up>),
|
| 57 |
+
requires(predicate<_Rp, _Tp, _Up>),
|
| 58 |
+
requires(predicate<_Rp, _Up, _Tp>)
|
| 59 |
+
));
|
| 60 |
+
|
| 61 |
+
template<class _Rp, class _Tp, class _Up>
|
| 62 |
+
_LIBCUDACXX_CONCEPT relation = _LIBCUDACXX_FRAGMENT(__relation_, _Rp, _Tp, _Up);
|
| 63 |
+
|
| 64 |
+
// [concept.equiv]
|
| 65 |
+
|
| 66 |
+
template<class _Rp, class _Tp, class _Up>
|
| 67 |
+
_LIBCUDACXX_CONCEPT equivalence_relation = relation<_Rp, _Tp, _Up>;
|
| 68 |
+
|
| 69 |
+
// [concept.strictweakorder]
|
| 70 |
+
|
| 71 |
+
template<class _Rp, class _Tp, class _Up>
|
| 72 |
+
_LIBCUDACXX_CONCEPT strict_weak_order = relation<_Rp, _Tp, _Up>;
|
| 73 |
+
|
| 74 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 75 |
+
|
| 76 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 77 |
+
|
| 78 |
+
#endif // _LIBCUDACXX___CONCEPTS_RELATION_H
|
cuda_toolkit/include/__concepts/same_as.h
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_SAME_AS_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_SAME_AS_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/is_same.h"
|
| 19 |
+
|
| 20 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 21 |
+
# pragma GCC system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 23 |
+
# pragma clang system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 25 |
+
# pragma system_header
|
| 26 |
+
#endif // no system header
|
| 27 |
+
|
| 28 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 29 |
+
|
| 30 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 31 |
+
|
| 32 |
+
// [concept.same]
|
| 33 |
+
|
| 34 |
+
template<class _Tp, class _Up>
|
| 35 |
+
_LIBCUDACXX_CONCEPT __same_as_impl = _IsSame<_Tp, _Up>::value;
|
| 36 |
+
|
| 37 |
+
template<class _Tp, class _Up>
|
| 38 |
+
_LIBCUDACXX_CONCEPT same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
|
| 39 |
+
|
| 40 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 41 |
+
|
| 42 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 43 |
+
|
| 44 |
+
#endif // _LIBCUDACXX___CONCEPTS_SAME_AS_H
|
cuda_toolkit/include/__concepts/semiregular.h
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_SEMIREGULAR_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_SEMIREGULAR_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/constructible.h"
|
| 19 |
+
#include "../__concepts/copyable.h"
|
| 20 |
+
|
| 21 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 22 |
+
# pragma GCC system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 24 |
+
# pragma clang system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 26 |
+
# pragma system_header
|
| 27 |
+
#endif // no system header
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 32 |
+
|
| 33 |
+
// [concept.object]
|
| 34 |
+
|
| 35 |
+
template<class _Tp>
|
| 36 |
+
concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
|
| 37 |
+
|
| 38 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 39 |
+
|
| 40 |
+
// [concept.object]
|
| 41 |
+
|
| 42 |
+
template<class _Tp>
|
| 43 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 44 |
+
__semiregular_,
|
| 45 |
+
requires()(
|
| 46 |
+
requires(copyable<_Tp>),
|
| 47 |
+
requires(default_initializable<_Tp>)
|
| 48 |
+
));
|
| 49 |
+
|
| 50 |
+
template<class _Tp>
|
| 51 |
+
_LIBCUDACXX_CONCEPT semiregular = _LIBCUDACXX_FRAGMENT(__semiregular_, _Tp);
|
| 52 |
+
|
| 53 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 54 |
+
|
| 55 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 56 |
+
|
| 57 |
+
#endif // _LIBCUDACXX___CONCEPTS_SEMIREGULAR_H
|
cuda_toolkit/include/__concepts/swappable.h
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_SWAPPABLE_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_SWAPPABLE_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/assignable.h"
|
| 19 |
+
#include "../__concepts/class_or_enum.h"
|
| 20 |
+
#include "../__concepts/common_reference_with.h"
|
| 21 |
+
#include "../__concepts/constructible.h"
|
| 22 |
+
#include "../__type_traits/extent.h"
|
| 23 |
+
#include "../__type_traits/integral_constant.h"
|
| 24 |
+
#include "../__type_traits/is_nothrow_move_assignable.h"
|
| 25 |
+
#include "../__type_traits/is_nothrow_move_constructible.h"
|
| 26 |
+
#include "../__type_traits/remove_cvref.h"
|
| 27 |
+
#include "../__type_traits/type_identity.h"
|
| 28 |
+
#include "../__type_traits/void_t.h"
|
| 29 |
+
#include "../__utility/declval.h"
|
| 30 |
+
#include "../__utility/exchange.h"
|
| 31 |
+
#include "../__utility/forward.h"
|
| 32 |
+
#include "../__utility/move.h"
|
| 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 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 43 |
+
_LIBCUDACXX_NV_DIAG_SUPPRESS(461) // nonstandard cast to array type ignored
|
| 44 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 45 |
+
|
| 46 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 47 |
+
|
| 48 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_RANGES
|
| 49 |
+
|
| 50 |
+
// [concept.swappable]
|
| 51 |
+
|
| 52 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CPO(__swap)
|
| 53 |
+
|
| 54 |
+
template<class _Tp>
|
| 55 |
+
void swap(_Tp&, _Tp&) = delete;
|
| 56 |
+
|
| 57 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 58 |
+
template<class _Tp, class _Up>
|
| 59 |
+
concept __unqualified_swappable_with =
|
| 60 |
+
(__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) &&
|
| 61 |
+
requires(_Tp&& __t, _Up&& __u) {
|
| 62 |
+
swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u));
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
template<class _Tp>
|
| 66 |
+
concept __exchangeable =
|
| 67 |
+
!__unqualified_swappable_with<_Tp&, _Tp&> &&
|
| 68 |
+
move_constructible<_Tp> &&
|
| 69 |
+
assignable_from<_Tp&, _Tp>;
|
| 70 |
+
|
| 71 |
+
#else // ^^^ CXX20 ^^^ / vvv CXX17 vvv
|
| 72 |
+
|
| 73 |
+
template<class _Tp, class _Up>
|
| 74 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 75 |
+
__unqualified_swappable_with_,
|
| 76 |
+
requires(_Tp&& __t, _Up&& __u)(
|
| 77 |
+
(swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u)))
|
| 78 |
+
));
|
| 79 |
+
|
| 80 |
+
template<class _Tp, class _Up>
|
| 81 |
+
_LIBCUDACXX_CONCEPT __unqualified_swappable_with = _LIBCUDACXX_FRAGMENT(__unqualified_swappable_with_, _Tp, _Up);
|
| 82 |
+
|
| 83 |
+
template<class _Tp>
|
| 84 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 85 |
+
__exchangeable_,
|
| 86 |
+
requires()(
|
| 87 |
+
requires(!__unqualified_swappable_with<_Tp&, _Tp&>),
|
| 88 |
+
requires(move_constructible<_Tp>),
|
| 89 |
+
requires(assignable_from<_Tp&, _Tp>)
|
| 90 |
+
));
|
| 91 |
+
|
| 92 |
+
template<class _Tp>
|
| 93 |
+
_LIBCUDACXX_CONCEPT __exchangeable = _LIBCUDACXX_FRAGMENT(__exchangeable_, _Tp);
|
| 94 |
+
#endif // _LIBCUDACXX_STD_VER < 20
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
#if _LIBCUDACXX_STD_VER > 17 && !defined(_LIBCUDACXX_COMPILER_NVHPC) // nvbug4051640
|
| 98 |
+
struct __fn;
|
| 99 |
+
|
| 100 |
+
_LIBCUDACXX_NV_DIAG_SUPPRESS(2642)
|
| 101 |
+
template<class _Tp, class _Up, size_t _Size>
|
| 102 |
+
concept __swappable_arrays =
|
| 103 |
+
!__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> &&
|
| 104 |
+
extent_v<_Tp> == extent_v<_Up> &&
|
| 105 |
+
requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) {
|
| 106 |
+
__swap(__t[0], __u[0]);
|
| 107 |
+
};
|
| 108 |
+
_LIBCUDACXX_NV_DIAG_DEFAULT(2642)
|
| 109 |
+
|
| 110 |
+
#else
|
| 111 |
+
template<class _Tp, class _Up, size_t _Size, class = void>
|
| 112 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __swappable_arrays = false;
|
| 113 |
+
#endif // _LIBCUDACXX_STD_VER < 20 || defined(_LIBCUDACXX_COMPILER_NVHPC)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
template<class _Tp, class _Up, class = void>
|
| 117 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __noexcept_swappable_arrays = false;
|
| 118 |
+
|
| 119 |
+
struct __fn {
|
| 120 |
+
// 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and...
|
| 121 |
+
// *The name `swap` is used here unqualified.
|
| 122 |
+
_LIBCUDACXX_TEMPLATE(class _Tp, class _Up)
|
| 123 |
+
_LIBCUDACXX_REQUIRES( __unqualified_swappable_with<_Tp, _Up>)
|
| 124 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr void operator()(_Tp&& __t, _Up&& __u) const
|
| 125 |
+
noexcept(noexcept(swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u))))
|
| 126 |
+
{
|
| 127 |
+
swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u));
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and...
|
| 131 |
+
_LIBCUDACXX_TEMPLATE(class _Tp, class _Up, size_t _Size)
|
| 132 |
+
_LIBCUDACXX_REQUIRES( __swappable_arrays<_Tp, _Up, _Size>)
|
| 133 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const
|
| 134 |
+
noexcept(__noexcept_swappable_arrays<_Tp, _Up>)
|
| 135 |
+
{
|
| 136 |
+
// TODO(cjdb): replace with `_CUDA_VRANGES::swap_ranges`.
|
| 137 |
+
for (size_t __i = 0; __i < _Size; ++__i) {
|
| 138 |
+
(*this)(__t[__i], __u[__i]);
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models...
|
| 143 |
+
_LIBCUDACXX_TEMPLATE(class _Tp)
|
| 144 |
+
_LIBCUDACXX_REQUIRES( __exchangeable<_Tp>)
|
| 145 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr void operator()(_Tp& __x, _Tp& __y) const
|
| 146 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) && _LIBCUDACXX_TRAIT(is_nothrow_move_assignable, _Tp))
|
| 147 |
+
{
|
| 148 |
+
__y = _CUDA_VSTD::exchange(__x, _CUDA_VSTD::move(__y));
|
| 149 |
+
}
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
#if _LIBCUDACXX_STD_VER < 20 || defined(_LIBCUDACXX_COMPILER_NVHPC)
|
| 153 |
+
template<class _Tp, class _Up, class _Size>
|
| 154 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 155 |
+
__swappable_arrays_,
|
| 156 |
+
requires(_Tp(& __t)[_Size::value], _Up(& __u)[_Size::value], const __fn& __swap)(
|
| 157 |
+
requires(!__unqualified_swappable_with<_Tp(&)[_Size::value], _Up(&)[_Size::value]>),
|
| 158 |
+
requires(_LIBCUDACXX_TRAIT(extent, _Tp) == _LIBCUDACXX_TRAIT(extent, _Up)),
|
| 159 |
+
(__swap(__t[0], __u[0]))
|
| 160 |
+
));
|
| 161 |
+
|
| 162 |
+
template<class _Tp, class _Up, size_t _Size>
|
| 163 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __swappable_arrays<_Tp, _Up, _Size, void_t<type_identity_t<_Tp>>> =
|
| 164 |
+
_LIBCUDACXX_FRAGMENT(__swappable_arrays_, _Tp, _Up, _CUDA_VSTD::integral_constant<size_t, _Size>);
|
| 165 |
+
#endif // _LIBCUDACXX_STD_VER < 20 || defined(_LIBCUDACXX_COMPILER_NVHPC)
|
| 166 |
+
|
| 167 |
+
template<class _Tp, class _Up>
|
| 168 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __noexcept_swappable_arrays<_Tp, _Up, void_t<type_identity_t<_Tp>>> =
|
| 169 |
+
noexcept(__swap::__fn{}(_CUDA_VSTD::declval<_Tp&>(), _CUDA_VSTD::declval<_Up&>()));
|
| 170 |
+
|
| 171 |
+
_LIBCUDACXX_END_NAMESPACE_CPO
|
| 172 |
+
|
| 173 |
+
inline namespace __cpo {
|
| 174 |
+
_LIBCUDACXX_CPO_ACCESSIBILITY auto swap = __swap::__fn{};
|
| 175 |
+
} // namespace __cpo
|
| 176 |
+
_LIBCUDACXX_END_NAMESPACE_RANGES
|
| 177 |
+
|
| 178 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 179 |
+
|
| 180 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 181 |
+
template<class _Tp>
|
| 182 |
+
concept swappable = requires(_Tp& __a, _Tp& __b) { _CUDA_VRANGES::swap(__a, __b); };
|
| 183 |
+
|
| 184 |
+
template<class _Tp, class _Up>
|
| 185 |
+
concept swappable_with =
|
| 186 |
+
common_reference_with<_Tp, _Up> &&
|
| 187 |
+
requires(_Tp&& __t, _Up&& __u) {
|
| 188 |
+
_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Tp>(__t));
|
| 189 |
+
_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Up>(__u), _CUDA_VSTD::forward<_Up>(__u));
|
| 190 |
+
_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u));
|
| 191 |
+
_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Up>(__u), _CUDA_VSTD::forward<_Tp>(__t));
|
| 192 |
+
};
|
| 193 |
+
#else
|
| 194 |
+
template<class _Tp>
|
| 195 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 196 |
+
__swappable_,
|
| 197 |
+
requires(_Tp& __a, _Tp& __b)(
|
| 198 |
+
(_CUDA_VRANGES::swap(__a, __b))
|
| 199 |
+
));
|
| 200 |
+
|
| 201 |
+
template<class _Tp>
|
| 202 |
+
_LIBCUDACXX_CONCEPT swappable = _LIBCUDACXX_FRAGMENT(__swappable_, _Tp);
|
| 203 |
+
|
| 204 |
+
template<class _Tp, class _Up>
|
| 205 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 206 |
+
__swappable_with_,
|
| 207 |
+
requires(_Tp&& __t, _Up&& __u)(
|
| 208 |
+
requires(common_reference_with<_Tp, _Up>),
|
| 209 |
+
(_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Tp>(__t))),
|
| 210 |
+
(_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Up>(__u), _CUDA_VSTD::forward<_Up>(__u))),
|
| 211 |
+
(_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Tp>(__t), _CUDA_VSTD::forward<_Up>(__u))),
|
| 212 |
+
(_CUDA_VRANGES::swap(_CUDA_VSTD::forward<_Up>(__u), _CUDA_VSTD::forward<_Tp>(__t)))
|
| 213 |
+
));
|
| 214 |
+
|
| 215 |
+
template<class _Tp, class _Up>
|
| 216 |
+
_LIBCUDACXX_CONCEPT swappable_with = _LIBCUDACXX_FRAGMENT(__swappable_with_, _Tp, _Up);
|
| 217 |
+
#endif
|
| 218 |
+
|
| 219 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 220 |
+
|
| 221 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 222 |
+
|
| 223 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 224 |
+
_LIBCUDACXX_NV_DIAG_DEFAULT(461) // nonstandard cast to array type ignored
|
| 225 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
#endif // _LIBCUDACXX___CONCEPTS_SWAPPABLE_H
|
cuda_toolkit/include/__concepts/totally_ordered.h
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___CONCEPTS_TOTALLY_ORDERED_H
|
| 11 |
+
#define _LIBCUDACXX___CONCEPTS_TOTALLY_ORDERED_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif //__cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/boolean_testable.h"
|
| 19 |
+
#include "../__concepts/equality_comparable.h"
|
| 20 |
+
#include "../__type_traits/common_reference.h"
|
| 21 |
+
#include "../__type_traits/make_const_lvalue_ref.h"
|
| 22 |
+
|
| 23 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 24 |
+
# pragma GCC system_header
|
| 25 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 26 |
+
# pragma clang system_header
|
| 27 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 28 |
+
# pragma system_header
|
| 29 |
+
#endif // no system header
|
| 30 |
+
|
| 31 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 32 |
+
|
| 33 |
+
#if _LIBCUDACXX_STD_VER > 17
|
| 34 |
+
|
| 35 |
+
// [concept.totallyordered]
|
| 36 |
+
|
| 37 |
+
template<class _Tp, class _Up>
|
| 38 |
+
concept __partially_ordered_with =
|
| 39 |
+
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
|
| 40 |
+
{ __t < __u } -> __boolean_testable;
|
| 41 |
+
{ __t > __u } -> __boolean_testable;
|
| 42 |
+
{ __t <= __u } -> __boolean_testable;
|
| 43 |
+
{ __t >= __u } -> __boolean_testable;
|
| 44 |
+
{ __u < __t } -> __boolean_testable;
|
| 45 |
+
{ __u > __t } -> __boolean_testable;
|
| 46 |
+
{ __u <= __t } -> __boolean_testable;
|
| 47 |
+
{ __u >= __t } -> __boolean_testable;
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
template<class _Tp>
|
| 51 |
+
concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>;
|
| 52 |
+
|
| 53 |
+
template<class _Tp, class _Up>
|
| 54 |
+
concept totally_ordered_with =
|
| 55 |
+
totally_ordered<_Tp> && totally_ordered<_Up> &&
|
| 56 |
+
equality_comparable_with<_Tp, _Up> &&
|
| 57 |
+
totally_ordered<
|
| 58 |
+
common_reference_t<
|
| 59 |
+
__make_const_lvalue_ref<_Tp>,
|
| 60 |
+
__make_const_lvalue_ref<_Up>>> &&
|
| 61 |
+
__partially_ordered_with<_Tp, _Up>;
|
| 62 |
+
|
| 63 |
+
#elif _LIBCUDACXX_STD_VER > 11
|
| 64 |
+
|
| 65 |
+
template<class _Tp, class _Up>
|
| 66 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 67 |
+
__partially_ordered_with_,
|
| 68 |
+
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u)(
|
| 69 |
+
requires(__boolean_testable<decltype(__t < __u)>),
|
| 70 |
+
requires(__boolean_testable<decltype(__t > __u)>),
|
| 71 |
+
requires(__boolean_testable<decltype(__t <= __u)>),
|
| 72 |
+
requires(__boolean_testable<decltype(__t >= __u)>),
|
| 73 |
+
requires(__boolean_testable<decltype(__u < __t)>),
|
| 74 |
+
requires(__boolean_testable<decltype(__u > __t)>),
|
| 75 |
+
requires(__boolean_testable<decltype(__u <= __t)>),
|
| 76 |
+
requires(__boolean_testable<decltype(__u >= __t)>)
|
| 77 |
+
));
|
| 78 |
+
|
| 79 |
+
template<class _Tp, class _Up>
|
| 80 |
+
_LIBCUDACXX_CONCEPT __partially_ordered_with = _LIBCUDACXX_FRAGMENT(__partially_ordered_with_, _Tp, _Up);
|
| 81 |
+
|
| 82 |
+
template<class _Tp>
|
| 83 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 84 |
+
__totally_ordered_,
|
| 85 |
+
requires()(
|
| 86 |
+
requires(equality_comparable<_Tp>),
|
| 87 |
+
requires(__partially_ordered_with<_Tp, _Tp>)
|
| 88 |
+
));
|
| 89 |
+
|
| 90 |
+
template<class _Tp>
|
| 91 |
+
_LIBCUDACXX_CONCEPT totally_ordered = _LIBCUDACXX_FRAGMENT(__totally_ordered_, _Tp);
|
| 92 |
+
|
| 93 |
+
template<class _Tp, class _Up>
|
| 94 |
+
_LIBCUDACXX_CONCEPT_FRAGMENT(
|
| 95 |
+
__totally_ordered_with_,
|
| 96 |
+
requires()(
|
| 97 |
+
requires(totally_ordered<_Tp>),
|
| 98 |
+
requires(totally_ordered<_Up>),
|
| 99 |
+
requires(equality_comparable_with<_Tp, _Up>),
|
| 100 |
+
requires(totally_ordered<
|
| 101 |
+
common_reference_t<
|
| 102 |
+
__make_const_lvalue_ref<_Tp>,
|
| 103 |
+
__make_const_lvalue_ref<_Up>>>),
|
| 104 |
+
requires(__partially_ordered_with<_Tp, _Up>)));
|
| 105 |
+
|
| 106 |
+
template<class _Tp, class _Up>
|
| 107 |
+
_LIBCUDACXX_CONCEPT totally_ordered_with = _LIBCUDACXX_FRAGMENT(__totally_ordered_with_, _Tp, _Up);;
|
| 108 |
+
|
| 109 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 110 |
+
|
| 111 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 112 |
+
|
| 113 |
+
#endif // _LIBCUDACXX___CONCEPTS_TOTALLY_ORDERED_H
|
cuda_toolkit/include/__cuda/atomic.h
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_ATOMIC_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_ATOMIC_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/atomic> should only be included in from <cuda/std/atomic>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 19 |
+
# pragma GCC system_header
|
| 20 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 21 |
+
# pragma clang system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 23 |
+
# pragma system_header
|
| 24 |
+
#endif // no system header
|
| 25 |
+
|
| 26 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 27 |
+
|
| 28 |
+
using std::__detail::thread_scope;
|
| 29 |
+
using std::__detail::thread_scope_system;
|
| 30 |
+
using std::__detail::thread_scope_device;
|
| 31 |
+
using std::__detail::thread_scope_block;
|
| 32 |
+
using std::__detail::thread_scope_thread;
|
| 33 |
+
|
| 34 |
+
namespace __detail {
|
| 35 |
+
using std::__detail::__thread_scope_block_tag;
|
| 36 |
+
using std::__detail::__thread_scope_device_tag;
|
| 37 |
+
using std::__detail::__thread_scope_system_tag;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
using memory_order = std::memory_order;
|
| 41 |
+
|
| 42 |
+
constexpr memory_order memory_order_relaxed = std::memory_order_relaxed;
|
| 43 |
+
constexpr memory_order memory_order_consume = std::memory_order_consume;
|
| 44 |
+
constexpr memory_order memory_order_acquire = std::memory_order_acquire;
|
| 45 |
+
constexpr memory_order memory_order_release = std::memory_order_release;
|
| 46 |
+
constexpr memory_order memory_order_acq_rel = std::memory_order_acq_rel;
|
| 47 |
+
constexpr memory_order memory_order_seq_cst = std::memory_order_seq_cst;
|
| 48 |
+
|
| 49 |
+
// atomic<T>
|
| 50 |
+
|
| 51 |
+
template <class _Tp, thread_scope _Sco = thread_scope::thread_scope_system>
|
| 52 |
+
struct atomic
|
| 53 |
+
: public std::__atomic_base<_Tp, _Sco>
|
| 54 |
+
{
|
| 55 |
+
typedef std::__atomic_base<_Tp, _Sco> __base;
|
| 56 |
+
|
| 57 |
+
constexpr atomic() noexcept = default;
|
| 58 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 59 |
+
constexpr atomic(_Tp __d) noexcept : __base(__d) {}
|
| 60 |
+
|
| 61 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 62 |
+
_Tp operator=(_Tp __d) volatile noexcept
|
| 63 |
+
{__base::store(__d); return __d;}
|
| 64 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 65 |
+
_Tp operator=(_Tp __d) noexcept
|
| 66 |
+
{__base::store(__d); return __d;}
|
| 67 |
+
|
| 68 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 69 |
+
_Tp fetch_max(const _Tp & __op, memory_order __m = memory_order_seq_cst) volatile noexcept
|
| 70 |
+
{
|
| 71 |
+
return std::__detail::__cxx_atomic_fetch_max(&this->__a_, __op, __m);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 75 |
+
_Tp fetch_min(const _Tp & __op, memory_order __m = memory_order_seq_cst) volatile noexcept
|
| 76 |
+
{
|
| 77 |
+
return std::__detail::__cxx_atomic_fetch_min(&this->__a_, __op, __m);
|
| 78 |
+
}
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
// atomic<T*>
|
| 82 |
+
|
| 83 |
+
template <class _Tp, thread_scope _Sco>
|
| 84 |
+
struct atomic<_Tp*, _Sco>
|
| 85 |
+
: public std::__atomic_base<_Tp*, _Sco>
|
| 86 |
+
{
|
| 87 |
+
typedef std::__atomic_base<_Tp*, _Sco> __base;
|
| 88 |
+
|
| 89 |
+
constexpr atomic() noexcept = default;
|
| 90 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 91 |
+
constexpr atomic(_Tp* __d) noexcept : __base(__d) {}
|
| 92 |
+
|
| 93 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 94 |
+
_Tp* operator=(_Tp* __d) volatile noexcept
|
| 95 |
+
{__base::store(__d); return __d;}
|
| 96 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 97 |
+
_Tp* operator=(_Tp* __d) noexcept
|
| 98 |
+
{__base::store(__d); return __d;}
|
| 99 |
+
|
| 100 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 101 |
+
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
|
| 102 |
+
volatile noexcept
|
| 103 |
+
{return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
|
| 104 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 105 |
+
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) noexcept
|
| 106 |
+
{return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
|
| 107 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 108 |
+
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
|
| 109 |
+
volatile noexcept
|
| 110 |
+
{return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
|
| 111 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 112 |
+
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) noexcept
|
| 113 |
+
{return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
|
| 114 |
+
|
| 115 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 116 |
+
_Tp* operator++(int) volatile noexcept {return fetch_add(1);}
|
| 117 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 118 |
+
_Tp* operator++(int) noexcept {return fetch_add(1);}
|
| 119 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 120 |
+
_Tp* operator--(int) volatile noexcept {return fetch_sub(1);}
|
| 121 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 122 |
+
_Tp* operator--(int) noexcept {return fetch_sub(1);}
|
| 123 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 124 |
+
_Tp* operator++() volatile noexcept {return fetch_add(1) + 1;}
|
| 125 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 126 |
+
_Tp* operator++() noexcept {return fetch_add(1) + 1;}
|
| 127 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 128 |
+
_Tp* operator--() volatile noexcept {return fetch_sub(1) - 1;}
|
| 129 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 130 |
+
_Tp* operator--() noexcept {return fetch_sub(1) - 1;}
|
| 131 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 132 |
+
_Tp* operator+=(ptrdiff_t __op) volatile noexcept {return fetch_add(__op) + __op;}
|
| 133 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 134 |
+
_Tp* operator+=(ptrdiff_t __op) noexcept {return fetch_add(__op) + __op;}
|
| 135 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 136 |
+
_Tp* operator-=(ptrdiff_t __op) volatile noexcept {return fetch_sub(__op) - __op;}
|
| 137 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 138 |
+
_Tp* operator-=(ptrdiff_t __op) noexcept {return fetch_sub(__op) - __op;}
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
// atomic_ref<T>
|
| 142 |
+
|
| 143 |
+
template <class _Tp, thread_scope _Sco = thread_scope::thread_scope_system>
|
| 144 |
+
struct atomic_ref
|
| 145 |
+
: public std::__atomic_base_ref<_Tp, _Sco>
|
| 146 |
+
{
|
| 147 |
+
typedef std::__atomic_base_ref<_Tp, _Sco> __base;
|
| 148 |
+
|
| 149 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 150 |
+
constexpr atomic_ref(_Tp& __d) noexcept : __base(__d) {}
|
| 151 |
+
|
| 152 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 153 |
+
_Tp operator=(_Tp __d) const volatile noexcept
|
| 154 |
+
{__base::store(__d); return __d;}
|
| 155 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 156 |
+
_Tp operator=(_Tp __d) const noexcept
|
| 157 |
+
{__base::store(__d); return __d;}
|
| 158 |
+
|
| 159 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 160 |
+
_Tp fetch_max(const _Tp & __op, memory_order __m = memory_order_seq_cst) const volatile noexcept
|
| 161 |
+
{
|
| 162 |
+
return std::__detail::__cxx_atomic_fetch_max(&this->__a_, __op, __m);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 166 |
+
_Tp fetch_min(const _Tp & __op, memory_order __m = memory_order_seq_cst) const volatile noexcept
|
| 167 |
+
{
|
| 168 |
+
return std::__detail::__cxx_atomic_fetch_min(&this->__a_, __op, __m);
|
| 169 |
+
}
|
| 170 |
+
};
|
| 171 |
+
|
| 172 |
+
// atomic_ref<T*>
|
| 173 |
+
|
| 174 |
+
template <class _Tp, thread_scope _Sco>
|
| 175 |
+
struct atomic_ref<_Tp*, _Sco>
|
| 176 |
+
: public std::__atomic_base_ref<_Tp*, _Sco>
|
| 177 |
+
{
|
| 178 |
+
typedef std::__atomic_base_ref<_Tp*, _Sco> __base;
|
| 179 |
+
|
| 180 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 181 |
+
constexpr atomic_ref(_Tp*& __d) noexcept : __base(__d) {}
|
| 182 |
+
|
| 183 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 184 |
+
_Tp* operator=(_Tp* __d) const volatile noexcept
|
| 185 |
+
{__base::store(__d); return __d;}
|
| 186 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 187 |
+
_Tp* operator=(_Tp* __d) const noexcept
|
| 188 |
+
{__base::store(__d); return __d;}
|
| 189 |
+
|
| 190 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 191 |
+
_Tp* fetch_add(ptrdiff_t __op,
|
| 192 |
+
memory_order __m = memory_order_seq_cst) const volatile noexcept
|
| 193 |
+
{return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
|
| 194 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 195 |
+
_Tp* fetch_add(ptrdiff_t __op,
|
| 196 |
+
memory_order __m = memory_order_seq_cst) const noexcept
|
| 197 |
+
{return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
|
| 198 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 199 |
+
_Tp* fetch_sub(ptrdiff_t __op,
|
| 200 |
+
memory_order __m = memory_order_seq_cst) const volatile noexcept
|
| 201 |
+
{return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
|
| 202 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 203 |
+
_Tp* fetch_sub(ptrdiff_t __op,
|
| 204 |
+
memory_order __m = memory_order_seq_cst) const noexcept
|
| 205 |
+
{return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
|
| 206 |
+
|
| 207 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 208 |
+
_Tp* operator++(int) const volatile noexcept {return fetch_add(1);}
|
| 209 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 210 |
+
_Tp* operator++(int) const noexcept {return fetch_add(1);}
|
| 211 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 212 |
+
_Tp* operator--(int) const volatile noexcept {return fetch_sub(1);}
|
| 213 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 214 |
+
_Tp* operator--(int) const noexcept {return fetch_sub(1);}
|
| 215 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 216 |
+
_Tp* operator++() const volatile noexcept {return fetch_add(1) + 1;}
|
| 217 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 218 |
+
_Tp* operator++() const noexcept {return fetch_add(1) + 1;}
|
| 219 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 220 |
+
_Tp* operator--() const volatile noexcept {return fetch_sub(1) - 1;}
|
| 221 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 222 |
+
_Tp* operator--() const noexcept {return fetch_sub(1) - 1;}
|
| 223 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 224 |
+
_Tp* operator+=(ptrdiff_t __op) const volatile noexcept {return fetch_add(__op) + __op;}
|
| 225 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 226 |
+
_Tp* operator+=(ptrdiff_t __op) const noexcept {return fetch_add(__op) + __op;}
|
| 227 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 228 |
+
_Tp* operator-=(ptrdiff_t __op) const volatile noexcept {return fetch_sub(__op) - __op;}
|
| 229 |
+
_LIBCUDACXX_HOST_DEVICE
|
| 230 |
+
_Tp* operator-=(ptrdiff_t __op) const noexcept {return fetch_sub(__op) - __op;}
|
| 231 |
+
};
|
| 232 |
+
|
| 233 |
+
inline _LIBCUDACXX_HOST_DEVICE void atomic_thread_fence(memory_order __m, thread_scope _Scope = thread_scope::thread_scope_system) {
|
| 234 |
+
NV_DISPATCH_TARGET(
|
| 235 |
+
NV_IS_DEVICE, (
|
| 236 |
+
switch(_Scope) {
|
| 237 |
+
case thread_scope::thread_scope_system:
|
| 238 |
+
std::__detail::__atomic_thread_fence_cuda((int)__m, __detail::__thread_scope_system_tag());
|
| 239 |
+
break;
|
| 240 |
+
case thread_scope::thread_scope_device:
|
| 241 |
+
std::__detail::__atomic_thread_fence_cuda((int)__m, __detail::__thread_scope_device_tag());
|
| 242 |
+
break;
|
| 243 |
+
case thread_scope::thread_scope_block:
|
| 244 |
+
std::__detail::__atomic_thread_fence_cuda((int)__m, __detail::__thread_scope_block_tag());
|
| 245 |
+
break;
|
| 246 |
+
// Atomics scoped to themselves do not require fencing
|
| 247 |
+
case thread_scope::thread_scope_thread:
|
| 248 |
+
break;
|
| 249 |
+
}
|
| 250 |
+
),
|
| 251 |
+
NV_IS_HOST, (
|
| 252 |
+
(void) _Scope;
|
| 253 |
+
std::atomic_thread_fence(__m);
|
| 254 |
+
)
|
| 255 |
+
)
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
inline _LIBCUDACXX_HOST_DEVICE void atomic_signal_fence(memory_order __m) {
|
| 259 |
+
std::atomic_signal_fence(__m);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 263 |
+
|
| 264 |
+
#endif // _LIBCUDACXX___CUDA_ATOMIC_H
|
cuda_toolkit/include/__cuda/atomic_prelude.h
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_ATOMIC_PRELUDE_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_ATOMIC_PRELUDE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/atomic_prelude> should only be included in from <cuda/std/atomic>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#ifndef _LIBCUDACXX_COMPILER_NVRTC
|
| 19 |
+
#include "../cassert" // TRANSITION: Fix transitive includes
|
| 20 |
+
#include <atomic>
|
| 21 |
+
static_assert(ATOMIC_BOOL_LOCK_FREE == 2, "");
|
| 22 |
+
static_assert(ATOMIC_CHAR_LOCK_FREE == 2, "");
|
| 23 |
+
static_assert(ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
|
| 24 |
+
static_assert(ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
|
| 25 |
+
static_assert(ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
|
| 26 |
+
static_assert(ATOMIC_SHORT_LOCK_FREE == 2, "");
|
| 27 |
+
static_assert(ATOMIC_INT_LOCK_FREE == 2, "");
|
| 28 |
+
static_assert(ATOMIC_LONG_LOCK_FREE == 2, "");
|
| 29 |
+
static_assert(ATOMIC_LLONG_LOCK_FREE == 2, "");
|
| 30 |
+
static_assert(ATOMIC_POINTER_LOCK_FREE == 2, "");
|
| 31 |
+
#undef ATOMIC_BOOL_LOCK_FREE
|
| 32 |
+
#undef ATOMIC_BOOL_LOCK_FREE
|
| 33 |
+
#undef ATOMIC_CHAR_LOCK_FREE
|
| 34 |
+
#undef ATOMIC_CHAR16_T_LOCK_FREE
|
| 35 |
+
#undef ATOMIC_CHAR32_T_LOCK_FREE
|
| 36 |
+
#undef ATOMIC_WCHAR_T_LOCK_FREE
|
| 37 |
+
#undef ATOMIC_SHORT_LOCK_FREE
|
| 38 |
+
#undef ATOMIC_INT_LOCK_FREE
|
| 39 |
+
#undef ATOMIC_LONG_LOCK_FREE
|
| 40 |
+
#undef ATOMIC_LLONG_LOCK_FREE
|
| 41 |
+
#undef ATOMIC_POINTER_LOCK_FREE
|
| 42 |
+
#undef ATOMIC_FLAG_INIT
|
| 43 |
+
#undef ATOMIC_VAR_INIT
|
| 44 |
+
#endif // _LIBCUDACXX_COMPILER_NVRTC
|
| 45 |
+
|
| 46 |
+
// pre-define lock free query for heterogeneous compatibility
|
| 47 |
+
#ifndef _LIBCUDACXX_ATOMIC_IS_LOCK_FREE
|
| 48 |
+
#define _LIBCUDACXX_ATOMIC_IS_LOCK_FREE(__x) (__x <= 8)
|
| 49 |
+
#endif
|
| 50 |
+
|
| 51 |
+
#ifndef _LIBCUDACXX_COMPILER_NVRTC
|
| 52 |
+
#include <thread>
|
| 53 |
+
#include <errno.h>
|
| 54 |
+
#endif // _LIBCUDACXX_COMPILER_NVRTC
|
| 55 |
+
|
| 56 |
+
#endif // _LIBCUDACXX___CUDA_ATOMIC_PRELUDE_H
|
cuda_toolkit/include/__cuda/barrier.h
ADDED
|
@@ -0,0 +1,1257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_BARRIER_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_BARRIER_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/barrier> should only be included in from <cuda/std/barrier>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#if defined(__CUDA_MINIMUM_ARCH__) && __CUDA_MINIMUM_ARCH__ < 700
|
| 19 |
+
# error "CUDA synchronization primitives are only supported for sm_70 and up."
|
| 20 |
+
#endif
|
| 21 |
+
|
| 22 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 23 |
+
# pragma GCC system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 25 |
+
# pragma clang system_header
|
| 26 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 27 |
+
# pragma system_header
|
| 28 |
+
#endif // no system header
|
| 29 |
+
|
| 30 |
+
#include "../cstdlib" // _LIBCUDACXX_UNREACHABLE
|
| 31 |
+
#include "../__type_traits/void_t.h" // _CUDA_VSTD::__void_t
|
| 32 |
+
|
| 33 |
+
#if defined(_CCCL_CUDA_COMPILER)
|
| 34 |
+
#include "../__cuda/ptx.h" // cuda::ptx::*
|
| 35 |
+
#endif // _CCCL_CUDA_COMPILER
|
| 36 |
+
|
| 37 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC)
|
| 38 |
+
#define _LIBCUDACXX_OFFSET_IS_ZERO(type, member) !(&(((type *)0)->member))
|
| 39 |
+
#else
|
| 40 |
+
#define _LIBCUDACXX_OFFSET_IS_ZERO(type, member) !offsetof(type, member)
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 44 |
+
|
| 45 |
+
// foward declaration required for memcpy_async, pipeline "sync" defined here
|
| 46 |
+
template<thread_scope _Scope>
|
| 47 |
+
class pipeline;
|
| 48 |
+
|
| 49 |
+
template<_CUDA_VSTD::size_t _Alignment>
|
| 50 |
+
struct aligned_size_t {
|
| 51 |
+
static constexpr _CUDA_VSTD::size_t align = _Alignment;
|
| 52 |
+
_CUDA_VSTD::size_t value;
|
| 53 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 54 |
+
explicit aligned_size_t(size_t __s) : value(__s) { }
|
| 55 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 56 |
+
operator size_t() const { return value; }
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
// Type only used for logging purpose
|
| 60 |
+
enum async_contract_fulfillment
|
| 61 |
+
{
|
| 62 |
+
none,
|
| 63 |
+
async
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
// __completion_mechanism allows memcpy_async to report back what completion
|
| 67 |
+
// mechanism it used. This is necessary to determine in which way to synchronize
|
| 68 |
+
// the memcpy_async with a sync object (barrier or pipeline).
|
| 69 |
+
//
|
| 70 |
+
// In addition, we use this enum to create bit flags so that calling functions
|
| 71 |
+
// can specify which completion mechanisms can be used (__sync is always
|
| 72 |
+
// allowed).
|
| 73 |
+
enum class __completion_mechanism {
|
| 74 |
+
__sync = 0,
|
| 75 |
+
__mbarrier_complete_tx = 1 << 0, // Use powers of two here to support the
|
| 76 |
+
__async_group = 1 << 1, // bit flag use case
|
| 77 |
+
__async_bulk_group = 1 << 2,
|
| 78 |
+
};
|
| 79 |
+
|
| 80 |
+
template<thread_scope _Sco, class _CompletionF = _CUDA_VSTD::__empty_completion>
|
| 81 |
+
class barrier : public _CUDA_VSTD::__barrier_base<_CompletionF, _Sco> {
|
| 82 |
+
public:
|
| 83 |
+
barrier() = default;
|
| 84 |
+
|
| 85 |
+
barrier(const barrier &) = delete;
|
| 86 |
+
barrier & operator=(const barrier &) = delete;
|
| 87 |
+
|
| 88 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 89 |
+
barrier(_CUDA_VSTD::ptrdiff_t __expected, _CompletionF __completion = _CompletionF())
|
| 90 |
+
: _CUDA_VSTD::__barrier_base<_CompletionF, _Sco>(__expected, __completion) {
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 94 |
+
friend void init(barrier * __b, _CUDA_VSTD::ptrdiff_t __expected) {
|
| 95 |
+
_LIBCUDACXX_DEBUG_ASSERT(__expected >= 0, "Cannot initialize barrier with negative arrival count");
|
| 96 |
+
new (__b) barrier(__expected);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 100 |
+
friend void init(barrier * __b, _CUDA_VSTD::ptrdiff_t __expected, _CompletionF __completion) {
|
| 101 |
+
_LIBCUDACXX_DEBUG_ASSERT(__expected >= 0, "Cannot initialize barrier with negative arrival count");
|
| 102 |
+
new (__b) barrier(__expected, __completion);
|
| 103 |
+
}
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
struct __block_scope_barrier_base {};
|
| 107 |
+
|
| 108 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 109 |
+
|
| 110 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_DEVICE
|
| 111 |
+
|
| 112 |
+
_LIBCUDACXX_DEVICE
|
| 113 |
+
inline _CUDA_VSTD::uint64_t * barrier_native_handle(barrier<thread_scope_block> & b);
|
| 114 |
+
|
| 115 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_DEVICE
|
| 116 |
+
|
| 117 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 118 |
+
|
| 119 |
+
template<>
|
| 120 |
+
class barrier<thread_scope_block, _CUDA_VSTD::__empty_completion> : public __block_scope_barrier_base {
|
| 121 |
+
using __barrier_base = _CUDA_VSTD::__barrier_base<_CUDA_VSTD::__empty_completion, (int)thread_scope_block>;
|
| 122 |
+
__barrier_base __barrier;
|
| 123 |
+
|
| 124 |
+
_LIBCUDACXX_DEVICE
|
| 125 |
+
friend inline _CUDA_VSTD::uint64_t * device::_LIBCUDACXX_ABI_NAMESPACE::barrier_native_handle(barrier<thread_scope_block> & b);
|
| 126 |
+
|
| 127 |
+
template<typename _Barrier>
|
| 128 |
+
friend class _CUDA_VSTD::__barrier_poll_tester_phase;
|
| 129 |
+
template<typename _Barrier>
|
| 130 |
+
friend class _CUDA_VSTD::__barrier_poll_tester_parity;
|
| 131 |
+
|
| 132 |
+
public:
|
| 133 |
+
using arrival_token = typename __barrier_base::arrival_token;
|
| 134 |
+
barrier() = default;
|
| 135 |
+
|
| 136 |
+
barrier(const barrier &) = delete;
|
| 137 |
+
barrier & operator=(const barrier &) = delete;
|
| 138 |
+
|
| 139 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 140 |
+
barrier(_CUDA_VSTD::ptrdiff_t __expected, _CUDA_VSTD::__empty_completion __completion = _CUDA_VSTD::__empty_completion()) {
|
| 141 |
+
static_assert(_LIBCUDACXX_OFFSET_IS_ZERO(barrier<thread_scope_block>, __barrier), "fatal error: bad barrier layout");
|
| 142 |
+
init(this, __expected, __completion);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 146 |
+
~barrier() {
|
| 147 |
+
NV_DISPATCH_TARGET(
|
| 148 |
+
NV_PROVIDES_SM_90, (
|
| 149 |
+
if (__isShared(&__barrier)) {
|
| 150 |
+
asm volatile ("mbarrier.inval.shared.b64 [%0];"
|
| 151 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier)))
|
| 152 |
+
: "memory");
|
| 153 |
+
}
|
| 154 |
+
else if (__isClusterShared(&__barrier)) {
|
| 155 |
+
__trap();
|
| 156 |
+
}
|
| 157 |
+
), NV_PROVIDES_SM_80, (
|
| 158 |
+
if (__isShared(&__barrier)) {
|
| 159 |
+
asm volatile ("mbarrier.inval.shared.b64 [%0];"
|
| 160 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier)))
|
| 161 |
+
: "memory");
|
| 162 |
+
}
|
| 163 |
+
)
|
| 164 |
+
)
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 168 |
+
friend void init(barrier * __b, _CUDA_VSTD::ptrdiff_t __expected, _CUDA_VSTD::__empty_completion __completion = _CUDA_VSTD::__empty_completion()) {
|
| 169 |
+
NV_DISPATCH_TARGET(
|
| 170 |
+
NV_PROVIDES_SM_90, (
|
| 171 |
+
if (__isShared(&__b->__barrier)) {
|
| 172 |
+
asm volatile ("mbarrier.init.shared.b64 [%0], %1;"
|
| 173 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__b->__barrier))),
|
| 174 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__expected))
|
| 175 |
+
: "memory");
|
| 176 |
+
}
|
| 177 |
+
else if (__isClusterShared(&__b->__barrier))
|
| 178 |
+
{
|
| 179 |
+
__trap();
|
| 180 |
+
}
|
| 181 |
+
else
|
| 182 |
+
{
|
| 183 |
+
new (&__b->__barrier) __barrier_base(__expected);
|
| 184 |
+
}
|
| 185 |
+
),
|
| 186 |
+
NV_PROVIDES_SM_80, (
|
| 187 |
+
if (__isShared(&__b->__barrier)) {
|
| 188 |
+
asm volatile ("mbarrier.init.shared.b64 [%0], %1;"
|
| 189 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__b->__barrier))),
|
| 190 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__expected))
|
| 191 |
+
: "memory");
|
| 192 |
+
}
|
| 193 |
+
else
|
| 194 |
+
{
|
| 195 |
+
new (&__b->__barrier) __barrier_base(__expected);
|
| 196 |
+
}
|
| 197 |
+
), NV_ANY_TARGET, (
|
| 198 |
+
new (&__b->__barrier) __barrier_base(__expected);
|
| 199 |
+
)
|
| 200 |
+
)
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 204 |
+
arrival_token arrive(_CUDA_VSTD::ptrdiff_t __update = 1) {
|
| 205 |
+
_LIBCUDACXX_DEBUG_ASSERT(__update >= 0, "Arrival count update must be non-negative.");
|
| 206 |
+
arrival_token __token = {};
|
| 207 |
+
NV_DISPATCH_TARGET(
|
| 208 |
+
NV_PROVIDES_SM_90, (
|
| 209 |
+
if (!__isClusterShared(&__barrier)) {
|
| 210 |
+
return __barrier.arrive(__update);
|
| 211 |
+
}
|
| 212 |
+
else if (!__isShared(&__barrier)) {
|
| 213 |
+
__trap();
|
| 214 |
+
}
|
| 215 |
+
// Cannot use cuda::device::barrier_native_handle here, as it is
|
| 216 |
+
// only defined for block-scope barriers. This barrier may be a
|
| 217 |
+
// non-block scoped barrier.
|
| 218 |
+
auto __bh = reinterpret_cast<_CUDA_VSTD::uint64_t*>(&__barrier);
|
| 219 |
+
__token = _CUDA_VPTX::mbarrier_arrive(__bh, __update);
|
| 220 |
+
), NV_PROVIDES_SM_80, (
|
| 221 |
+
if (!__isShared(&__barrier)) {
|
| 222 |
+
return __barrier.arrive(__update);
|
| 223 |
+
}
|
| 224 |
+
auto __bh = reinterpret_cast<_CUDA_VSTD::uint64_t*>(&__barrier);
|
| 225 |
+
// Need 2 instructions, can't finish barrier with arrive > 1
|
| 226 |
+
if (__update > 1) {
|
| 227 |
+
_CUDA_VPTX::mbarrier_arrive_no_complete(__bh, __update - 1);
|
| 228 |
+
}
|
| 229 |
+
__token = _CUDA_VPTX::mbarrier_arrive( __bh);
|
| 230 |
+
), NV_IS_DEVICE, (
|
| 231 |
+
if (!__isShared(&__barrier)) {
|
| 232 |
+
return __barrier.arrive(__update);
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
unsigned int __mask = __activemask();
|
| 236 |
+
unsigned int __activeA = __match_any_sync(__mask, __update);
|
| 237 |
+
unsigned int __activeB = __match_any_sync(__mask, reinterpret_cast<_CUDA_VSTD::uintptr_t>(&__barrier));
|
| 238 |
+
unsigned int __active = __activeA & __activeB;
|
| 239 |
+
int __inc = __popc(__active) * __update;
|
| 240 |
+
|
| 241 |
+
unsigned __laneid;
|
| 242 |
+
asm ("mov.u32 %0, %%laneid;" : "=r"(__laneid));
|
| 243 |
+
int __leader = __ffs(__active) - 1;
|
| 244 |
+
// All threads in mask synchronize here, establishing cummulativity to the __leader:
|
| 245 |
+
__syncwarp(__mask);
|
| 246 |
+
if(__leader == static_cast<int>(__laneid))
|
| 247 |
+
{
|
| 248 |
+
__token = __barrier.arrive(__inc);
|
| 249 |
+
}
|
| 250 |
+
__token = __shfl_sync(__active, __token, __leader);
|
| 251 |
+
), NV_IS_HOST, (
|
| 252 |
+
__token = __barrier.arrive(__update);
|
| 253 |
+
)
|
| 254 |
+
)
|
| 255 |
+
return __token;
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
private:
|
| 259 |
+
|
| 260 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 261 |
+
inline bool __test_wait_sm_80(arrival_token __token) const {
|
| 262 |
+
int32_t __ready = 0;
|
| 263 |
+
NV_DISPATCH_TARGET(
|
| 264 |
+
NV_PROVIDES_SM_80, (
|
| 265 |
+
asm volatile ("{\n\t"
|
| 266 |
+
".reg .pred p;\n\t"
|
| 267 |
+
"mbarrier.test_wait.shared.b64 p, [%1], %2;\n\t"
|
| 268 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 269 |
+
"}"
|
| 270 |
+
: "=r"(__ready)
|
| 271 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 272 |
+
"l"(__token)
|
| 273 |
+
: "memory");
|
| 274 |
+
)
|
| 275 |
+
)
|
| 276 |
+
return __ready;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
// Document de drop > uint32_t for __nanosec on public for APIs
|
| 280 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 281 |
+
bool __try_wait(arrival_token __token) const {
|
| 282 |
+
NV_DISPATCH_TARGET(
|
| 283 |
+
NV_PROVIDES_SM_90, (
|
| 284 |
+
int32_t __ready = 0;
|
| 285 |
+
if (!__isClusterShared(&__barrier)) {
|
| 286 |
+
return _CUDA_VSTD::__call_try_wait(__barrier, _CUDA_VSTD::move(__token));
|
| 287 |
+
}
|
| 288 |
+
else if (!__isShared(&__barrier)) {
|
| 289 |
+
__trap();
|
| 290 |
+
}
|
| 291 |
+
asm volatile ("{\n\t"
|
| 292 |
+
".reg .pred p;\n\t"
|
| 293 |
+
"mbarrier.try_wait.shared.b64 p, [%1], %2;\n\t"
|
| 294 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 295 |
+
"}"
|
| 296 |
+
: "=r"(__ready)
|
| 297 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 298 |
+
"l"(__token)
|
| 299 |
+
: "memory");
|
| 300 |
+
return __ready;
|
| 301 |
+
), NV_PROVIDES_SM_80, (
|
| 302 |
+
if (!__isShared(&__barrier)) {
|
| 303 |
+
return _CUDA_VSTD::__call_try_wait(__barrier, _CUDA_VSTD::move(__token));
|
| 304 |
+
}
|
| 305 |
+
return __test_wait_sm_80(__token);
|
| 306 |
+
), NV_ANY_TARGET, (
|
| 307 |
+
return _CUDA_VSTD::__call_try_wait(__barrier, _CUDA_VSTD::move(__token));
|
| 308 |
+
)
|
| 309 |
+
)
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// Document de drop > uint32_t for __nanosec on public for APIs
|
| 313 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 314 |
+
bool __try_wait(arrival_token __token, _CUDA_VSTD::chrono::nanoseconds __nanosec) const {
|
| 315 |
+
if (__nanosec.count() < 1) {
|
| 316 |
+
return __try_wait(_CUDA_VSTD::move(__token));
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
NV_DISPATCH_TARGET(
|
| 320 |
+
NV_PROVIDES_SM_90, (
|
| 321 |
+
int32_t __ready = 0;
|
| 322 |
+
if (!__isClusterShared(&__barrier)) {
|
| 323 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 324 |
+
_CUDA_VSTD::__barrier_poll_tester_phase<barrier>(this, _CUDA_VSTD::move(__token)),
|
| 325 |
+
__nanosec);
|
| 326 |
+
}
|
| 327 |
+
else if (!__isShared(&__barrier)) {
|
| 328 |
+
__trap();
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
_CUDA_VSTD::chrono::high_resolution_clock::time_point const __start = _CUDA_VSTD::chrono::high_resolution_clock::now();
|
| 332 |
+
_CUDA_VSTD::chrono::nanoseconds __elapsed;
|
| 333 |
+
do {
|
| 334 |
+
const _CUDA_VSTD::uint32_t __wait_nsec = static_cast<_CUDA_VSTD::uint32_t>((__nanosec - __elapsed).count());
|
| 335 |
+
asm volatile ("{\n\t"
|
| 336 |
+
".reg .pred p;\n\t"
|
| 337 |
+
"mbarrier.try_wait.shared.b64 p, [%1], %2, %3;\n\t"
|
| 338 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 339 |
+
"}"
|
| 340 |
+
: "=r"(__ready)
|
| 341 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 342 |
+
"l"(__token)
|
| 343 |
+
"r"(__wait_nsec)
|
| 344 |
+
: "memory");
|
| 345 |
+
__elapsed = _CUDA_VSTD::chrono::high_resolution_clock::now() - __start;
|
| 346 |
+
} while (!__ready && (__nanosec > __elapsed));
|
| 347 |
+
return __ready;
|
| 348 |
+
), NV_PROVIDES_SM_80, (
|
| 349 |
+
bool __ready = 0;
|
| 350 |
+
if (!__isShared(&__barrier)) {
|
| 351 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 352 |
+
_CUDA_VSTD::__barrier_poll_tester_phase<barrier>(this, _CUDA_VSTD::move(__token)),
|
| 353 |
+
__nanosec);
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
_CUDA_VSTD::chrono::high_resolution_clock::time_point const __start = _CUDA_VSTD::chrono::high_resolution_clock::now();
|
| 357 |
+
do {
|
| 358 |
+
__ready = __test_wait_sm_80(__token);
|
| 359 |
+
} while (!__ready &&
|
| 360 |
+
__nanosec > (_CUDA_VSTD::chrono::high_resolution_clock::now() - __start));
|
| 361 |
+
return __ready;
|
| 362 |
+
), NV_ANY_TARGET, (
|
| 363 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 364 |
+
_CUDA_VSTD::__barrier_poll_tester_phase<barrier>(this, _CUDA_VSTD::move(__token)),
|
| 365 |
+
_CUDA_VSTD::chrono::nanoseconds(__nanosec));
|
| 366 |
+
)
|
| 367 |
+
)
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 371 |
+
inline bool __test_wait_parity_sm_80(bool __phase_parity) const {
|
| 372 |
+
uint16_t __ready = 0;
|
| 373 |
+
NV_DISPATCH_TARGET(
|
| 374 |
+
NV_PROVIDES_SM_80, (
|
| 375 |
+
asm volatile ("{"
|
| 376 |
+
".reg .pred %%p;"
|
| 377 |
+
"mbarrier.test_wait.parity.shared.b64 %%p, [%1], %2;"
|
| 378 |
+
"selp.u16 %0, 1, 0, %%p;"
|
| 379 |
+
"}"
|
| 380 |
+
: "=h"(__ready)
|
| 381 |
+
: "r"(static_cast<uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 382 |
+
"r"(static_cast<uint32_t>(__phase_parity))
|
| 383 |
+
: "memory");
|
| 384 |
+
)
|
| 385 |
+
)
|
| 386 |
+
return __ready;
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 390 |
+
bool __try_wait_parity(bool __phase_parity) const {
|
| 391 |
+
NV_DISPATCH_TARGET(
|
| 392 |
+
NV_PROVIDES_SM_90, (
|
| 393 |
+
if (!__isClusterShared(&__barrier)) {
|
| 394 |
+
return _CUDA_VSTD::__call_try_wait_parity(__barrier, __phase_parity);
|
| 395 |
+
}
|
| 396 |
+
else if (!__isShared(&__barrier)) {
|
| 397 |
+
__trap();
|
| 398 |
+
}
|
| 399 |
+
int32_t __ready = 0;
|
| 400 |
+
|
| 401 |
+
asm volatile ("{\n\t"
|
| 402 |
+
".reg .pred p;\n\t"
|
| 403 |
+
"mbarrier.try_wait.parity.shared.b64 p, [%1], %2;\n\t"
|
| 404 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 405 |
+
"}"
|
| 406 |
+
: "=r"(__ready)
|
| 407 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 408 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__phase_parity))
|
| 409 |
+
:);
|
| 410 |
+
|
| 411 |
+
return __ready;
|
| 412 |
+
), NV_PROVIDES_SM_80, (
|
| 413 |
+
if (!__isShared(&__barrier)) {
|
| 414 |
+
return _CUDA_VSTD::__call_try_wait_parity(__barrier, __phase_parity);
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
return __test_wait_parity_sm_80(__phase_parity);
|
| 418 |
+
), NV_ANY_TARGET, (
|
| 419 |
+
return _CUDA_VSTD::__call_try_wait_parity(__barrier, __phase_parity);
|
| 420 |
+
)
|
| 421 |
+
)
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 425 |
+
bool __try_wait_parity(bool __phase_parity, _CUDA_VSTD::chrono::nanoseconds __nanosec) const {
|
| 426 |
+
if (__nanosec.count() < 1) {
|
| 427 |
+
return __try_wait_parity(__phase_parity);
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
NV_DISPATCH_TARGET(
|
| 431 |
+
NV_PROVIDES_SM_90, (
|
| 432 |
+
int32_t __ready = 0;
|
| 433 |
+
if (!__isClusterShared(&__barrier)) {
|
| 434 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 435 |
+
_CUDA_VSTD::__barrier_poll_tester_parity<barrier>(this, __phase_parity),
|
| 436 |
+
__nanosec);
|
| 437 |
+
}
|
| 438 |
+
else if (!__isShared(&__barrier)) {
|
| 439 |
+
__trap();
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
_CUDA_VSTD::chrono::high_resolution_clock::time_point const __start = _CUDA_VSTD::chrono::high_resolution_clock::now();
|
| 443 |
+
_CUDA_VSTD::chrono::nanoseconds __elapsed;
|
| 444 |
+
do {
|
| 445 |
+
const _CUDA_VSTD::uint32_t __wait_nsec = static_cast<_CUDA_VSTD::uint32_t>((__nanosec - __elapsed).count());
|
| 446 |
+
asm volatile ("{\n\t"
|
| 447 |
+
".reg .pred p;\n\t"
|
| 448 |
+
"mbarrier.try_wait.parity.shared.b64 p, [%1], %2, %3;\n\t"
|
| 449 |
+
"selp.b32 %0, 1, 0, p;\n\t"
|
| 450 |
+
"}"
|
| 451 |
+
: "=r"(__ready)
|
| 452 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier))),
|
| 453 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__phase_parity)),
|
| 454 |
+
"r"(__wait_nsec)
|
| 455 |
+
: "memory");
|
| 456 |
+
__elapsed = _CUDA_VSTD::chrono::high_resolution_clock::now() - __start;
|
| 457 |
+
} while (!__ready && (__nanosec > __elapsed));
|
| 458 |
+
|
| 459 |
+
return __ready;
|
| 460 |
+
), NV_PROVIDES_SM_80, (
|
| 461 |
+
bool __ready = 0;
|
| 462 |
+
if (!__isShared(&__barrier)) {
|
| 463 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 464 |
+
_CUDA_VSTD::__barrier_poll_tester_parity<barrier>(this, __phase_parity),
|
| 465 |
+
__nanosec);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
_CUDA_VSTD::chrono::high_resolution_clock::time_point const __start = _CUDA_VSTD::chrono::high_resolution_clock::now();
|
| 469 |
+
do {
|
| 470 |
+
__ready = __test_wait_parity_sm_80(__phase_parity);
|
| 471 |
+
} while (!__ready &&
|
| 472 |
+
__nanosec > (_CUDA_VSTD::chrono::high_resolution_clock::now() - __start));
|
| 473 |
+
|
| 474 |
+
return __ready;
|
| 475 |
+
), NV_ANY_TARGET, (
|
| 476 |
+
return _CUDA_VSTD::__libcpp_thread_poll_with_backoff(
|
| 477 |
+
_CUDA_VSTD::__barrier_poll_tester_parity<barrier>(this, __phase_parity),
|
| 478 |
+
__nanosec);
|
| 479 |
+
)
|
| 480 |
+
)
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
public:
|
| 484 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 485 |
+
void wait(arrival_token && __phase) const {
|
| 486 |
+
_CUDA_VSTD::__libcpp_thread_poll_with_backoff(_CUDA_VSTD::__barrier_poll_tester_phase<barrier>(this, _CUDA_VSTD::move(__phase)));
|
| 487 |
+
}
|
| 488 |
+
|
| 489 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 490 |
+
void wait_parity(bool __phase_parity) const {
|
| 491 |
+
_CUDA_VSTD::__libcpp_thread_poll_with_backoff(_CUDA_VSTD::__barrier_poll_tester_parity<barrier>(this, __phase_parity));
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 495 |
+
void arrive_and_wait() {
|
| 496 |
+
wait(arrive());
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 500 |
+
void arrive_and_drop() {
|
| 501 |
+
NV_DISPATCH_TARGET(
|
| 502 |
+
NV_PROVIDES_SM_90, (
|
| 503 |
+
if (!__isClusterShared(&__barrier)) {
|
| 504 |
+
return __barrier.arrive_and_drop();
|
| 505 |
+
}
|
| 506 |
+
else if (!__isShared(&__barrier)) {
|
| 507 |
+
__trap();
|
| 508 |
+
}
|
| 509 |
+
|
| 510 |
+
asm volatile ("mbarrier.arrive_drop.shared.b64 _, [%0];"
|
| 511 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier)))
|
| 512 |
+
: "memory");
|
| 513 |
+
), NV_PROVIDES_SM_80, (
|
| 514 |
+
// Fallback to slowpath on device
|
| 515 |
+
if (!__isShared(&__barrier)) {
|
| 516 |
+
__barrier.arrive_and_drop();
|
| 517 |
+
return;
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
asm volatile ("mbarrier.arrive_drop.shared.b64 _, [%0];"
|
| 521 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(&__barrier)))
|
| 522 |
+
: "memory");
|
| 523 |
+
), NV_ANY_TARGET, (
|
| 524 |
+
// Fallback to slowpath on device
|
| 525 |
+
__barrier.arrive_and_drop();
|
| 526 |
+
)
|
| 527 |
+
)
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 531 |
+
static constexpr ptrdiff_t max() noexcept {
|
| 532 |
+
return (1 << 20) - 1;
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
template<class _Rep, class _Period>
|
| 536 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 537 |
+
bool try_wait_for(arrival_token && __token, const _CUDA_VSTD::chrono::duration<_Rep, _Period>& __dur) {
|
| 538 |
+
auto __nanosec = _CUDA_VSTD::chrono::duration_cast<_CUDA_VSTD::chrono::nanoseconds>(__dur);
|
| 539 |
+
|
| 540 |
+
return __try_wait(_CUDA_VSTD::move(__token), __nanosec);
|
| 541 |
+
}
|
| 542 |
+
|
| 543 |
+
template<class _Clock, class _Duration>
|
| 544 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 545 |
+
bool try_wait_until(arrival_token && __token, const _CUDA_VSTD::chrono::time_point<_Clock, _Duration>& __time) {
|
| 546 |
+
return try_wait_for(_CUDA_VSTD::move(__token), (__time - _Clock::now()));
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
template<class _Rep, class _Period>
|
| 550 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 551 |
+
bool try_wait_parity_for(bool __phase_parity, const _CUDA_VSTD::chrono::duration<_Rep, _Period>& __dur) {
|
| 552 |
+
auto __nanosec = _CUDA_VSTD::chrono::duration_cast<_CUDA_VSTD::chrono::nanoseconds>(__dur);
|
| 553 |
+
|
| 554 |
+
return __try_wait_parity(__phase_parity, __nanosec);
|
| 555 |
+
}
|
| 556 |
+
|
| 557 |
+
template<class _Clock, class _Duration>
|
| 558 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 559 |
+
bool try_wait_parity_until(bool __phase_parity, const _CUDA_VSTD::chrono::time_point<_Clock, _Duration>& __time) {
|
| 560 |
+
return try_wait_parity_for(__phase_parity, (__time - _Clock::now()));
|
| 561 |
+
}
|
| 562 |
+
};
|
| 563 |
+
|
| 564 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 565 |
+
|
| 566 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_DEVICE
|
| 567 |
+
|
| 568 |
+
_LIBCUDACXX_DEVICE
|
| 569 |
+
inline _CUDA_VSTD::uint64_t * barrier_native_handle(barrier<thread_scope_block> & b) {
|
| 570 |
+
return reinterpret_cast<_CUDA_VSTD::uint64_t *>(&b.__barrier);
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
#if defined(_CCCL_CUDA_COMPILER)
|
| 574 |
+
|
| 575 |
+
#if __cccl_ptx_isa >= 800
|
| 576 |
+
extern "C" _LIBCUDACXX_DEVICE void __cuda_ptx_barrier_arrive_tx_is_not_supported_before_SM_90__();
|
| 577 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_DEVICE inline
|
| 578 |
+
barrier<thread_scope_block>::arrival_token barrier_arrive_tx(
|
| 579 |
+
barrier<thread_scope_block> & __b,
|
| 580 |
+
_CUDA_VSTD::ptrdiff_t __arrive_count_update,
|
| 581 |
+
_CUDA_VSTD::ptrdiff_t __transaction_count_update) {
|
| 582 |
+
|
| 583 |
+
_LIBCUDACXX_DEBUG_ASSERT(__isShared(barrier_native_handle(__b)), "Barrier must be located in local shared memory.");
|
| 584 |
+
_LIBCUDACXX_DEBUG_ASSERT(1 <= __arrive_count_update, "Arrival count update must be at least one.");
|
| 585 |
+
_LIBCUDACXX_DEBUG_ASSERT(__arrive_count_update <= (1 << 20) - 1, "Arrival count update cannot exceed 2^20 - 1.");
|
| 586 |
+
_LIBCUDACXX_DEBUG_ASSERT(__transaction_count_update >= 0, "Transaction count update must be non-negative.");
|
| 587 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#contents-of-the-mbarrier-object
|
| 588 |
+
_LIBCUDACXX_DEBUG_ASSERT(__transaction_count_update <= (1 << 20) - 1, "Transaction count update cannot exceed 2^20 - 1.");
|
| 589 |
+
|
| 590 |
+
barrier<thread_scope_block>::arrival_token __token = {};
|
| 591 |
+
NV_IF_ELSE_TARGET(
|
| 592 |
+
// On architectures pre-sm90, arrive_tx is not supported.
|
| 593 |
+
NV_PROVIDES_SM_90, (
|
| 594 |
+
// We do not check for the statespace of the barrier here. This is
|
| 595 |
+
// on purpose. This allows debugging tools like memcheck/racecheck
|
| 596 |
+
// to detect that we are passing a pointer with the wrong state
|
| 597 |
+
// space to mbarrier.arrive. If we checked for the state space here,
|
| 598 |
+
// and __trap() if wrong, then those tools would not be able to help
|
| 599 |
+
// us in release builds. In debug builds, the error would be caught
|
| 600 |
+
// by the asserts at the top of this function.
|
| 601 |
+
|
| 602 |
+
auto __native_handle = barrier_native_handle(__b);
|
| 603 |
+
auto __bh = __cvta_generic_to_shared(__native_handle);
|
| 604 |
+
if (__arrive_count_update == 1) {
|
| 605 |
+
__token = _CUDA_VPTX::mbarrier_arrive_expect_tx(
|
| 606 |
+
_CUDA_VPTX::sem_release, _CUDA_VPTX::scope_cta, _CUDA_VPTX::space_shared, __native_handle, __transaction_count_update
|
| 607 |
+
);
|
| 608 |
+
} else {
|
| 609 |
+
asm (
|
| 610 |
+
"mbarrier.expect_tx.relaxed.cta.shared::cta.b64 [%0], %1;"
|
| 611 |
+
:
|
| 612 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__bh)),
|
| 613 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__transaction_count_update))
|
| 614 |
+
: "memory");
|
| 615 |
+
__token = _CUDA_VPTX::mbarrier_arrive(
|
| 616 |
+
_CUDA_VPTX::sem_release, _CUDA_VPTX::scope_cta, _CUDA_VPTX::space_shared, __native_handle, __arrive_count_update
|
| 617 |
+
);
|
| 618 |
+
}
|
| 619 |
+
),(
|
| 620 |
+
__cuda_ptx_barrier_arrive_tx_is_not_supported_before_SM_90__();
|
| 621 |
+
)
|
| 622 |
+
);
|
| 623 |
+
return __token;
|
| 624 |
+
}
|
| 625 |
+
|
| 626 |
+
extern "C" _LIBCUDACXX_DEVICE void __cuda_ptx_barrier_expect_tx_is_not_supported_before_SM_90__();
|
| 627 |
+
_LIBCUDACXX_DEVICE inline
|
| 628 |
+
void barrier_expect_tx(
|
| 629 |
+
barrier<thread_scope_block> & __b,
|
| 630 |
+
_CUDA_VSTD::ptrdiff_t __transaction_count_update) {
|
| 631 |
+
|
| 632 |
+
_LIBCUDACXX_DEBUG_ASSERT(__isShared(barrier_native_handle(__b)), "Barrier must be located in local shared memory.");
|
| 633 |
+
_LIBCUDACXX_DEBUG_ASSERT(__transaction_count_update >= 0, "Transaction count update must be non-negative.");
|
| 634 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#contents-of-the-mbarrier-object
|
| 635 |
+
_LIBCUDACXX_DEBUG_ASSERT(__transaction_count_update <= (1 << 20) - 1, "Transaction count update cannot exceed 2^20 - 1.");
|
| 636 |
+
|
| 637 |
+
// We do not check for the statespace of the barrier here. This is
|
| 638 |
+
// on purpose. This allows debugging tools like memcheck/racecheck
|
| 639 |
+
// to detect that we are passing a pointer with the wrong state
|
| 640 |
+
// space to mbarrier.arrive. If we checked for the state space here,
|
| 641 |
+
// and __trap() if wrong, then those tools would not be able to help
|
| 642 |
+
// us in release builds. In debug builds, the error would be caught
|
| 643 |
+
// by the asserts at the top of this function.
|
| 644 |
+
NV_IF_ELSE_TARGET(
|
| 645 |
+
// On architectures pre-sm90, arrive_tx is not supported.
|
| 646 |
+
NV_PROVIDES_SM_90, (
|
| 647 |
+
auto __bh = __cvta_generic_to_shared(barrier_native_handle(__b));
|
| 648 |
+
asm (
|
| 649 |
+
"mbarrier.expect_tx.relaxed.cta.shared::cta.b64 [%0], %1;"
|
| 650 |
+
:
|
| 651 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__bh)),
|
| 652 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__transaction_count_update))
|
| 653 |
+
: "memory");
|
| 654 |
+
),(
|
| 655 |
+
__cuda_ptx_barrier_expect_tx_is_not_supported_before_SM_90__();
|
| 656 |
+
));
|
| 657 |
+
}
|
| 658 |
+
|
| 659 |
+
extern "C" _LIBCUDACXX_DEVICE void __cuda_ptx_memcpy_async_tx_is_not_supported_before_SM_90__();
|
| 660 |
+
template <typename _Tp, _CUDA_VSTD::size_t _Alignment>
|
| 661 |
+
_LIBCUDACXX_DEVICE inline async_contract_fulfillment memcpy_async_tx(
|
| 662 |
+
_Tp* __dest,
|
| 663 |
+
const _Tp* __src,
|
| 664 |
+
::cuda::aligned_size_t<_Alignment> __size,
|
| 665 |
+
::cuda::barrier<::cuda::thread_scope_block> & __b) {
|
| 666 |
+
// When compiling with NVCC and GCC 4.8, certain user defined types that _are_ trivially copyable are
|
| 667 |
+
// incorrectly classified as not trivially copyable. Remove this assertion to allow for their usage with
|
| 668 |
+
// memcpy_async when compiling with GCC 4.8.
|
| 669 |
+
// FIXME: remove the #if once GCC 4.8 is no longer supported.
|
| 670 |
+
#if !defined(_LIBCUDACXX_COMPILER_GCC) || _GNUC_VER > 408
|
| 671 |
+
static_assert(_CUDA_VSTD::is_trivially_copyable<_Tp>::value, "memcpy_async_tx requires a trivially copyable type");
|
| 672 |
+
#endif
|
| 673 |
+
static_assert(16 <= _Alignment, "mempcy_async_tx expects arguments to be at least 16 byte aligned.");
|
| 674 |
+
|
| 675 |
+
_LIBCUDACXX_DEBUG_ASSERT(__isShared(barrier_native_handle(__b)), "Barrier must be located in local shared memory.");
|
| 676 |
+
_LIBCUDACXX_DEBUG_ASSERT(__isShared(__dest), "dest must point to shared memory.");
|
| 677 |
+
_LIBCUDACXX_DEBUG_ASSERT(__isGlobal(__src), "src must point to global memory.");
|
| 678 |
+
|
| 679 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 680 |
+
auto __bh = __cvta_generic_to_shared(barrier_native_handle(__b));
|
| 681 |
+
if (__isShared(__dest) && __isGlobal(__src)) {
|
| 682 |
+
asm volatile(
|
| 683 |
+
"cp.async.bulk.shared::cluster.global.mbarrier::complete_tx::bytes [%0], [%1], %2, [%3];\n"
|
| 684 |
+
:
|
| 685 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__dest))),
|
| 686 |
+
"l"(static_cast<_CUDA_VSTD::uint64_t>(__cvta_generic_to_global(__src))),
|
| 687 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__size)),
|
| 688 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__bh))
|
| 689 |
+
: "memory");
|
| 690 |
+
} else {
|
| 691 |
+
// memcpy_async_tx only supports copying from global to shared
|
| 692 |
+
// or from shared to remote cluster dsmem. To copy to remote
|
| 693 |
+
// dsmem, we need to arrive on a cluster-scoped barrier, which
|
| 694 |
+
// is not yet implemented. So we trap in this case as well.
|
| 695 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 696 |
+
}
|
| 697 |
+
),(
|
| 698 |
+
__cuda_ptx_memcpy_async_tx_is_not_supported_before_SM_90__();
|
| 699 |
+
));
|
| 700 |
+
|
| 701 |
+
return async_contract_fulfillment::async;
|
| 702 |
+
}
|
| 703 |
+
#endif // __cccl_ptx_isa >= 800
|
| 704 |
+
#endif // _CCCL_CUDA_COMPILER
|
| 705 |
+
|
| 706 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_DEVICE
|
| 707 |
+
|
| 708 |
+
#if defined(_CCCL_CUDA_COMPILER)
|
| 709 |
+
|
| 710 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 711 |
+
|
| 712 |
+
template<>
|
| 713 |
+
class barrier<thread_scope_thread, _CUDA_VSTD::__empty_completion> : private barrier<thread_scope_block> {
|
| 714 |
+
using __base = barrier<thread_scope_block>;
|
| 715 |
+
|
| 716 |
+
public:
|
| 717 |
+
using __base::__base;
|
| 718 |
+
|
| 719 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 720 |
+
friend void init(barrier * __b, _CUDA_VSTD::ptrdiff_t __expected, _CUDA_VSTD::__empty_completion __completion = _CUDA_VSTD::__empty_completion()) {
|
| 721 |
+
init(static_cast<__base *>(__b), __expected, __completion);
|
| 722 |
+
}
|
| 723 |
+
|
| 724 |
+
using __base::arrive;
|
| 725 |
+
using __base::wait;
|
| 726 |
+
using __base::arrive_and_wait;
|
| 727 |
+
using __base::arrive_and_drop;
|
| 728 |
+
using __base::max;
|
| 729 |
+
};
|
| 730 |
+
|
| 731 |
+
template <typename ... _Ty>
|
| 732 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr bool __unused(_Ty...) {return true;}
|
| 733 |
+
|
| 734 |
+
template <typename _Ty>
|
| 735 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr bool __unused(_Ty&) {return true;}
|
| 736 |
+
|
| 737 |
+
// __is_local_smem_barrier returns true if barrier is (1) block-scoped and (2) located in shared memory.
|
| 738 |
+
template<thread_scope _Sco, typename _CompF, bool _Is_mbarrier = (_Sco == thread_scope_block) && _CUDA_VSTD::is_same<_CompF, _CUDA_VSTD::__empty_completion>::value>
|
| 739 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 740 |
+
bool __is_local_smem_barrier(barrier<_Sco, _CompF> & __barrier) {
|
| 741 |
+
NV_IF_ELSE_TARGET(
|
| 742 |
+
NV_IS_DEVICE, (
|
| 743 |
+
return _Is_mbarrier && __isShared(&__barrier);
|
| 744 |
+
),(
|
| 745 |
+
return false;
|
| 746 |
+
)
|
| 747 |
+
);
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
// __try_get_barrier_handle returns barrier handle of block-scoped barriers and a nullptr otherwise.
|
| 751 |
+
template<thread_scope _Sco, typename _CompF>
|
| 752 |
+
_LIBCUDACXX_INLINE_VISIBILITY inline
|
| 753 |
+
_CUDA_VSTD::uint64_t * __try_get_barrier_handle(barrier<_Sco, _CompF> & __barrier) {
|
| 754 |
+
return nullptr;
|
| 755 |
+
}
|
| 756 |
+
|
| 757 |
+
template<>
|
| 758 |
+
_LIBCUDACXX_INLINE_VISIBILITY inline
|
| 759 |
+
_CUDA_VSTD::uint64_t * __try_get_barrier_handle<::cuda::thread_scope_block, _CUDA_VSTD::__empty_completion>(barrier<::cuda::thread_scope_block> & __barrier) {
|
| 760 |
+
NV_DISPATCH_TARGET(
|
| 761 |
+
NV_IS_DEVICE, (
|
| 762 |
+
return ::cuda::device::barrier_native_handle(__barrier);
|
| 763 |
+
),
|
| 764 |
+
NV_ANY_TARGET, (
|
| 765 |
+
return nullptr;
|
| 766 |
+
)
|
| 767 |
+
);
|
| 768 |
+
}
|
| 769 |
+
|
| 770 |
+
// This struct contains functions to defer the completion of a barrier phase
|
| 771 |
+
// or pipeline stage until a specific memcpy_async operation *initiated by
|
| 772 |
+
// this thread* has completed.
|
| 773 |
+
|
| 774 |
+
// The user is still responsible for arriving and waiting on (or otherwise
|
| 775 |
+
// synchronizing with) the barrier or pipeline barrier to see the results of
|
| 776 |
+
// copies from other threads participating in the synchronization object.
|
| 777 |
+
struct __memcpy_completion_impl {
|
| 778 |
+
|
| 779 |
+
template<typename _Group>
|
| 780 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY static
|
| 781 |
+
async_contract_fulfillment __defer(
|
| 782 |
+
__completion_mechanism __cm, _Group const & __group, _CUDA_VSTD::size_t __size, barrier<::cuda::thread_scope_block> & __barrier) {
|
| 783 |
+
// In principle, this is the overload for shared memory barriers. However, a
|
| 784 |
+
// block-scope barrier may also be located in global memory. Therefore, we
|
| 785 |
+
// check if the barrier is a non-smem barrier and handle that separately.
|
| 786 |
+
if (! __is_local_smem_barrier(__barrier)) {
|
| 787 |
+
return __defer_non_smem_barrier(__cm, __group, __size, __barrier);
|
| 788 |
+
}
|
| 789 |
+
|
| 790 |
+
switch (__cm) {
|
| 791 |
+
case __completion_mechanism::__async_group:
|
| 792 |
+
// Pre-SM80, the async_group mechanism is not available.
|
| 793 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80, (
|
| 794 |
+
// Non-Blocking: unbalance barrier by 1, barrier will be
|
| 795 |
+
// rebalanced when all thread-local cp.async instructions
|
| 796 |
+
// have completed writing to shared memory.
|
| 797 |
+
_CUDA_VSTD::uint64_t * __bh = __try_get_barrier_handle(__barrier);
|
| 798 |
+
|
| 799 |
+
asm volatile ("cp.async.mbarrier.arrive.shared.b64 [%0];"
|
| 800 |
+
:: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__bh)))
|
| 801 |
+
: "memory");
|
| 802 |
+
));
|
| 803 |
+
return async_contract_fulfillment::async;
|
| 804 |
+
case __completion_mechanism::__async_bulk_group:
|
| 805 |
+
// This completion mechanism should not be used with a shared
|
| 806 |
+
// memory barrier. Or at least, we do not currently envision
|
| 807 |
+
// bulk group to be used with shared memory barriers.
|
| 808 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 809 |
+
case __completion_mechanism::__mbarrier_complete_tx:
|
| 810 |
+
#if __cccl_ptx_isa >= 800
|
| 811 |
+
// Pre-sm90, the mbarrier_complete_tx completion mechanism is not available.
|
| 812 |
+
NV_IF_TARGET(NV_PROVIDES_SM_90, (
|
| 813 |
+
// Only perform the expect_tx operation with the leader thread
|
| 814 |
+
if (__group.thread_rank() == 0) {
|
| 815 |
+
::cuda::device::barrier_expect_tx(__barrier, __size);
|
| 816 |
+
}
|
| 817 |
+
));
|
| 818 |
+
#endif // __cccl_ptx_isa >= 800
|
| 819 |
+
return async_contract_fulfillment::async;
|
| 820 |
+
case __completion_mechanism::__sync:
|
| 821 |
+
// sync: In this case, we do not need to do anything. The user will have
|
| 822 |
+
// to issue `bar.arrive_wait();` to see the effect of the transaction.
|
| 823 |
+
return async_contract_fulfillment::none;
|
| 824 |
+
default:
|
| 825 |
+
// Get rid of "control reaches end of non-void function":
|
| 826 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 827 |
+
}
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
template<typename _Group, thread_scope _Sco, typename _CompF>
|
| 831 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY static
|
| 832 |
+
async_contract_fulfillment __defer(
|
| 833 |
+
__completion_mechanism __cm, _Group const & __group, _CUDA_VSTD::size_t __size, barrier<_Sco, _CompF> & __barrier) {
|
| 834 |
+
return __defer_non_smem_barrier(__cm, __group, __size, __barrier);
|
| 835 |
+
}
|
| 836 |
+
|
| 837 |
+
template<typename _Group, thread_scope _Sco, typename _CompF>
|
| 838 |
+
_LIBCUDACXX_INLINE_VISIBILITY static
|
| 839 |
+
async_contract_fulfillment __defer_non_smem_barrier(
|
| 840 |
+
__completion_mechanism __cm, _Group const & __group, _CUDA_VSTD::size_t __size, barrier<_Sco, _CompF> & __barrier) {
|
| 841 |
+
// Overload for non-smem barriers.
|
| 842 |
+
|
| 843 |
+
switch (__cm) {
|
| 844 |
+
case __completion_mechanism::__async_group:
|
| 845 |
+
// Pre-SM80, the async_group mechanism is not available.
|
| 846 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80, (
|
| 847 |
+
// Blocking: wait for all thread-local cp.async instructions to have
|
| 848 |
+
// completed writing to shared memory.
|
| 849 |
+
asm volatile ("cp.async.wait_all;" ::: "memory");
|
| 850 |
+
));
|
| 851 |
+
return async_contract_fulfillment::async;
|
| 852 |
+
case __completion_mechanism::__mbarrier_complete_tx:
|
| 853 |
+
// Non-smem barriers do not have an mbarrier_complete_tx mechanism..
|
| 854 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 855 |
+
case __completion_mechanism::__async_bulk_group:
|
| 856 |
+
// This completion mechanism is currently not expected to be used with barriers.
|
| 857 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 858 |
+
case __completion_mechanism::__sync:
|
| 859 |
+
// sync: In this case, we do not need to do anything.
|
| 860 |
+
return async_contract_fulfillment::none;
|
| 861 |
+
default:
|
| 862 |
+
// Get rid of "control reaches end of non-void function":
|
| 863 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 864 |
+
}
|
| 865 |
+
}
|
| 866 |
+
|
| 867 |
+
template<typename _Group, thread_scope _Sco>
|
| 868 |
+
_LIBCUDACXX_INLINE_VISIBILITY static
|
| 869 |
+
async_contract_fulfillment __defer(__completion_mechanism __cm, _Group const & __group, _CUDA_VSTD::size_t __size, pipeline<_Sco> & __pipeline) {
|
| 870 |
+
// pipeline does not sync on memcpy_async, defeat pipeline purpose otherwise
|
| 871 |
+
__unused(__pipeline);
|
| 872 |
+
__unused(__size);
|
| 873 |
+
__unused(__group);
|
| 874 |
+
|
| 875 |
+
switch (__cm) {
|
| 876 |
+
case __completion_mechanism::__async_group: return async_contract_fulfillment::async;
|
| 877 |
+
case __completion_mechanism::__async_bulk_group: return async_contract_fulfillment::async;
|
| 878 |
+
case __completion_mechanism::__mbarrier_complete_tx: return async_contract_fulfillment::async;
|
| 879 |
+
case __completion_mechanism::__sync: return async_contract_fulfillment::none;
|
| 880 |
+
default:
|
| 881 |
+
// Get rid of "control reaches end of non-void function":
|
| 882 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 883 |
+
}
|
| 884 |
+
}
|
| 885 |
+
};
|
| 886 |
+
|
| 887 |
+
/***********************************************************************
|
| 888 |
+
* memcpy_async code:
|
| 889 |
+
*
|
| 890 |
+
* A call to cuda::memcpy_async(dest, src, size, barrier) can dispatch to any of
|
| 891 |
+
* these PTX instructions:
|
| 892 |
+
*
|
| 893 |
+
* 1. normal synchronous copy (fallback)
|
| 894 |
+
* 2. cp.async: shared <- global
|
| 895 |
+
* 3. cp.async.bulk: shared <- global
|
| 896 |
+
* 4. TODO: cp.async.bulk: global <- shared
|
| 897 |
+
* 5. TODO: cp.async.bulk: cluster <- shared
|
| 898 |
+
*
|
| 899 |
+
* Which of these options is chosen, depends on:
|
| 900 |
+
*
|
| 901 |
+
* 1. The alignment of dest, src, and size;
|
| 902 |
+
* 2. The direction of the copy
|
| 903 |
+
* 3. The current compute capability
|
| 904 |
+
* 4. The requested completion mechanism
|
| 905 |
+
*
|
| 906 |
+
* PTX has 3 asynchronous completion mechanisms:
|
| 907 |
+
*
|
| 908 |
+
* 1. Async group - local to a thread. Used by cp.async
|
| 909 |
+
* 2. Bulk async group - local to a thread. Used by cp.async.bulk (shared -> global)
|
| 910 |
+
* 3. mbarrier::complete_tx - shared memory barier. Used by cp.async.bulk (other directions)
|
| 911 |
+
*
|
| 912 |
+
* The code is organized as follows:
|
| 913 |
+
*
|
| 914 |
+
* 1. Asynchronous copy mechanisms that wrap the PTX instructions
|
| 915 |
+
*
|
| 916 |
+
* 2. Device memcpy_async implementation per copy direction (global to shared,
|
| 917 |
+
* shared to global, etc). Dispatches to fastest mechanism based on requested
|
| 918 |
+
* completion mechanism(s), pointer alignment, and architecture.
|
| 919 |
+
*
|
| 920 |
+
* 3. Host and device memcpy_async implementations. Host implementation is
|
| 921 |
+
* basically a memcpy wrapper; device implementation dispatches based on the
|
| 922 |
+
* direction of the copy.
|
| 923 |
+
*
|
| 924 |
+
* 4. __memcpy_async_barrier:
|
| 925 |
+
* a) Sets the allowed completion mechanisms based on the barrier location
|
| 926 |
+
* b) Calls the host or device memcpy_async implementation
|
| 927 |
+
* c) If necessary, synchronizes with the barrier based on the returned
|
| 928 |
+
* completion mechanism.
|
| 929 |
+
*
|
| 930 |
+
* 5. The public memcpy_async function overloads. Call into
|
| 931 |
+
* __memcpy_async_barrier.
|
| 932 |
+
*
|
| 933 |
+
***********************************************************************/
|
| 934 |
+
|
| 935 |
+
/***********************************************************************
|
| 936 |
+
* Asynchronous copy mechanisms:
|
| 937 |
+
*
|
| 938 |
+
* 1. cp.async.bulk: shared <- global
|
| 939 |
+
* 2. TODO: cp.async.bulk: cluster <- shared
|
| 940 |
+
* 3. TODO: cp.async.bulk: global <- shared
|
| 941 |
+
* 4. cp.async: shared <- global
|
| 942 |
+
* 5. normal synchronous copy (fallback)
|
| 943 |
+
***********************************************************************/
|
| 944 |
+
|
| 945 |
+
#if __cccl_ptx_isa >= 800
|
| 946 |
+
extern "C" _LIBCUDACXX_DEVICE void __cuda_ptx_cp_async_bulk_shared_global_is_not_supported_before_SM_90__();
|
| 947 |
+
template <typename _Group>
|
| 948 |
+
inline __device__
|
| 949 |
+
void __cp_async_bulk_shared_global(const _Group &__g, char * __dest, const char * __src, size_t __size, uint64_t *__bar_handle) {
|
| 950 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk
|
| 951 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 952 |
+
if (__g.thread_rank() == 0) {
|
| 953 |
+
asm volatile(
|
| 954 |
+
"cp.async.bulk.shared::cluster.global.mbarrier::complete_tx::bytes [%0], [%1], %2, [%3];\n"
|
| 955 |
+
:
|
| 956 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__dest))),
|
| 957 |
+
"l"(static_cast<_CUDA_VSTD::uint64_t>(__cvta_generic_to_global(__src))),
|
| 958 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__size)),
|
| 959 |
+
"r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__bar_handle)))
|
| 960 |
+
: "memory");
|
| 961 |
+
}
|
| 962 |
+
),(
|
| 963 |
+
__cuda_ptx_cp_async_bulk_shared_global_is_not_supported_before_SM_90__();
|
| 964 |
+
));
|
| 965 |
+
}
|
| 966 |
+
#endif // __cccl_ptx_isa >= 800
|
| 967 |
+
|
| 968 |
+
extern "C" _LIBCUDACXX_DEVICE void __cuda_ptx_cp_async_shared_global_is_not_supported_before_SM_80__();
|
| 969 |
+
template <size_t _Copy_size>
|
| 970 |
+
inline __device__
|
| 971 |
+
void __cp_async_shared_global(char * __dest, const char * __src) {
|
| 972 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async
|
| 973 |
+
|
| 974 |
+
// If `if constexpr` is not available, this function gets instantiated even
|
| 975 |
+
// if is not called. Do not static_assert in that case.
|
| 976 |
+
#if _LIBCUDACXX_STD_VER >= 17
|
| 977 |
+
static_assert(_Copy_size == 4 || _Copy_size == 8 || _Copy_size == 16, "cp.async.shared.global requires a copy size of 4, 8, or 16.");
|
| 978 |
+
#endif // _LIBCUDACXX_STD_VER >= 17
|
| 979 |
+
|
| 980 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 981 |
+
asm volatile(
|
| 982 |
+
"cp.async.ca.shared.global [%0], [%1], %2, %2;"
|
| 983 |
+
:
|
| 984 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__dest))),
|
| 985 |
+
"l"(static_cast<_CUDA_VSTD::uint64_t>(__cvta_generic_to_global(__src))),
|
| 986 |
+
"n"(_Copy_size)
|
| 987 |
+
: "memory");
|
| 988 |
+
),(
|
| 989 |
+
__cuda_ptx_cp_async_shared_global_is_not_supported_before_SM_80__();
|
| 990 |
+
));
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
template <>
|
| 994 |
+
inline __device__
|
| 995 |
+
void __cp_async_shared_global<16>(char * __dest, const char * __src) {
|
| 996 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async
|
| 997 |
+
// When copying 16 bytes, it is possible to skip L1 cache (.cg).
|
| 998 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 999 |
+
asm volatile(
|
| 1000 |
+
"cp.async.cg.shared.global [%0], [%1], %2, %2;"
|
| 1001 |
+
:
|
| 1002 |
+
: "r"(static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__dest))),
|
| 1003 |
+
"l"(static_cast<_CUDA_VSTD::uint64_t>(__cvta_generic_to_global(__src))),
|
| 1004 |
+
"n"(16)
|
| 1005 |
+
: "memory");
|
| 1006 |
+
),(
|
| 1007 |
+
__cuda_ptx_cp_async_shared_global_is_not_supported_before_SM_80__();
|
| 1008 |
+
));
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
template <size_t _Alignment, typename _Group>
|
| 1012 |
+
inline __device__
|
| 1013 |
+
void __cp_async_shared_global_mechanism(_Group __g, char * __dest, const char * __src, _CUDA_VSTD::size_t __size) {
|
| 1014 |
+
// If `if constexpr` is not available, this function gets instantiated even
|
| 1015 |
+
// if is not called. Do not static_assert in that case.
|
| 1016 |
+
#if _LIBCUDACXX_STD_VER >= 17
|
| 1017 |
+
static_assert(4 <= _Alignment, "cp.async requires at least 4-byte alignment");
|
| 1018 |
+
#endif // _LIBCUDACXX_STD_VER >= 17
|
| 1019 |
+
|
| 1020 |
+
// Maximal copy size is 16.
|
| 1021 |
+
constexpr int __copy_size = (_Alignment > 16) ? 16 : _Alignment;
|
| 1022 |
+
// We use an int offset here, because we are copying to shared memory,
|
| 1023 |
+
// which is easily addressable using int.
|
| 1024 |
+
const int __group_size = __g.size();
|
| 1025 |
+
const int __group_rank = __g.thread_rank();
|
| 1026 |
+
const int __stride = __group_size * __copy_size;
|
| 1027 |
+
for (int __offset = __group_rank * __copy_size; __offset < static_cast<int>(__size); __offset += __stride) {
|
| 1028 |
+
__cp_async_shared_global<__copy_size>(__dest + __offset, __src + __offset);
|
| 1029 |
+
}
|
| 1030 |
+
}
|
| 1031 |
+
|
| 1032 |
+
template <size_t _Copy_size>
|
| 1033 |
+
struct __copy_chunk {
|
| 1034 |
+
_ALIGNAS(_Copy_size) char data[_Copy_size];
|
| 1035 |
+
};
|
| 1036 |
+
|
| 1037 |
+
template <size_t _Alignment, typename _Group>
|
| 1038 |
+
inline __host__ __device__
|
| 1039 |
+
void __cp_async_fallback_mechanism(_Group __g, char * __dest, const char * __src, _CUDA_VSTD::size_t __size) {
|
| 1040 |
+
// Maximal copy size is 16 bytes
|
| 1041 |
+
constexpr _CUDA_VSTD::size_t __copy_size = (_Alignment > 16) ? 16 : _Alignment;
|
| 1042 |
+
using __chunk_t = __copy_chunk<__copy_size>;
|
| 1043 |
+
|
| 1044 |
+
// "Group"-strided loop over memory
|
| 1045 |
+
const size_t __stride = __g.size() * __copy_size;
|
| 1046 |
+
|
| 1047 |
+
// An unroll factor of 64 ought to be enough for anybody. This unroll pragma
|
| 1048 |
+
// is mainly intended to place an upper bound on loop unrolling. The number
|
| 1049 |
+
// is more than high enough for the intended use case: an unroll factor of
|
| 1050 |
+
// 64 allows moving 4 * 64 * 256 = 64kb in one unrolled loop with 256
|
| 1051 |
+
// threads (copying ints). On the other hand, in the unfortunate case that
|
| 1052 |
+
// we have to move 1024 bytes / thread with char width, then we prevent
|
| 1053 |
+
// fully unrolling the loop to 1024 copy instructions. This prevents the
|
| 1054 |
+
// compile times from increasing unreasonably, and also has neglibible
|
| 1055 |
+
// impact on runtime performance.
|
| 1056 |
+
_LIBCUDACXX_PRAGMA_UNROLL(64)
|
| 1057 |
+
for (_CUDA_VSTD::size_t __offset = __g.thread_rank() * __copy_size; __offset < __size; __offset += __stride) {
|
| 1058 |
+
__chunk_t tmp = *reinterpret_cast<const __chunk_t *>(__src + __offset);
|
| 1059 |
+
*reinterpret_cast<__chunk_t *>(__dest + __offset) = tmp;
|
| 1060 |
+
}
|
| 1061 |
+
}
|
| 1062 |
+
|
| 1063 |
+
/***********************************************************************
|
| 1064 |
+
* cuda::memcpy_async dispatch helper functions
|
| 1065 |
+
*
|
| 1066 |
+
* - __get_size_align struct to determine the alignment from a size type.
|
| 1067 |
+
***********************************************************************/
|
| 1068 |
+
|
| 1069 |
+
// The __get_size_align struct provides a way to query the guaranteed
|
| 1070 |
+
// "alignment" of a provided size. In this case, an n-byte aligned size means
|
| 1071 |
+
// that the size is a multiple of n.
|
| 1072 |
+
//
|
| 1073 |
+
// Use as follows:
|
| 1074 |
+
// static_assert(__get_size_align<size_t>::align == 1)
|
| 1075 |
+
// static_assert(__get_size_align<aligned_size_t<n>>::align == n)
|
| 1076 |
+
|
| 1077 |
+
// Default impl: always returns 1.
|
| 1078 |
+
template <typename, typename = void>
|
| 1079 |
+
struct __get_size_align {
|
| 1080 |
+
static constexpr int align = 1;
|
| 1081 |
+
};
|
| 1082 |
+
|
| 1083 |
+
// aligned_size_t<n> overload: return n.
|
| 1084 |
+
template <typename T>
|
| 1085 |
+
struct __get_size_align<T, _CUDA_VSTD::__void_t<decltype(T::align)>> {
|
| 1086 |
+
static constexpr int align = T::align;
|
| 1087 |
+
};
|
| 1088 |
+
|
| 1089 |
+
/***********************************************************************
|
| 1090 |
+
* cuda::memcpy_async dispatch
|
| 1091 |
+
*
|
| 1092 |
+
* The dispatch mechanism takes all the arguments and dispatches to the
|
| 1093 |
+
* fastest asynchronous copy mechanism available.
|
| 1094 |
+
*
|
| 1095 |
+
* It returns a __completion_mechanism that indicates which completion mechanism
|
| 1096 |
+
* was used by the copy mechanism. This value can be used by the sync object to
|
| 1097 |
+
* further synchronize if necessary.
|
| 1098 |
+
*
|
| 1099 |
+
***********************************************************************/
|
| 1100 |
+
|
| 1101 |
+
template<_CUDA_VSTD::size_t _Align, typename _Group>
|
| 1102 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_DEVICE inline
|
| 1103 |
+
__completion_mechanism __dispatch_memcpy_async_any_to_any(_Group const & __group, char * __dest_char, char const * __src_char, _CUDA_VSTD::size_t __size, uint32_t __allowed_completions, uint64_t* __bar_handle) {
|
| 1104 |
+
__cp_async_fallback_mechanism<_Align>(__group, __dest_char, __src_char, __size);
|
| 1105 |
+
return __completion_mechanism::__sync;
|
| 1106 |
+
}
|
| 1107 |
+
|
| 1108 |
+
template<_CUDA_VSTD::size_t _Align, typename _Group>
|
| 1109 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_DEVICE inline
|
| 1110 |
+
__completion_mechanism __dispatch_memcpy_async_global_to_shared(_Group const & __group, char * __dest_char, char const * __src_char, _CUDA_VSTD::size_t __size, uint32_t __allowed_completions, uint64_t* __bar_handle) {
|
| 1111 |
+
#if __cccl_ptx_isa >= 800
|
| 1112 |
+
NV_IF_TARGET(NV_PROVIDES_SM_90, (
|
| 1113 |
+
const bool __can_use_complete_tx = __allowed_completions & uint32_t(__completion_mechanism::__mbarrier_complete_tx);
|
| 1114 |
+
_LIBCUDACXX_DEBUG_ASSERT(__can_use_complete_tx == (nullptr != __bar_handle), "Pass non-null bar_handle if and only if can_use_complete_tx.");
|
| 1115 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (_Align >= 16) {
|
| 1116 |
+
if (__can_use_complete_tx && __isShared(__bar_handle)) {
|
| 1117 |
+
__cp_async_bulk_shared_global(__group, __dest_char, __src_char, __size, __bar_handle);
|
| 1118 |
+
return __completion_mechanism::__mbarrier_complete_tx;
|
| 1119 |
+
}
|
| 1120 |
+
}
|
| 1121 |
+
// Fallthrough to SM 80..
|
| 1122 |
+
));
|
| 1123 |
+
#endif // __cccl_ptx_isa >= 800
|
| 1124 |
+
|
| 1125 |
+
NV_IF_TARGET(NV_PROVIDES_SM_80, (
|
| 1126 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (_Align >= 4) {
|
| 1127 |
+
const bool __can_use_async_group = __allowed_completions & uint32_t(__completion_mechanism::__async_group);
|
| 1128 |
+
if (__can_use_async_group) {
|
| 1129 |
+
__cp_async_shared_global_mechanism<_Align>(__group, __dest_char, __src_char, __size);
|
| 1130 |
+
return __completion_mechanism::__async_group;
|
| 1131 |
+
}
|
| 1132 |
+
}
|
| 1133 |
+
// Fallthrough..
|
| 1134 |
+
));
|
| 1135 |
+
|
| 1136 |
+
__cp_async_fallback_mechanism<_Align>(__group, __dest_char, __src_char, __size);
|
| 1137 |
+
return __completion_mechanism::__sync;
|
| 1138 |
+
}
|
| 1139 |
+
|
| 1140 |
+
// __dispatch_memcpy_async is the internal entry point for dispatching to the correct memcpy_async implementation.
|
| 1141 |
+
template<_CUDA_VSTD::size_t _Align, typename _Group>
|
| 1142 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 1143 |
+
__completion_mechanism __dispatch_memcpy_async(_Group const & __group, char * __dest_char, char const * __src_char, size_t __size, _CUDA_VSTD::uint32_t __allowed_completions, uint64_t* __bar_handle) {
|
| 1144 |
+
NV_IF_ELSE_TARGET(NV_IS_DEVICE, (
|
| 1145 |
+
// Dispatch based on direction of the copy: global to shared, shared to
|
| 1146 |
+
// global, etc.
|
| 1147 |
+
|
| 1148 |
+
// CUDA compilers <= 12.2 may not propagate assumptions about the state space
|
| 1149 |
+
// of pointers correctly. Therefore, we
|
| 1150 |
+
// 1) put the code for each copy direction in a separate function, and
|
| 1151 |
+
// 2) make sure none of the code paths can reach each other by "falling through".
|
| 1152 |
+
//
|
| 1153 |
+
// See nvbug 4074679 and also PR #478.
|
| 1154 |
+
if (__isGlobal(__src_char) && __isShared(__dest_char)) {
|
| 1155 |
+
return __dispatch_memcpy_async_global_to_shared<_Align>(__group, __dest_char, __src_char, __size, __allowed_completions, __bar_handle);
|
| 1156 |
+
} else {
|
| 1157 |
+
return __dispatch_memcpy_async_any_to_any<_Align>(__group, __dest_char, __src_char, __size, __allowed_completions, __bar_handle);
|
| 1158 |
+
}
|
| 1159 |
+
), (
|
| 1160 |
+
// Host code path:
|
| 1161 |
+
if (__group.thread_rank() == 0) {
|
| 1162 |
+
memcpy(__dest_char, __src_char, __size);
|
| 1163 |
+
}
|
| 1164 |
+
return __completion_mechanism::__sync;
|
| 1165 |
+
));
|
| 1166 |
+
}
|
| 1167 |
+
|
| 1168 |
+
template<_CUDA_VSTD::size_t _Align, typename _Group>
|
| 1169 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 1170 |
+
__completion_mechanism __dispatch_memcpy_async(_Group const & __group, char * __dest_char, char const * __src_char, _CUDA_VSTD::size_t __size, _CUDA_VSTD::uint32_t __allowed_completions) {
|
| 1171 |
+
_LIBCUDACXX_DEBUG_ASSERT(! (__allowed_completions & uint32_t(__completion_mechanism::__mbarrier_complete_tx)), "Cannot allow mbarrier_complete_tx completion mechanism when not passing a barrier. ");
|
| 1172 |
+
return __dispatch_memcpy_async<_Align>(__group, __dest_char, __src_char, __size, __allowed_completions, nullptr);
|
| 1173 |
+
}
|
| 1174 |
+
|
| 1175 |
+
////////////////////////////////////////////////////////////////////////////////
|
| 1176 |
+
|
| 1177 |
+
struct __single_thread_group {
|
| 1178 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1179 |
+
void sync() const {}
|
| 1180 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1181 |
+
constexpr _CUDA_VSTD::size_t size() const { return 1; };
|
| 1182 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1183 |
+
constexpr _CUDA_VSTD::size_t thread_rank() const { return 0; };
|
| 1184 |
+
};
|
| 1185 |
+
|
| 1186 |
+
template<typename _Group, class _Tp, typename _Size, thread_scope _Sco, typename _CompF>
|
| 1187 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1188 |
+
async_contract_fulfillment __memcpy_async_barrier(_Group const & __group, _Tp * __destination, _Tp const * __source, _Size __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1189 |
+
static_assert(_CUDA_VSTD::is_trivially_copyable<_Tp>::value, "memcpy_async requires a trivially copyable type");
|
| 1190 |
+
|
| 1191 |
+
// 1. Determine which completion mechanisms can be used with the current
|
| 1192 |
+
// barrier. A local shared memory barrier, i.e., block-scope barrier in local
|
| 1193 |
+
// shared memory, supports the mbarrier_complete_tx mechanism in addition to
|
| 1194 |
+
// the async group mechanism.
|
| 1195 |
+
_CUDA_VSTD::uint32_t __allowed_completions = __is_local_smem_barrier(__barrier)
|
| 1196 |
+
? ( _CUDA_VSTD::uint32_t(__completion_mechanism::__async_group) | _CUDA_VSTD::uint32_t(__completion_mechanism::__mbarrier_complete_tx))
|
| 1197 |
+
: _CUDA_VSTD::uint32_t(__completion_mechanism::__async_group);
|
| 1198 |
+
|
| 1199 |
+
// Alignment: Use the maximum of the alignment of _Tp and that of a possible cuda::aligned_size_t.
|
| 1200 |
+
constexpr _CUDA_VSTD::size_t __size_align = __get_size_align<_Size>::align;
|
| 1201 |
+
constexpr _CUDA_VSTD::size_t __align = (alignof(_Tp) < __size_align) ? __size_align : alignof(_Tp);
|
| 1202 |
+
// Cast to char pointers. We don't need the type for alignment anymore and
|
| 1203 |
+
// erasing the types reduces the number of instantiations of down-stream
|
| 1204 |
+
// functions.
|
| 1205 |
+
char * __dest_char = reinterpret_cast<char*>(__destination);
|
| 1206 |
+
char const * __src_char = reinterpret_cast<char const *>(__source);
|
| 1207 |
+
|
| 1208 |
+
// 2. Issue actual copy instructions.
|
| 1209 |
+
auto __bh = __try_get_barrier_handle(__barrier);
|
| 1210 |
+
auto __cm = __dispatch_memcpy_async<__align>(__group, __dest_char, __src_char, __size, __allowed_completions, __bh);
|
| 1211 |
+
|
| 1212 |
+
// 3. Synchronize barrier with copy instructions.
|
| 1213 |
+
return __memcpy_completion_impl::__defer(__cm, __group, __size, __barrier);
|
| 1214 |
+
}
|
| 1215 |
+
|
| 1216 |
+
template<typename _Group, class _Tp, _CUDA_VSTD::size_t _Alignment, thread_scope _Sco, typename _CompF>
|
| 1217 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1218 |
+
async_contract_fulfillment memcpy_async(_Group const & __group, _Tp * __destination, _Tp const * __source, aligned_size_t<_Alignment> __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1219 |
+
return __memcpy_async_barrier(__group, __destination, __source, __size, __barrier);
|
| 1220 |
+
}
|
| 1221 |
+
|
| 1222 |
+
template<class _Tp, typename _Size, thread_scope _Sco, typename _CompF>
|
| 1223 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1224 |
+
async_contract_fulfillment memcpy_async(_Tp * __destination, _Tp const * __source, _Size __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1225 |
+
return __memcpy_async_barrier(__single_thread_group{}, __destination, __source, __size, __barrier);
|
| 1226 |
+
}
|
| 1227 |
+
|
| 1228 |
+
template<typename _Group, class _Tp, thread_scope _Sco, typename _CompF>
|
| 1229 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1230 |
+
async_contract_fulfillment memcpy_async(_Group const & __group, _Tp * __destination, _Tp const * __source, _CUDA_VSTD::size_t __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1231 |
+
|
| 1232 |
+
return __memcpy_async_barrier(__group, __destination, __source, __size, __barrier);
|
| 1233 |
+
}
|
| 1234 |
+
|
| 1235 |
+
template<typename _Group, thread_scope _Sco, typename _CompF>
|
| 1236 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1237 |
+
async_contract_fulfillment memcpy_async(_Group const & __group, void * __destination, void const * __source, _CUDA_VSTD::size_t __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1238 |
+
return __memcpy_async_barrier(__group, reinterpret_cast<char *>(__destination), reinterpret_cast<char const *>(__source), __size, __barrier);
|
| 1239 |
+
}
|
| 1240 |
+
|
| 1241 |
+
template<typename _Group, _CUDA_VSTD::size_t _Alignment, thread_scope _Sco, typename _CompF>
|
| 1242 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1243 |
+
async_contract_fulfillment memcpy_async(_Group const & __group, void * __destination, void const * __source, aligned_size_t<_Alignment> __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1244 |
+
return __memcpy_async_barrier(__group, reinterpret_cast<char *>(__destination), reinterpret_cast<char const *>(__source), __size, __barrier);
|
| 1245 |
+
}
|
| 1246 |
+
|
| 1247 |
+
template<typename _Size, thread_scope _Sco, typename _CompF>
|
| 1248 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 1249 |
+
async_contract_fulfillment memcpy_async(void * __destination, void const * __source, _Size __size, barrier<_Sco, _CompF> & __barrier) {
|
| 1250 |
+
return __memcpy_async_barrier(__single_thread_group{}, reinterpret_cast<char *>(__destination), reinterpret_cast<char const *>(__source), __size, __barrier);
|
| 1251 |
+
}
|
| 1252 |
+
|
| 1253 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 1254 |
+
|
| 1255 |
+
#endif // _CCCL_CUDA_COMPILER
|
| 1256 |
+
|
| 1257 |
+
#endif // _LIBCUDACXX___CUDA_BARRIER_H
|
cuda_toolkit/include/__cuda/chrono.h
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_CHRONO_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_CHRONO_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/chrono> should only be included in from <cuda/std/chrono>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#include <nv/target>
|
| 19 |
+
|
| 20 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 21 |
+
# pragma GCC system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 23 |
+
# pragma clang system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 25 |
+
# pragma system_header
|
| 26 |
+
#endif // no system header
|
| 27 |
+
|
| 28 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 29 |
+
|
| 30 |
+
namespace chrono {
|
| 31 |
+
|
| 32 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 33 |
+
system_clock::time_point system_clock::now() noexcept
|
| 34 |
+
{
|
| 35 |
+
NV_DISPATCH_TARGET(
|
| 36 |
+
NV_IS_DEVICE, (
|
| 37 |
+
uint64_t __time;
|
| 38 |
+
asm volatile("mov.u64 %0, %%globaltimer;":"=l"(__time)::);
|
| 39 |
+
return time_point(duration_cast<duration>(nanoseconds(__time)));
|
| 40 |
+
),
|
| 41 |
+
NV_IS_HOST, (
|
| 42 |
+
return time_point(duration_cast<duration>(nanoseconds(
|
| 43 |
+
::std::chrono::duration_cast<::std::chrono::nanoseconds>(
|
| 44 |
+
::std::chrono::system_clock::now().time_since_epoch()
|
| 45 |
+
).count()
|
| 46 |
+
)));
|
| 47 |
+
));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 51 |
+
time_t system_clock::to_time_t(const system_clock::time_point& __t) noexcept
|
| 52 |
+
{
|
| 53 |
+
return time_t(duration_cast<seconds>(__t.time_since_epoch()).count());
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 57 |
+
system_clock::time_point system_clock::from_time_t(time_t __t) noexcept
|
| 58 |
+
{
|
| 59 |
+
return time_point(seconds(__t));;
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 64 |
+
|
| 65 |
+
#endif // _LIBCUDACXX___CUDA_CHRONO_H
|
cuda_toolkit/include/__cuda/climits_prelude.h
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_CLIMITS_PRELUDE_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_CLIMITS_PRELUDE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/climits_prelude> should only be included in from <cuda/std/climits>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#ifndef _LIBCUDACXX_COMPILER_NVRTC
|
| 19 |
+
#include <climits>
|
| 20 |
+
#include <limits.h>
|
| 21 |
+
#include <cstdint>
|
| 22 |
+
#else // ^^^ !_LIBCUDACXX_COMPILER_NVRTC ^^^ / vvv _LIBCUDACXX_COMPILER_NVRTC vvv
|
| 23 |
+
#define CHAR_BIT 8
|
| 24 |
+
|
| 25 |
+
#define SCHAR_MIN (-128)
|
| 26 |
+
#define SCHAR_MAX 127
|
| 27 |
+
#define UCHAR_MAX 255
|
| 28 |
+
#define __CHAR_UNSIGNED__ ('\xff' > 0) // CURSED
|
| 29 |
+
#if __CHAR_UNSIGNED__
|
| 30 |
+
#define CHAR_MIN 0
|
| 31 |
+
#define CHAR_MAX UCHAR_MAX
|
| 32 |
+
#else
|
| 33 |
+
#define CHAR_MIN SCHAR_MIN
|
| 34 |
+
#define CHAR_MAX SCHAR_MAX
|
| 35 |
+
#endif
|
| 36 |
+
#define SHRT_MIN (-SHRT_MAX - 1)
|
| 37 |
+
#define SHRT_MAX 0x7fff
|
| 38 |
+
#define USHRT_MAX 0xffff
|
| 39 |
+
#define INT_MIN (-INT_MAX - 1)
|
| 40 |
+
#define INT_MAX 0x7fffffff
|
| 41 |
+
#define UINT_MAX 0xffffffff
|
| 42 |
+
#define LONG_MIN (-LONG_MAX - 1)
|
| 43 |
+
#ifdef __LP64__
|
| 44 |
+
#define LONG_MAX LLONG_MAX
|
| 45 |
+
#define ULONG_MAX ULLONG_MAX
|
| 46 |
+
#else
|
| 47 |
+
#define LONG_MAX INT_MAX
|
| 48 |
+
#define ULONG_MAX UINT_MAX
|
| 49 |
+
#endif
|
| 50 |
+
#define LLONG_MIN (-LLONG_MAX - 1)
|
| 51 |
+
#define LLONG_MAX 0x7fffffffffffffffLL
|
| 52 |
+
#define ULLONG_MAX 0xffffffffffffffffUL
|
| 53 |
+
|
| 54 |
+
#define __FLT_RADIX__ 2
|
| 55 |
+
#define __FLT_MANT_DIG__ 24
|
| 56 |
+
#define __FLT_DIG__ 6
|
| 57 |
+
#define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F
|
| 58 |
+
#define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F
|
| 59 |
+
#define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F
|
| 60 |
+
#define __FLT_MIN_EXP__ (-125)
|
| 61 |
+
#define __FLT_MIN_10_EXP__ (-37)
|
| 62 |
+
#define __FLT_MAX_EXP__ 128
|
| 63 |
+
#define __FLT_MAX_10_EXP__ 38
|
| 64 |
+
#define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F
|
| 65 |
+
#define __DBL_MANT_DIG__ 53
|
| 66 |
+
#define __DBL_DIG__ 15
|
| 67 |
+
#define __DBL_MIN__ 2.22507385850720138309023271733240406e-308
|
| 68 |
+
#define __DBL_MAX__ 1.79769313486231570814527423731704357e+308
|
| 69 |
+
#define __DBL_EPSILON__ 2.22044604925031308084726333618164062e-16
|
| 70 |
+
#define __DBL_MIN_EXP__ (-1021)
|
| 71 |
+
#define __DBL_MIN_10_EXP__ (-307)
|
| 72 |
+
#define __DBL_MAX_EXP__ 1024
|
| 73 |
+
#define __DBL_MAX_10_EXP__ 308
|
| 74 |
+
#define __DBL_DENORM_MIN__ 4.94065645841246544176568792868221372e-324
|
| 75 |
+
|
| 76 |
+
template<typename _To, typename _From>
|
| 77 |
+
static _LIBCUDACXX_DEVICE _LIBCUDACXX_FORCE_INLINE
|
| 78 |
+
_To __cowchild_cast(_From __from)
|
| 79 |
+
{
|
| 80 |
+
static_assert(sizeof(_From) == sizeof(_To), "");
|
| 81 |
+
union __cast { _From __from; _To __to; };
|
| 82 |
+
__cast __c;
|
| 83 |
+
__c.__from = __from;
|
| 84 |
+
return __c.__to;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
#define __builtin_huge_valf() __cowchild_cast<float>(0x7f800000)
|
| 88 |
+
#define __builtin_nanf(__dummy) __cowchild_cast<float>(0x7fc00000)
|
| 89 |
+
#define __builtin_nansf(__dummy) __cowchild_cast<float>(0x7fa00000)
|
| 90 |
+
#define __builtin_huge_val() __cowchild_cast<double>(0x7ff0000000000000)
|
| 91 |
+
#define __builtin_nan(__dummy) __cowchild_cast<double>(0x7ff8000000000000)
|
| 92 |
+
#define __builtin_nans(__dummy) __cowchild_cast<double>(0x7ff4000000000000)
|
| 93 |
+
#endif // _LIBCUDACXX_COMPILER_NVRTC
|
| 94 |
+
|
| 95 |
+
#endif // _LIBCUDACXX___CUDA_CLIMITS_PRELUDE_H
|
cuda_toolkit/include/__cuda/cstddef_prelude.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_CSTDDEF_PRELUDE_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_CSTDDEF_PRELUDE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/cstddef_prelude> should only be included in from <cuda/std/cstddef>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#ifndef _LIBCUDACXX_COMPILER_NVRTC
|
| 19 |
+
#include <cstddef>
|
| 20 |
+
#include <stddef.h>
|
| 21 |
+
#else
|
| 22 |
+
#define offsetof(type, member) (_CUDA_VSTD::size_t)((char*)&(((type *)0)->member) - (char*)0)
|
| 23 |
+
#endif // _LIBCUDACXX_COMPILER_NVRTC
|
| 24 |
+
|
| 25 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 26 |
+
|
| 27 |
+
typedef decltype(nullptr) nullptr_t;
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
#endif // _LIBCUDACXX___CUDA_CSTDDEF_PRELUDE_H
|
cuda_toolkit/include/__cuda/cstdint_prelude.h
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_CSTDINT_PRELUDE_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_CSTDINT_PRELUDE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/cstdint_prelude> should only be included in from <cuda/std/cstdint>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#ifndef _LIBCUDACXX_COMPILER_NVRTC
|
| 19 |
+
#include <cstdint>
|
| 20 |
+
#else // ^^^ !_LIBCUDACXX_COMPILER_NVRTC ^^^ / vvv _LIBCUDACXX_COMPILER_NVRTC vvv
|
| 21 |
+
typedef signed char int8_t;
|
| 22 |
+
typedef unsigned char uint8_t;
|
| 23 |
+
typedef signed short int16_t;
|
| 24 |
+
typedef unsigned short uint16_t;
|
| 25 |
+
typedef signed int int32_t;
|
| 26 |
+
typedef unsigned int uint32_t;
|
| 27 |
+
typedef signed long long int64_t;
|
| 28 |
+
typedef unsigned long long uint64_t;
|
| 29 |
+
|
| 30 |
+
#define _LIBCUDACXX_ADDITIONAL_INTS(N) \
|
| 31 |
+
typedef int##N##_t int_fast##N##_t; \
|
| 32 |
+
typedef uint##N##_t uint_fast##N##_t; \
|
| 33 |
+
typedef int##N##_t int_least##N##_t; \
|
| 34 |
+
typedef uint##N##_t uint_least##N##_t
|
| 35 |
+
|
| 36 |
+
_LIBCUDACXX_ADDITIONAL_INTS(8);
|
| 37 |
+
_LIBCUDACXX_ADDITIONAL_INTS(16);
|
| 38 |
+
_LIBCUDACXX_ADDITIONAL_INTS(32);
|
| 39 |
+
_LIBCUDACXX_ADDITIONAL_INTS(64);
|
| 40 |
+
#undef _LIBCUDACXX_ADDITIONAL_INTS
|
| 41 |
+
|
| 42 |
+
typedef int64_t intptr_t;
|
| 43 |
+
typedef uint64_t uintptr_t;
|
| 44 |
+
typedef int64_t intmax_t;
|
| 45 |
+
typedef uint64_t uintmax_t;
|
| 46 |
+
|
| 47 |
+
#define INT8_MIN SCHAR_MIN
|
| 48 |
+
#define INT16_MIN SHRT_MIN
|
| 49 |
+
#define INT32_MIN INT_MIN
|
| 50 |
+
#define INT64_MIN LLONG_MIN
|
| 51 |
+
#define INT8_MAX SCHAR_MAX
|
| 52 |
+
#define INT16_MAX SHRT_MAX
|
| 53 |
+
#define INT32_MAX INT_MAX
|
| 54 |
+
#define INT64_MAX LLONG_MAX
|
| 55 |
+
#define UINT8_MAX UCHAR_MAX
|
| 56 |
+
#define UINT16_MAX USHRT_MAX
|
| 57 |
+
#define UINT32_MAX UINT_MAX
|
| 58 |
+
#define UINT64_MAX ULLONG_MAX
|
| 59 |
+
#define INT_FAST8_MIN SCHAR_MIN
|
| 60 |
+
#define INT_FAST16_MIN SHRT_MIN
|
| 61 |
+
#define INT_FAST32_MIN INT_MIN
|
| 62 |
+
#define INT_FAST64_MIN LLONG_MIN
|
| 63 |
+
#define INT_FAST8_MAX SCHAR_MAX
|
| 64 |
+
#define INT_FAST16_MAX SHRT_MAX
|
| 65 |
+
#define INT_FAST32_MAX INT_MAX
|
| 66 |
+
#define INT_FAST64_MAX LLONG_MAX
|
| 67 |
+
#define UINT_FAST8_MAX UCHAR_MAX
|
| 68 |
+
#define UINT_FAST16_MAX USHRT_MAX
|
| 69 |
+
#define UINT_FAST32_MAX UINT_MAX
|
| 70 |
+
#define UINT_FAST64_MAX ULLONG_MAX
|
| 71 |
+
|
| 72 |
+
#define INT8_C(X) ((int_least8_t)(X))
|
| 73 |
+
#define INT16_C(X) ((int_least16_t)(X))
|
| 74 |
+
#define INT32_C(X) ((int_least32_t)(X))
|
| 75 |
+
#define INT64_C(X) ((int_least64_t)(X))
|
| 76 |
+
#define UINT8_C(X) ((uint_least8_t)(X))
|
| 77 |
+
#define UINT16_C(X) ((uint_least16_t)(X))
|
| 78 |
+
#define UINT32_C(X) ((uint_least32_t)(X))
|
| 79 |
+
#define UINT64_C(X) ((uint_least64_t)(X))
|
| 80 |
+
#define INTMAX_C(X) ((intmax_t)(X))
|
| 81 |
+
#define UINTMAX_C(X) ((uintmax_t)(X))
|
| 82 |
+
#endif // _LIBCUDACXX_COMPILER_NVRTC
|
| 83 |
+
|
| 84 |
+
#endif // _LIBCUDACXX___CUDA_CSTDINT_PRELUDE_H
|
cuda_toolkit/include/__cuda/latch.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_LATCH_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_LATCH_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/latch> should only be included in from <cuda/std/latch>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 19 |
+
|
| 20 |
+
template<thread_scope _Sco>
|
| 21 |
+
class latch : public _CUDA_VSTD::__latch_base<_Sco> {
|
| 22 |
+
public:
|
| 23 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 24 |
+
latch(_CUDA_VSTD::ptrdiff_t __count)
|
| 25 |
+
: _CUDA_VSTD::__latch_base<_Sco>(__count) {
|
| 26 |
+
}
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 30 |
+
|
| 31 |
+
#endif // _LIBCUDACXX___CUDA_LATCH_H
|
cuda_toolkit/include/__cuda/ptx.h
ADDED
|
@@ -0,0 +1,1373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 5 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 6 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 7 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 8 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 9 |
+
//
|
| 10 |
+
//===----------------------------------------------------------------------===//
|
| 11 |
+
|
| 12 |
+
#ifndef _LIBCUDACXX___CUDA_PTX_H
|
| 13 |
+
#define _LIBCUDACXX___CUDA_PTX_H
|
| 14 |
+
|
| 15 |
+
#ifndef __cuda_std__
|
| 16 |
+
#error "<__cuda/ptx.h> should only be included in from <cuda/std/barrier>"
|
| 17 |
+
#endif // __cuda_std__
|
| 18 |
+
|
| 19 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 20 |
+
# pragma GCC system_header
|
| 21 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 22 |
+
# pragma clang system_header
|
| 23 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 24 |
+
# pragma system_header
|
| 25 |
+
#endif // no system header
|
| 26 |
+
|
| 27 |
+
#include <nv/target> // __CUDA_MINIMUM_ARCH__ and friends
|
| 28 |
+
|
| 29 |
+
#include "../__cuda/ptx/ptx_dot_variants.h"
|
| 30 |
+
#include "../__cuda/ptx/ptx_helper_functions.h"
|
| 31 |
+
#include "../__cuda/ptx/parallel_synchronization_and_communication_instructions_mbarrier.h"
|
| 32 |
+
#include "../cstdint" // uint32_t
|
| 33 |
+
/*
|
| 34 |
+
* The cuda::ptx namespace intends to provide PTX wrappers for new hardware
|
| 35 |
+
* features and new PTX instructions so that they can be experimented with
|
| 36 |
+
* before higher-level C++ APIs are designed and developed.
|
| 37 |
+
*
|
| 38 |
+
* The wrappers have the following responsibilities:
|
| 39 |
+
*
|
| 40 |
+
* - They must prevent any PTX assembler errors, that is:
|
| 41 |
+
* - They are defined only for versions of the CUDA Toolkit in which nvcc/ptxas
|
| 42 |
+
* actually recognizes the instruction.
|
| 43 |
+
* - Sizes and types of parameters are correct.
|
| 44 |
+
* - They must convert state spaces correctly.
|
| 45 |
+
* - They adhere to the libcu++ coding standards of using:
|
| 46 |
+
* - Reserved identifiers for all parameters, variables. E.g. `__meow` or `_Woof`
|
| 47 |
+
* - _CUDA_VSTD:: namespace for types
|
| 48 |
+
*
|
| 49 |
+
* The wrappers should not do the following:
|
| 50 |
+
*
|
| 51 |
+
* - Use any non-native types. For example, an mbarrier instruction wrapper
|
| 52 |
+
* takes the barrier address as a uint64_t pointer.
|
| 53 |
+
*
|
| 54 |
+
* This header is intended for:
|
| 55 |
+
*
|
| 56 |
+
* - internal consumption by higher-level APIs such as cuda::barrier,
|
| 57 |
+
* - outside developers who want to experiment with the latest features of the
|
| 58 |
+
* hardware.
|
| 59 |
+
*
|
| 60 |
+
* Stability:
|
| 61 |
+
*
|
| 62 |
+
* - These headers are intended to present a stable API (not ABI) within one
|
| 63 |
+
* major version of the CTK. This means that:
|
| 64 |
+
* - All functions are marked inline
|
| 65 |
+
* - The type of a function parameter can be changed to be more generic if
|
| 66 |
+
* that means that code that called the original version can still be
|
| 67 |
+
* compiled.
|
| 68 |
+
*
|
| 69 |
+
* - Good exposure of the PTX should be high priority. If, at a new major
|
| 70 |
+
* version, we face a difficult choice between breaking backward-compatibility
|
| 71 |
+
* and an improvement of the PTX exposure, we will tend to the latter option
|
| 72 |
+
* more easily than in other parts of libcu++.
|
| 73 |
+
*/
|
| 74 |
+
|
| 75 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_PTX
|
| 76 |
+
|
| 77 |
+
/*
|
| 78 |
+
* Instructions
|
| 79 |
+
*
|
| 80 |
+
* The organization of the instructions below follows that of the PTX ISA documentation:
|
| 81 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#instructions
|
| 82 |
+
*
|
| 83 |
+
* To improve code organization, some sections are separated into their own
|
| 84 |
+
* header. For instance, the mbarrier instructions are found in:
|
| 85 |
+
* __cuda/ptx/parallel_synchronization_and_communication_instructions_mbarrier.h
|
| 86 |
+
*
|
| 87 |
+
*/
|
| 88 |
+
|
| 89 |
+
/*
|
| 90 |
+
* 9.7.1. Integer Arithmetic Instructions
|
| 91 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions
|
| 92 |
+
*
|
| 93 |
+
*/
|
| 94 |
+
|
| 95 |
+
// 9.7.1.7. Integer Arithmetic Instructions: sad
|
| 96 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-sad
|
| 97 |
+
|
| 98 |
+
// 9.7.1.8. Integer Arithmetic Instructions: div
|
| 99 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-div
|
| 100 |
+
|
| 101 |
+
// 9.7.1.9. Integer Arithmetic Instructions: rem
|
| 102 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-rem
|
| 103 |
+
|
| 104 |
+
// 9.7.1.10. Integer Arithmetic Instructions: abs
|
| 105 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-abs
|
| 106 |
+
|
| 107 |
+
// 9.7.1.11. Integer Arithmetic Instructions: neg
|
| 108 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-neg
|
| 109 |
+
|
| 110 |
+
// 9.7.1.12. Integer Arithmetic Instructions: min
|
| 111 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-min
|
| 112 |
+
|
| 113 |
+
// 9.7.1.13. Integer Arithmetic Instructions: max
|
| 114 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-max
|
| 115 |
+
|
| 116 |
+
// 9.7.1.14. Integer Arithmetic Instructions: popc
|
| 117 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-popc
|
| 118 |
+
|
| 119 |
+
// 9.7.1.15. Integer Arithmetic Instructions: clz
|
| 120 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-clz
|
| 121 |
+
|
| 122 |
+
// 9.7.1.16. Integer Arithmetic Instructions: bfind
|
| 123 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-bfind
|
| 124 |
+
|
| 125 |
+
// 9.7.1.17. Integer Arithmetic Instructions: fns
|
| 126 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-fns
|
| 127 |
+
|
| 128 |
+
// 9.7.1.18. Integer Arithmetic Instructions: brev
|
| 129 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-brev
|
| 130 |
+
|
| 131 |
+
// 9.7.1.19. Integer Arithmetic Instructions: bfe
|
| 132 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-bfe
|
| 133 |
+
|
| 134 |
+
// 9.7.1.20. Integer Arithmetic Instructions: bfi
|
| 135 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-bfi
|
| 136 |
+
|
| 137 |
+
// 9.7.1.21. Integer Arithmetic Instructions: szext
|
| 138 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-szext
|
| 139 |
+
|
| 140 |
+
// 9.7.1.22. Integer Arithmetic Instructions: bmsk
|
| 141 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-bmsk
|
| 142 |
+
|
| 143 |
+
// 9.7.1.23. Integer Arithmetic Instructions: dp4a
|
| 144 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-dp4a
|
| 145 |
+
|
| 146 |
+
// 9.7.1.24. Integer Arithmetic Instructions: dp2a
|
| 147 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#integer-arithmetic-instructions-dp2a
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
/*
|
| 151 |
+
* 9.7.2. Extended-Precision Integer Arithmetic Instructions
|
| 152 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-integer-arithmetic-instructions
|
| 153 |
+
*
|
| 154 |
+
*/
|
| 155 |
+
|
| 156 |
+
// 9.7.2.1. Extended-Precision Arithmetic Instructions: add.cc
|
| 157 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-add-cc
|
| 158 |
+
|
| 159 |
+
// 9.7.2.2. Extended-Precision Arithmetic Instructions: addc
|
| 160 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-addc
|
| 161 |
+
|
| 162 |
+
// 9.7.2.3. Extended-Precision Arithmetic Instructions: sub.cc
|
| 163 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-sub-cc
|
| 164 |
+
|
| 165 |
+
// 9.7.2.4. Extended-Precision Arithmetic Instructions: subc
|
| 166 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-subc
|
| 167 |
+
|
| 168 |
+
// 9.7.2.5. Extended-Precision Arithmetic Instructions: mad.cc
|
| 169 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-mad-cc
|
| 170 |
+
|
| 171 |
+
// 9.7.2.6. Extended-Precision Arithmetic Instructions: madc
|
| 172 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#extended-precision-arithmetic-instructions-madc
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
/*
|
| 176 |
+
* 9.7.3. Floating-Point Instructions
|
| 177 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions
|
| 178 |
+
*
|
| 179 |
+
*/
|
| 180 |
+
|
| 181 |
+
// 9.7.3.1. Floating Point Instructions: testp
|
| 182 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-testp
|
| 183 |
+
|
| 184 |
+
// 9.7.3.2. Floating Point Instructions: copysign
|
| 185 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-copysign
|
| 186 |
+
|
| 187 |
+
// 9.7.3.3. Floating Point Instructions: add
|
| 188 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-add
|
| 189 |
+
|
| 190 |
+
// 9.7.3.4. Floating Point Instructions: sub
|
| 191 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-sub
|
| 192 |
+
|
| 193 |
+
// 9.7.3.5. Floating Point Instructions: mul
|
| 194 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-mul
|
| 195 |
+
|
| 196 |
+
// 9.7.3.6. Floating Point Instructions: fma
|
| 197 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-fma
|
| 198 |
+
|
| 199 |
+
// 9.7.3.7. Floating Point Instructions: mad
|
| 200 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-mad
|
| 201 |
+
|
| 202 |
+
// 9.7.3.8. Floating Point Instructions: div
|
| 203 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-div
|
| 204 |
+
|
| 205 |
+
// 9.7.3.9. Floating Point Instructions: abs
|
| 206 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-abs
|
| 207 |
+
|
| 208 |
+
// 9.7.3.10. Floating Point Instructions: neg
|
| 209 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-neg
|
| 210 |
+
|
| 211 |
+
// 9.7.3.11. Floating Point Instructions: min
|
| 212 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-min
|
| 213 |
+
|
| 214 |
+
// 9.7.3.12. Floating Point Instructions: max
|
| 215 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-max
|
| 216 |
+
|
| 217 |
+
// 9.7.3.13. Floating Point Instructions: rcp
|
| 218 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-rcp
|
| 219 |
+
|
| 220 |
+
// 9.7.3.14. Floating Point Instructions: rcp.approx.ftz.f64
|
| 221 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-rcp-approx-ftz-f64
|
| 222 |
+
|
| 223 |
+
// 9.7.3.15. Floating Point Instructions: sqrt
|
| 224 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-sqrt
|
| 225 |
+
|
| 226 |
+
// 9.7.3.16. Floating Point Instructions: rsqrt
|
| 227 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-rsqrt
|
| 228 |
+
|
| 229 |
+
// 9.7.3.17. Floating Point Instructions: rsqrt.approx.ftz.f64
|
| 230 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-rsqrt-approx-ftz-f64
|
| 231 |
+
|
| 232 |
+
// 9.7.3.18. Floating Point Instructions: sin
|
| 233 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-sin
|
| 234 |
+
|
| 235 |
+
// 9.7.3.19. Floating Point Instructions: cos
|
| 236 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-cos
|
| 237 |
+
|
| 238 |
+
// 9.7.3.20. Floating Point Instructions: lg2
|
| 239 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-lg2
|
| 240 |
+
|
| 241 |
+
// 9.7.3.21. Floating Point Instructions: ex2
|
| 242 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-ex2
|
| 243 |
+
|
| 244 |
+
// 9.7.3.22. Floating Point Instructions: tanh
|
| 245 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#floating-point-instructions-tanh
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
/*
|
| 249 |
+
* 9.7.4. Half Precision Floating-Point Instructions
|
| 250 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions
|
| 251 |
+
*
|
| 252 |
+
*/
|
| 253 |
+
|
| 254 |
+
// 9.7.4.1. Half Precision Floating Point Instructions: add
|
| 255 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-add
|
| 256 |
+
|
| 257 |
+
// 9.7.4.2. Half Precision Floating Point Instructions: sub
|
| 258 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-sub
|
| 259 |
+
|
| 260 |
+
// 9.7.4.3. Half Precision Floating Point Instructions: mul
|
| 261 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-mul
|
| 262 |
+
|
| 263 |
+
// 9.7.4.4. Half Precision Floating Point Instructions: fma
|
| 264 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-fma
|
| 265 |
+
|
| 266 |
+
// 9.7.4.5. Half Precision Floating Point Instructions: neg
|
| 267 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-neg
|
| 268 |
+
|
| 269 |
+
// 9.7.4.6. Half Precision Floating Point Instructions: abs
|
| 270 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-abs
|
| 271 |
+
|
| 272 |
+
// 9.7.4.7. Half Precision Floating Point Instructions: min
|
| 273 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-min
|
| 274 |
+
|
| 275 |
+
// 9.7.4.8. Half Precision Floating Point Instructions: max
|
| 276 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-max
|
| 277 |
+
|
| 278 |
+
// 9.7.4.9. Half Precision Floating Point Instructions: tanh
|
| 279 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-tanh
|
| 280 |
+
|
| 281 |
+
// 9.7.4.10. Half Precision Floating Point Instructions: ex2
|
| 282 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-ex2
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
/*
|
| 286 |
+
* 9.7.5. Comparison and Selection Instructions
|
| 287 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions
|
| 288 |
+
*
|
| 289 |
+
*/
|
| 290 |
+
|
| 291 |
+
// 9.7.5.1. Comparison and Selection Instructions: set
|
| 292 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions-set
|
| 293 |
+
|
| 294 |
+
// 9.7.5.2. Comparison and Selection Instructions: setp
|
| 295 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions-setp
|
| 296 |
+
|
| 297 |
+
// 9.7.5.3. Comparison and Selection Instructions: selp
|
| 298 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions-selp
|
| 299 |
+
|
| 300 |
+
// 9.7.5.4. Comparison and Selection Instructions: slct
|
| 301 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#comparison-and-selection-instructions-slct
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
/*
|
| 305 |
+
* 9.7.6. Half Precision Comparison Instructions
|
| 306 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-comparison-instructions
|
| 307 |
+
*
|
| 308 |
+
*/
|
| 309 |
+
|
| 310 |
+
// 9.7.6.1. Half Precision Comparison Instructions: set
|
| 311 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-comparison-instructions-set
|
| 312 |
+
|
| 313 |
+
// 9.7.6.2. Half Precision Comparison Instructions: setp
|
| 314 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-comparison-instructions-setp
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
/*
|
| 318 |
+
* 9.7.7. Logic and Shift Instructions
|
| 319 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions
|
| 320 |
+
*
|
| 321 |
+
*/
|
| 322 |
+
|
| 323 |
+
// 9.7.7.1. Logic and Shift Instructions: and
|
| 324 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-and
|
| 325 |
+
|
| 326 |
+
// 9.7.7.2. Logic and Shift Instructions: or
|
| 327 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-or
|
| 328 |
+
|
| 329 |
+
// 9.7.7.3. Logic and Shift Instructions: xor
|
| 330 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-xor
|
| 331 |
+
|
| 332 |
+
// 9.7.7.4. Logic and Shift Instructions: not
|
| 333 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-not
|
| 334 |
+
|
| 335 |
+
// 9.7.7.5. Logic and Shift Instructions: cnot
|
| 336 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-cnot
|
| 337 |
+
|
| 338 |
+
// 9.7.7.6. Logic and Shift Instructions: lop3
|
| 339 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-lop3
|
| 340 |
+
|
| 341 |
+
// 9.7.7.7. Logic and Shift Instructions: shf
|
| 342 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-shf
|
| 343 |
+
|
| 344 |
+
// 9.7.7.8. Logic and Shift Instructions: shl
|
| 345 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-shl
|
| 346 |
+
|
| 347 |
+
// 9.7.7.9. Logic and Shift Instructions: shr
|
| 348 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#logic-and-shift-instructions-shr
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
/*
|
| 352 |
+
* 9.7.8. Data Movement and Conversion Instructions
|
| 353 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions
|
| 354 |
+
*
|
| 355 |
+
*/
|
| 356 |
+
|
| 357 |
+
// 9.7.8.3. Data Movement and Conversion Instructions: mov
|
| 358 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-mov
|
| 359 |
+
|
| 360 |
+
// 9.7.8.4. Data Movement and Conversion Instructions: mov
|
| 361 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-mov-2
|
| 362 |
+
|
| 363 |
+
// 9.7.8.5. Data Movement and Conversion Instructions: shfl (deprecated)
|
| 364 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-shfl-deprecated
|
| 365 |
+
|
| 366 |
+
// 9.7.8.6. Data Movement and Conversion Instructions: shfl.sync
|
| 367 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-shfl-sync
|
| 368 |
+
|
| 369 |
+
// 9.7.8.7. Data Movement and Conversion Instructions: prmt
|
| 370 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-prmt
|
| 371 |
+
|
| 372 |
+
// 9.7.8.8. Data Movement and Conversion Instructions: ld
|
| 373 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-ld
|
| 374 |
+
|
| 375 |
+
// 9.7.8.9. Data Movement and Conversion Instructions: ld.global.nc
|
| 376 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-ld-global-nc
|
| 377 |
+
|
| 378 |
+
// 9.7.8.10. Data Movement and Conversion Instructions: ldu
|
| 379 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-ldu
|
| 380 |
+
|
| 381 |
+
// 9.7.8.11. Data Movement and Conversion Instructions: st
|
| 382 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-st
|
| 383 |
+
|
| 384 |
+
// 9.7.8.12. Data Movement and Conversion Instructions: st.async
|
| 385 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-st-async
|
| 386 |
+
|
| 387 |
+
/*
|
| 388 |
+
// st.async.weak.shared::cluster.mbarrier::complete_tx::bytes{.type} [addr], value, [remote_bar]; // 1. PTX ISA 81, SM_90
|
| 389 |
+
// .type = { .b32, .b64 }
|
| 390 |
+
template <typename Type>
|
| 391 |
+
__device__ static inline void st_async(
|
| 392 |
+
Type* addr,
|
| 393 |
+
const Type& value,
|
| 394 |
+
uint64_t* remote_bar);
|
| 395 |
+
*/
|
| 396 |
+
#if __cccl_ptx_isa >= 810
|
| 397 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 398 |
+
template <typename _Type>
|
| 399 |
+
_LIBCUDACXX_DEVICE static inline void st_async(
|
| 400 |
+
_Type* __addr,
|
| 401 |
+
const _Type& __value,
|
| 402 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 403 |
+
{
|
| 404 |
+
static_assert(sizeof(_Type) == 4 || sizeof(_Type) == 8, "");
|
| 405 |
+
|
| 406 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 407 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (sizeof(_Type) == 4) {
|
| 408 |
+
asm (
|
| 409 |
+
"st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.b32 [%0], %1, [%2]; // 1. "
|
| 410 |
+
:
|
| 411 |
+
: "r"(__as_ptr_remote_dsmem(__addr)),
|
| 412 |
+
"r"(__as_b32(__value)),
|
| 413 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 414 |
+
: "memory"
|
| 415 |
+
);
|
| 416 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (sizeof(_Type) == 8) {
|
| 417 |
+
asm (
|
| 418 |
+
"st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.b64 [%0], %1, [%2]; // 1. "
|
| 419 |
+
:
|
| 420 |
+
: "r"(__as_ptr_remote_dsmem(__addr)),
|
| 421 |
+
"l"(__as_b64(__value)),
|
| 422 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 423 |
+
: "memory"
|
| 424 |
+
);
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
),(
|
| 428 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 429 |
+
return __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 430 |
+
));
|
| 431 |
+
}
|
| 432 |
+
#endif // __cccl_ptx_isa >= 810
|
| 433 |
+
|
| 434 |
+
/*
|
| 435 |
+
// st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.v2{.type} [addr], value, [remote_bar]; // 2. PTX ISA 81, SM_90
|
| 436 |
+
// .type = { .b32, .b64 }
|
| 437 |
+
template <typename Type>
|
| 438 |
+
__device__ static inline void st_async(
|
| 439 |
+
Type* addr,
|
| 440 |
+
const Type (&value)[2],
|
| 441 |
+
uint64_t* remote_bar);
|
| 442 |
+
*/
|
| 443 |
+
#if __cccl_ptx_isa >= 810
|
| 444 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 445 |
+
template <typename _Type>
|
| 446 |
+
_LIBCUDACXX_DEVICE static inline void st_async(
|
| 447 |
+
_Type* __addr,
|
| 448 |
+
const _Type (&__value)[2],
|
| 449 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 450 |
+
{
|
| 451 |
+
static_assert(sizeof(_Type) == 4 || sizeof(_Type) == 8, "");
|
| 452 |
+
|
| 453 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 454 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (sizeof(_Type) == 4) {
|
| 455 |
+
asm (
|
| 456 |
+
"st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.v2.b32 [%0], {%1, %2}, [%3]; // 2. "
|
| 457 |
+
:
|
| 458 |
+
: "r"(__as_ptr_remote_dsmem(__addr)),
|
| 459 |
+
"r"(__as_b32(__value[0])),
|
| 460 |
+
"r"(__as_b32(__value[1])),
|
| 461 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 462 |
+
: "memory"
|
| 463 |
+
);
|
| 464 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (sizeof(_Type) == 8) {
|
| 465 |
+
asm (
|
| 466 |
+
"st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.v2.b64 [%0], {%1, %2}, [%3]; // 2. "
|
| 467 |
+
:
|
| 468 |
+
: "r"(__as_ptr_remote_dsmem(__addr)),
|
| 469 |
+
"l"(__as_b64(__value[0])),
|
| 470 |
+
"l"(__as_b64(__value[1])),
|
| 471 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 472 |
+
: "memory"
|
| 473 |
+
);
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
),(
|
| 477 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 478 |
+
return __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 479 |
+
));
|
| 480 |
+
}
|
| 481 |
+
#endif // __cccl_ptx_isa >= 810
|
| 482 |
+
|
| 483 |
+
/*
|
| 484 |
+
// st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.v4.b32 [addr], value, [remote_bar]; // 3. PTX ISA 81, SM_90
|
| 485 |
+
template <typename B32>
|
| 486 |
+
__device__ static inline void st_async(
|
| 487 |
+
B32* addr,
|
| 488 |
+
const B32 (&value)[4],
|
| 489 |
+
uint64_t* remote_bar);
|
| 490 |
+
*/
|
| 491 |
+
#if __cccl_ptx_isa >= 810
|
| 492 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 493 |
+
template <typename _B32>
|
| 494 |
+
_LIBCUDACXX_DEVICE static inline void st_async(
|
| 495 |
+
_B32* __addr,
|
| 496 |
+
const _B32 (&__value)[4],
|
| 497 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 498 |
+
{
|
| 499 |
+
static_assert(sizeof(_B32) == 4, "");
|
| 500 |
+
|
| 501 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 502 |
+
asm (
|
| 503 |
+
"st.async.weak.shared::cluster.mbarrier::complete_tx::bytes.v4.b32 [%0], {%1, %2, %3, %4}, [%5]; // 3. "
|
| 504 |
+
:
|
| 505 |
+
: "r"(__as_ptr_remote_dsmem(__addr)),
|
| 506 |
+
"r"(__as_b32(__value[0])),
|
| 507 |
+
"r"(__as_b32(__value[1])),
|
| 508 |
+
"r"(__as_b32(__value[2])),
|
| 509 |
+
"r"(__as_b32(__value[3])),
|
| 510 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 511 |
+
: "memory"
|
| 512 |
+
);
|
| 513 |
+
|
| 514 |
+
),(
|
| 515 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 516 |
+
return __void__cuda_ptx_st_async_is_not_supported_before_SM_90__();
|
| 517 |
+
));
|
| 518 |
+
}
|
| 519 |
+
#endif // __cccl_ptx_isa >= 810
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
// 9.7.8.13. Data Movement and Conversion Instructions: multimem.ld_reduce, multimem.st, multimem.red
|
| 523 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-multimem-ld-reduce-multimem-st-multimem-red
|
| 524 |
+
|
| 525 |
+
// 9.7.8.14. Data Movement and Conversion Instructions: prefetch, prefetchu
|
| 526 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-prefetch-prefetchu
|
| 527 |
+
|
| 528 |
+
// 9.7.8.15. Data Movement and Conversion Instructions: applypriority
|
| 529 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-applypriority
|
| 530 |
+
|
| 531 |
+
// 9.7.8.16. Data Movement and Conversion Instructions: discard
|
| 532 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-discard
|
| 533 |
+
|
| 534 |
+
// 9.7.8.17. Data Movement and Conversion Instructions: createpolicy
|
| 535 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-createpolicy
|
| 536 |
+
|
| 537 |
+
// 9.7.8.18. Data Movement and Conversion Instructions: isspacep
|
| 538 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-isspacep
|
| 539 |
+
|
| 540 |
+
// 9.7.8.19. Data Movement and Conversion Instructions: cvta
|
| 541 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvta
|
| 542 |
+
|
| 543 |
+
// 9.7.8.20. Data Movement and Conversion Instructions: cvt
|
| 544 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvt
|
| 545 |
+
|
| 546 |
+
// 9.7.8.21. Data Movement and Conversion Instructions: cvt.pack
|
| 547 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cvt-pack
|
| 548 |
+
|
| 549 |
+
// 9.7.8.22. Data Movement and Conversion Instructions: mapa
|
| 550 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-mapa
|
| 551 |
+
|
| 552 |
+
// 9.7.8.23. Data Movement and Conversion Instructions: getctarank
|
| 553 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-getctarank
|
| 554 |
+
|
| 555 |
+
|
| 556 |
+
/*
|
| 557 |
+
* 9.7.8.24. Data Movement and Conversion Instructions: Asynchronous copy
|
| 558 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-asynchronous-copy
|
| 559 |
+
*
|
| 560 |
+
*/
|
| 561 |
+
|
| 562 |
+
// 9.7.8.24.3. Data Movement and Conversion Instructions: cp.async
|
| 563 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async
|
| 564 |
+
|
| 565 |
+
// 9.7.8.24.4. Data Movement and Conversion Instructions: cp.async.commit_group
|
| 566 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-commit-group
|
| 567 |
+
|
| 568 |
+
// 9.7.8.24.5. Data Movement and Conversion Instructions: cp.async.wait_group / cp.async.wait_all
|
| 569 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group-cp-async-wait-all
|
| 570 |
+
|
| 571 |
+
// 9.7.8.24.6. Data Movement and Conversion Instructions: cp.async.bulk
|
| 572 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk
|
| 573 |
+
|
| 574 |
+
// 9.7.8.24.7. Data Movement and Conversion Instructions: cp.reduce.async.bulk
|
| 575 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-reduce-async-bulk
|
| 576 |
+
|
| 577 |
+
// 9.7.8.24.8. Data Movement and Conversion Instructions: cp.async.bulk.prefetch
|
| 578 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-prefetch
|
| 579 |
+
|
| 580 |
+
// 9.7.8.24.9. Data Movement and Conversion Instructions: cp.async.bulk.tensor
|
| 581 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-tensor
|
| 582 |
+
|
| 583 |
+
// 9.7.8.24.10. Data Movement and Conversion Instructions: cp.reduce.async.bulk.tensor
|
| 584 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-reduce-async-bulk-tensor
|
| 585 |
+
|
| 586 |
+
// 9.7.8.24.11. Data Movement and Conversion Instructions: cp.async.bulk.prefetch.tensor
|
| 587 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-prefetch-tensor
|
| 588 |
+
|
| 589 |
+
// 9.7.8.24.12. Data Movement and Conversion Instructions: cp.async.bulk.commit_group
|
| 590 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-commit-group
|
| 591 |
+
|
| 592 |
+
// 9.7.8.24.13. Data Movement and Conversion Instructions: cp.async.bulk.wait_group
|
| 593 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-bulk-wait-group
|
| 594 |
+
|
| 595 |
+
// 9.7.8.25. Data Movement and Conversion Instructions: tensormap.replace
|
| 596 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-tensormap-replace
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
/*
|
| 600 |
+
* 9.7.9. Texture Instructions
|
| 601 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#texture-instructions
|
| 602 |
+
*
|
| 603 |
+
*/
|
| 604 |
+
|
| 605 |
+
// 9.7.9.3. Texture Instructions: tex
|
| 606 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#texture-instructions-tex
|
| 607 |
+
|
| 608 |
+
// 9.7.9.4. Texture Instructions: tld4
|
| 609 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#texture-instructions-tld4
|
| 610 |
+
|
| 611 |
+
// 9.7.9.5. Texture Instructions: txq
|
| 612 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#texture-instructions-txq
|
| 613 |
+
|
| 614 |
+
// 9.7.9.6. Texture Instructions: istypep
|
| 615 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#texture-instructions-istypep
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
/*
|
| 619 |
+
* 9.7.10. Surface Instructions
|
| 620 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#surface-instructions
|
| 621 |
+
*
|
| 622 |
+
*/
|
| 623 |
+
|
| 624 |
+
// 9.7.10.1. Surface Instructions: suld
|
| 625 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#surface-instructions-suld
|
| 626 |
+
|
| 627 |
+
// 9.7.10.2. Surface Instructions: sust
|
| 628 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#surface-instructions-sust
|
| 629 |
+
|
| 630 |
+
// 9.7.10.3. Surface Instructions: sured
|
| 631 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#surface-instructions-sured
|
| 632 |
+
|
| 633 |
+
// 9.7.10.4. Surface Instructions: suq
|
| 634 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#surface-instructions-suq
|
| 635 |
+
|
| 636 |
+
|
| 637 |
+
/*
|
| 638 |
+
* 9.7.11. Control Flow Instructions
|
| 639 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions
|
| 640 |
+
*
|
| 641 |
+
*/
|
| 642 |
+
|
| 643 |
+
// 9.7.11.1. Control Flow Instructions: {}
|
| 644 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-curly-braces
|
| 645 |
+
|
| 646 |
+
// 9.7.11.2. Control Flow Instructions: @
|
| 647 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-at
|
| 648 |
+
|
| 649 |
+
// 9.7.11.3. Control Flow Instructions: bra
|
| 650 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-bra
|
| 651 |
+
|
| 652 |
+
// 9.7.11.4. Control Flow Instructions: brx.idx
|
| 653 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-brx-idx
|
| 654 |
+
|
| 655 |
+
// 9.7.11.5. Control Flow Instructions: call
|
| 656 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-call
|
| 657 |
+
|
| 658 |
+
// 9.7.11.6. Control Flow Instructions: ret
|
| 659 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-ret
|
| 660 |
+
|
| 661 |
+
// 9.7.11.7. Control Flow Instructions: exit
|
| 662 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#control-flow-instructions-exit
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
/*
|
| 666 |
+
* 9.7.12. Parallel Synchronization and Communication Instructions
|
| 667 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions
|
| 668 |
+
*
|
| 669 |
+
*/
|
| 670 |
+
|
| 671 |
+
// 9.7.12.1. Parallel Synchronization and Communication Instructions: bar, barrier
|
| 672 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-bar-barrier
|
| 673 |
+
|
| 674 |
+
// 9.7.12.2. Parallel Synchronization and Communication Instructions: bar.warp.sync
|
| 675 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-bar-warp-sync
|
| 676 |
+
|
| 677 |
+
// 9.7.12.3. Parallel Synchronization and Communication Instructions: barrier.cluster
|
| 678 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-barrier-cluster
|
| 679 |
+
|
| 680 |
+
// 9.7.12.4. Parallel Synchronization and Communication Instructions: membar/fence
|
| 681 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-membar-fence
|
| 682 |
+
|
| 683 |
+
// 9.7.12.5. Parallel Synchronization and Communication Instructions: atom
|
| 684 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-atom
|
| 685 |
+
|
| 686 |
+
// 9.7.12.6. Parallel Synchronization and Communication Instructions: red
|
| 687 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-red
|
| 688 |
+
|
| 689 |
+
// 9.7.12.7. Parallel Synchronization and Communication Instructions: red.async
|
| 690 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-red-async
|
| 691 |
+
|
| 692 |
+
/*
|
| 693 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 694 |
+
// .type = { .u32 }
|
| 695 |
+
// .op = { .inc }
|
| 696 |
+
template <typename=void>
|
| 697 |
+
__device__ static inline void red_async(
|
| 698 |
+
cuda::ptx::op_inc_t,
|
| 699 |
+
uint32_t* dest,
|
| 700 |
+
const uint32_t& value,
|
| 701 |
+
uint64_t* remote_bar);
|
| 702 |
+
*/
|
| 703 |
+
#if __cccl_ptx_isa >= 810
|
| 704 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 705 |
+
template <typename=void>
|
| 706 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 707 |
+
op_inc_t,
|
| 708 |
+
_CUDA_VSTD::uint32_t* __dest,
|
| 709 |
+
const _CUDA_VSTD::uint32_t& __value,
|
| 710 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 711 |
+
{
|
| 712 |
+
// __type == type_u32 (due to parameter type constraint)
|
| 713 |
+
// __op == op_inc (due to parameter type constraint)
|
| 714 |
+
|
| 715 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 716 |
+
asm (
|
| 717 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.inc.u32 [%0], %1, [%2]; "
|
| 718 |
+
:
|
| 719 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 720 |
+
"r"(__value),
|
| 721 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 722 |
+
: "memory"
|
| 723 |
+
);
|
| 724 |
+
|
| 725 |
+
),(
|
| 726 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 727 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 728 |
+
));
|
| 729 |
+
}
|
| 730 |
+
#endif // __cccl_ptx_isa >= 810
|
| 731 |
+
|
| 732 |
+
/*
|
| 733 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 734 |
+
// .type = { .u32 }
|
| 735 |
+
// .op = { .dec }
|
| 736 |
+
template <typename=void>
|
| 737 |
+
__device__ static inline void red_async(
|
| 738 |
+
cuda::ptx::op_dec_t,
|
| 739 |
+
uint32_t* dest,
|
| 740 |
+
const uint32_t& value,
|
| 741 |
+
uint64_t* remote_bar);
|
| 742 |
+
*/
|
| 743 |
+
#if __cccl_ptx_isa >= 810
|
| 744 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 745 |
+
template <typename=void>
|
| 746 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 747 |
+
op_dec_t,
|
| 748 |
+
_CUDA_VSTD::uint32_t* __dest,
|
| 749 |
+
const _CUDA_VSTD::uint32_t& __value,
|
| 750 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 751 |
+
{
|
| 752 |
+
// __type == type_u32 (due to parameter type constraint)
|
| 753 |
+
// __op == op_dec (due to parameter type constraint)
|
| 754 |
+
|
| 755 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 756 |
+
asm (
|
| 757 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.dec.u32 [%0], %1, [%2]; "
|
| 758 |
+
:
|
| 759 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 760 |
+
"r"(__value),
|
| 761 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 762 |
+
: "memory"
|
| 763 |
+
);
|
| 764 |
+
|
| 765 |
+
),(
|
| 766 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 767 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 768 |
+
));
|
| 769 |
+
}
|
| 770 |
+
#endif // __cccl_ptx_isa >= 810
|
| 771 |
+
|
| 772 |
+
/*
|
| 773 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 774 |
+
// .type = { .u32 }
|
| 775 |
+
// .op = { .min }
|
| 776 |
+
template <typename=void>
|
| 777 |
+
__device__ static inline void red_async(
|
| 778 |
+
cuda::ptx::op_min_t,
|
| 779 |
+
uint32_t* dest,
|
| 780 |
+
const uint32_t& value,
|
| 781 |
+
uint64_t* remote_bar);
|
| 782 |
+
*/
|
| 783 |
+
#if __cccl_ptx_isa >= 810
|
| 784 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 785 |
+
template <typename=void>
|
| 786 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 787 |
+
op_min_t,
|
| 788 |
+
_CUDA_VSTD::uint32_t* __dest,
|
| 789 |
+
const _CUDA_VSTD::uint32_t& __value,
|
| 790 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 791 |
+
{
|
| 792 |
+
// __type == type_u32 (due to parameter type constraint)
|
| 793 |
+
// __op == op_min (due to parameter type constraint)
|
| 794 |
+
|
| 795 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 796 |
+
asm (
|
| 797 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.min.u32 [%0], %1, [%2]; "
|
| 798 |
+
:
|
| 799 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 800 |
+
"r"(__value),
|
| 801 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 802 |
+
: "memory"
|
| 803 |
+
);
|
| 804 |
+
|
| 805 |
+
),(
|
| 806 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 807 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 808 |
+
));
|
| 809 |
+
}
|
| 810 |
+
#endif // __cccl_ptx_isa >= 810
|
| 811 |
+
|
| 812 |
+
/*
|
| 813 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 814 |
+
// .type = { .u32 }
|
| 815 |
+
// .op = { .max }
|
| 816 |
+
template <typename=void>
|
| 817 |
+
__device__ static inline void red_async(
|
| 818 |
+
cuda::ptx::op_max_t,
|
| 819 |
+
uint32_t* dest,
|
| 820 |
+
const uint32_t& value,
|
| 821 |
+
uint64_t* remote_bar);
|
| 822 |
+
*/
|
| 823 |
+
#if __cccl_ptx_isa >= 810
|
| 824 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 825 |
+
template <typename=void>
|
| 826 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 827 |
+
op_max_t,
|
| 828 |
+
_CUDA_VSTD::uint32_t* __dest,
|
| 829 |
+
const _CUDA_VSTD::uint32_t& __value,
|
| 830 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 831 |
+
{
|
| 832 |
+
// __type == type_u32 (due to parameter type constraint)
|
| 833 |
+
// __op == op_max (due to parameter type constraint)
|
| 834 |
+
|
| 835 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 836 |
+
asm (
|
| 837 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.max.u32 [%0], %1, [%2]; "
|
| 838 |
+
:
|
| 839 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 840 |
+
"r"(__value),
|
| 841 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 842 |
+
: "memory"
|
| 843 |
+
);
|
| 844 |
+
|
| 845 |
+
),(
|
| 846 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 847 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 848 |
+
));
|
| 849 |
+
}
|
| 850 |
+
#endif // __cccl_ptx_isa >= 810
|
| 851 |
+
|
| 852 |
+
/*
|
| 853 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 854 |
+
// .type = { .u32 }
|
| 855 |
+
// .op = { .add }
|
| 856 |
+
template <typename=void>
|
| 857 |
+
__device__ static inline void red_async(
|
| 858 |
+
cuda::ptx::op_add_t,
|
| 859 |
+
uint32_t* dest,
|
| 860 |
+
const uint32_t& value,
|
| 861 |
+
uint64_t* remote_bar);
|
| 862 |
+
*/
|
| 863 |
+
#if __cccl_ptx_isa >= 810
|
| 864 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 865 |
+
template <typename=void>
|
| 866 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 867 |
+
op_add_t,
|
| 868 |
+
_CUDA_VSTD::uint32_t* __dest,
|
| 869 |
+
const _CUDA_VSTD::uint32_t& __value,
|
| 870 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 871 |
+
{
|
| 872 |
+
// __type == type_u32 (due to parameter type constraint)
|
| 873 |
+
// __op == op_add (due to parameter type constraint)
|
| 874 |
+
|
| 875 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 876 |
+
asm (
|
| 877 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.add.u32 [%0], %1, [%2]; "
|
| 878 |
+
:
|
| 879 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 880 |
+
"r"(__value),
|
| 881 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 882 |
+
: "memory"
|
| 883 |
+
);
|
| 884 |
+
|
| 885 |
+
),(
|
| 886 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 887 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 888 |
+
));
|
| 889 |
+
}
|
| 890 |
+
#endif // __cccl_ptx_isa >= 810
|
| 891 |
+
|
| 892 |
+
/*
|
| 893 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 894 |
+
// .type = { .s32 }
|
| 895 |
+
// .op = { .min }
|
| 896 |
+
template <typename=void>
|
| 897 |
+
__device__ static inline void red_async(
|
| 898 |
+
cuda::ptx::op_min_t,
|
| 899 |
+
int32_t* dest,
|
| 900 |
+
const int32_t& value,
|
| 901 |
+
uint64_t* remote_bar);
|
| 902 |
+
*/
|
| 903 |
+
#if __cccl_ptx_isa >= 810
|
| 904 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 905 |
+
template <typename=void>
|
| 906 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 907 |
+
op_min_t,
|
| 908 |
+
_CUDA_VSTD::int32_t* __dest,
|
| 909 |
+
const _CUDA_VSTD::int32_t& __value,
|
| 910 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 911 |
+
{
|
| 912 |
+
// __type == type_s32 (due to parameter type constraint)
|
| 913 |
+
// __op == op_min (due to parameter type constraint)
|
| 914 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 915 |
+
asm (
|
| 916 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.min.s32 [%0], %1, [%2]; "
|
| 917 |
+
:
|
| 918 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 919 |
+
"r"(__value),
|
| 920 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 921 |
+
: "memory"
|
| 922 |
+
);
|
| 923 |
+
|
| 924 |
+
),(
|
| 925 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 926 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 927 |
+
));
|
| 928 |
+
}
|
| 929 |
+
#endif // __cccl_ptx_isa >= 810
|
| 930 |
+
|
| 931 |
+
/*
|
| 932 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 933 |
+
// .type = { .s32 }
|
| 934 |
+
// .op = { .max }
|
| 935 |
+
template <typename=void>
|
| 936 |
+
__device__ static inline void red_async(
|
| 937 |
+
cuda::ptx::op_max_t,
|
| 938 |
+
int32_t* dest,
|
| 939 |
+
const int32_t& value,
|
| 940 |
+
uint64_t* remote_bar);
|
| 941 |
+
*/
|
| 942 |
+
#if __cccl_ptx_isa >= 810
|
| 943 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 944 |
+
template <typename=void>
|
| 945 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 946 |
+
op_max_t,
|
| 947 |
+
_CUDA_VSTD::int32_t* __dest,
|
| 948 |
+
const _CUDA_VSTD::int32_t& __value,
|
| 949 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 950 |
+
{
|
| 951 |
+
// __type == type_s32 (due to parameter type constraint)
|
| 952 |
+
// __op == op_max (due to parameter type constraint)
|
| 953 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 954 |
+
asm (
|
| 955 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.max.s32 [%0], %1, [%2]; "
|
| 956 |
+
:
|
| 957 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 958 |
+
"r"(__value),
|
| 959 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 960 |
+
: "memory"
|
| 961 |
+
);
|
| 962 |
+
|
| 963 |
+
),(
|
| 964 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 965 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 966 |
+
));
|
| 967 |
+
}
|
| 968 |
+
#endif // __cccl_ptx_isa >= 810
|
| 969 |
+
|
| 970 |
+
/*
|
| 971 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 972 |
+
// .type = { .s32 }
|
| 973 |
+
// .op = { .add }
|
| 974 |
+
template <typename=void>
|
| 975 |
+
__device__ static inline void red_async(
|
| 976 |
+
cuda::ptx::op_add_t,
|
| 977 |
+
int32_t* dest,
|
| 978 |
+
const int32_t& value,
|
| 979 |
+
uint64_t* remote_bar);
|
| 980 |
+
*/
|
| 981 |
+
#if __cccl_ptx_isa >= 810
|
| 982 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 983 |
+
template <typename=void>
|
| 984 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 985 |
+
op_add_t,
|
| 986 |
+
_CUDA_VSTD::int32_t* __dest,
|
| 987 |
+
const _CUDA_VSTD::int32_t& __value,
|
| 988 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 989 |
+
{
|
| 990 |
+
// __type == type_s32 (due to parameter type constraint)
|
| 991 |
+
// __op == op_add (due to parameter type constraint)
|
| 992 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 993 |
+
asm (
|
| 994 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.add.s32 [%0], %1, [%2]; "
|
| 995 |
+
:
|
| 996 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 997 |
+
"r"(__value),
|
| 998 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 999 |
+
: "memory"
|
| 1000 |
+
);
|
| 1001 |
+
|
| 1002 |
+
),(
|
| 1003 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1004 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1005 |
+
));
|
| 1006 |
+
}
|
| 1007 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1008 |
+
|
| 1009 |
+
/*
|
| 1010 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 1011 |
+
// .type = { .b32 }
|
| 1012 |
+
// .op = { .and }
|
| 1013 |
+
template <typename B32>
|
| 1014 |
+
__device__ static inline void red_async(
|
| 1015 |
+
cuda::ptx::op_and_op_t,
|
| 1016 |
+
B32* dest,
|
| 1017 |
+
const B32& value,
|
| 1018 |
+
uint64_t* remote_bar);
|
| 1019 |
+
*/
|
| 1020 |
+
#if __cccl_ptx_isa >= 810
|
| 1021 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1022 |
+
template <typename _B32>
|
| 1023 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 1024 |
+
op_and_op_t,
|
| 1025 |
+
_B32* __dest,
|
| 1026 |
+
const _B32& __value,
|
| 1027 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 1028 |
+
{
|
| 1029 |
+
// __type == type_b32 (due to parameter type constraint)
|
| 1030 |
+
// __op == op_and_op (due to parameter type constraint)
|
| 1031 |
+
static_assert(sizeof(_B32) == 4, "");
|
| 1032 |
+
|
| 1033 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1034 |
+
asm (
|
| 1035 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.and.b32 [%0], %1, [%2]; "
|
| 1036 |
+
:
|
| 1037 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 1038 |
+
"r"(__as_b32(__value)),
|
| 1039 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 1040 |
+
: "memory"
|
| 1041 |
+
);
|
| 1042 |
+
|
| 1043 |
+
),(
|
| 1044 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1045 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1046 |
+
));
|
| 1047 |
+
}
|
| 1048 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1049 |
+
|
| 1050 |
+
/*
|
| 1051 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 1052 |
+
// .type = { .b32 }
|
| 1053 |
+
// .op = { .or }
|
| 1054 |
+
template <typename B32>
|
| 1055 |
+
__device__ static inline void red_async(
|
| 1056 |
+
cuda::ptx::op_or_op_t,
|
| 1057 |
+
B32* dest,
|
| 1058 |
+
const B32& value,
|
| 1059 |
+
uint64_t* remote_bar);
|
| 1060 |
+
*/
|
| 1061 |
+
#if __cccl_ptx_isa >= 810
|
| 1062 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1063 |
+
template <typename _B32>
|
| 1064 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 1065 |
+
op_or_op_t,
|
| 1066 |
+
_B32* __dest,
|
| 1067 |
+
const _B32& __value,
|
| 1068 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 1069 |
+
{
|
| 1070 |
+
// __type == type_b32 (due to parameter type constraint)
|
| 1071 |
+
// __op == op_or_op (due to parameter type constraint)
|
| 1072 |
+
static_assert(sizeof(_B32) == 4, "");
|
| 1073 |
+
|
| 1074 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1075 |
+
asm (
|
| 1076 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.or.b32 [%0], %1, [%2]; "
|
| 1077 |
+
:
|
| 1078 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 1079 |
+
"r"(__as_b32(__value)),
|
| 1080 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 1081 |
+
: "memory"
|
| 1082 |
+
);
|
| 1083 |
+
|
| 1084 |
+
),(
|
| 1085 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1086 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1087 |
+
));
|
| 1088 |
+
}
|
| 1089 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1090 |
+
|
| 1091 |
+
/*
|
| 1092 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 1093 |
+
// .type = { .b32 }
|
| 1094 |
+
// .op = { .xor }
|
| 1095 |
+
template <typename B32>
|
| 1096 |
+
__device__ static inline void red_async(
|
| 1097 |
+
cuda::ptx::op_xor_op_t,
|
| 1098 |
+
B32* dest,
|
| 1099 |
+
const B32& value,
|
| 1100 |
+
uint64_t* remote_bar);
|
| 1101 |
+
*/
|
| 1102 |
+
#if __cccl_ptx_isa >= 810
|
| 1103 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1104 |
+
template <typename _B32>
|
| 1105 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 1106 |
+
op_xor_op_t,
|
| 1107 |
+
_B32* __dest,
|
| 1108 |
+
const _B32& __value,
|
| 1109 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 1110 |
+
{
|
| 1111 |
+
// __type == type_b32 (due to parameter type constraint)
|
| 1112 |
+
// __op == op_xor_op (due to parameter type constraint)
|
| 1113 |
+
static_assert(sizeof(_B32) == 4, "");
|
| 1114 |
+
|
| 1115 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1116 |
+
asm (
|
| 1117 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.xor.b32 [%0], %1, [%2]; "
|
| 1118 |
+
:
|
| 1119 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 1120 |
+
"r"(__as_b32(__value)),
|
| 1121 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 1122 |
+
: "memory"
|
| 1123 |
+
);
|
| 1124 |
+
|
| 1125 |
+
),(
|
| 1126 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1127 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1128 |
+
));
|
| 1129 |
+
}
|
| 1130 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1131 |
+
|
| 1132 |
+
/*
|
| 1133 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}{.type} [dest], value, [remote_bar]; // PTX ISA 81, SM_90
|
| 1134 |
+
// .type = { .u64 }
|
| 1135 |
+
// .op = { .add }
|
| 1136 |
+
template <typename=void>
|
| 1137 |
+
__device__ static inline void red_async(
|
| 1138 |
+
cuda::ptx::op_add_t,
|
| 1139 |
+
uint64_t* dest,
|
| 1140 |
+
const uint64_t& value,
|
| 1141 |
+
uint64_t* remote_bar);
|
| 1142 |
+
*/
|
| 1143 |
+
#if __cccl_ptx_isa >= 810
|
| 1144 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1145 |
+
template <typename=void>
|
| 1146 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 1147 |
+
op_add_t,
|
| 1148 |
+
_CUDA_VSTD::uint64_t* __dest,
|
| 1149 |
+
const _CUDA_VSTD::uint64_t& __value,
|
| 1150 |
+
_CUDA_VSTD::uint64_t* __remote_bar)
|
| 1151 |
+
{
|
| 1152 |
+
// __type == type_u64 (due to parameter type constraint)
|
| 1153 |
+
// __op == op_add (due to parameter type constraint)
|
| 1154 |
+
|
| 1155 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1156 |
+
asm (
|
| 1157 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.add.u64 [%0], %1, [%2]; "
|
| 1158 |
+
:
|
| 1159 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 1160 |
+
"l"(__value),
|
| 1161 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 1162 |
+
: "memory"
|
| 1163 |
+
);
|
| 1164 |
+
|
| 1165 |
+
),(
|
| 1166 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1167 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1168 |
+
));
|
| 1169 |
+
}
|
| 1170 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1171 |
+
|
| 1172 |
+
/*
|
| 1173 |
+
// red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes{.op}.u64 [dest], value, [remote_bar]; // .u64 intentional PTX ISA 81, SM_90
|
| 1174 |
+
// .op = { .add }
|
| 1175 |
+
template <typename=void>
|
| 1176 |
+
__device__ static inline void red_async(
|
| 1177 |
+
cuda::ptx::op_add_t,
|
| 1178 |
+
int64_t* dest,
|
| 1179 |
+
const int64_t& value,
|
| 1180 |
+
int64_t* remote_bar);
|
| 1181 |
+
*/
|
| 1182 |
+
#if __cccl_ptx_isa >= 810
|
| 1183 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1184 |
+
template <typename=void>
|
| 1185 |
+
_LIBCUDACXX_DEVICE static inline void red_async(
|
| 1186 |
+
op_add_t,
|
| 1187 |
+
_CUDA_VSTD::int64_t* __dest,
|
| 1188 |
+
const _CUDA_VSTD::int64_t& __value,
|
| 1189 |
+
_CUDA_VSTD::int64_t* __remote_bar)
|
| 1190 |
+
{
|
| 1191 |
+
// __op == op_add (due to parameter type constraint)
|
| 1192 |
+
|
| 1193 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1194 |
+
asm (
|
| 1195 |
+
"red.async.relaxed.cluster.shared::cluster.mbarrier::complete_tx::bytes.add.u64 [%0], %1, [%2]; // .u64 intentional"
|
| 1196 |
+
:
|
| 1197 |
+
: "r"(__as_ptr_remote_dsmem(__dest)),
|
| 1198 |
+
"l"(__value),
|
| 1199 |
+
"r"(__as_ptr_remote_dsmem(__remote_bar))
|
| 1200 |
+
: "memory"
|
| 1201 |
+
);
|
| 1202 |
+
|
| 1203 |
+
),(
|
| 1204 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1205 |
+
return __void__cuda_ptx_red_async_is_not_supported_before_SM_90__();
|
| 1206 |
+
));
|
| 1207 |
+
}
|
| 1208 |
+
#endif // __cccl_ptx_isa >= 810
|
| 1209 |
+
|
| 1210 |
+
|
| 1211 |
+
// 9.7.12.8. Parallel Synchronization and Communication Instructions: vote (deprecated)
|
| 1212 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-vote-deprecated
|
| 1213 |
+
|
| 1214 |
+
// 9.7.12.9. Parallel Synchronization and Communication Instructions: vote.sync
|
| 1215 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-vote-sync
|
| 1216 |
+
|
| 1217 |
+
// 9.7.12.10. Parallel Synchronization and Communication Instructions: match.sync
|
| 1218 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-match-sync
|
| 1219 |
+
|
| 1220 |
+
// 9.7.12.11. Parallel Synchronization and Communication Instructions: activemask
|
| 1221 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-activemask
|
| 1222 |
+
|
| 1223 |
+
// 9.7.12.12. Parallel Synchronization and Communication Instructions: redux.sync
|
| 1224 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-redux-sync
|
| 1225 |
+
|
| 1226 |
+
// 9.7.12.13. Parallel Synchronization and Communication Instructions: griddepcontrol
|
| 1227 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-griddepcontrol
|
| 1228 |
+
|
| 1229 |
+
// 9.7.12.14. Parallel Synchronization and Communication Instructions: elect.sync
|
| 1230 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-elect-sync
|
| 1231 |
+
|
| 1232 |
+
/*
|
| 1233 |
+
* 9.7.12.15. Parallel Synchronization and Communication Instructions: mbarrier
|
| 1234 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier
|
| 1235 |
+
*
|
| 1236 |
+
* Contained in: __cuda/ptx/parallel_synchronization_and_communication_instructions_mbarrier.h
|
| 1237 |
+
*/
|
| 1238 |
+
|
| 1239 |
+
// 9.7.12.15.18. Parallel Synchronization and Communication Instructions: tensormap.cp_fenceproxy
|
| 1240 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-tensormap-cp-fenceproxy
|
| 1241 |
+
|
| 1242 |
+
|
| 1243 |
+
/*
|
| 1244 |
+
* 9.7.13. Warp Level Matrix Multiply-Accumulate Instructions
|
| 1245 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-multiply-accumulate-instructions
|
| 1246 |
+
*
|
| 1247 |
+
*/
|
| 1248 |
+
|
| 1249 |
+
// 9.7.13.3.3. Warp-level Matrix Load Instruction: wmma.load
|
| 1250 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-load-instruction-wmma-load
|
| 1251 |
+
|
| 1252 |
+
// 9.7.13.3.4. Warp-level Matrix Store Instruction: wmma.store
|
| 1253 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-store-instruction-wmma-store
|
| 1254 |
+
|
| 1255 |
+
// 9.7.13.3.5. Warp-level Matrix Multiply-and-Accumulate Instruction: wmma.mma
|
| 1256 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-multiply-and-accumulate-instruction-wmma-mma
|
| 1257 |
+
|
| 1258 |
+
// 9.7.13.4.14. Multiply-and-Accumulate Instruction: mma
|
| 1259 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#multiply-and-accumulate-instruction-mma
|
| 1260 |
+
|
| 1261 |
+
// 9.7.13.4.15. Warp-level matrix load instruction: ldmatrix
|
| 1262 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-load-instruction-ldmatrix
|
| 1263 |
+
|
| 1264 |
+
// 9.7.13.4.16. Warp-level matrix store instruction: stmatrix
|
| 1265 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-store-instruction-stmatrix
|
| 1266 |
+
|
| 1267 |
+
// 9.7.13.4.17. Warp-level matrix transpose instruction: movmatrix
|
| 1268 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#warp-level-matrix-transpose-instruction-movmatrix
|
| 1269 |
+
|
| 1270 |
+
// 9.7.13.5.3. Multiply-and-Accumulate Instruction: mma.sp
|
| 1271 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#multiply-and-accumulate-instruction-mma-sp
|
| 1272 |
+
|
| 1273 |
+
|
| 1274 |
+
/*
|
| 1275 |
+
* 9.7.14. Asynchronous Warpgroup Level Matrix Multiply-Accumulate Instructions
|
| 1276 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-warpgroup-level-matrix-multiply-accumulate-instructions
|
| 1277 |
+
*
|
| 1278 |
+
*/
|
| 1279 |
+
|
| 1280 |
+
// 9.7.14.5.2. Asynchronous Multiply-and-Accumulate Instruction: wgmma.mma_async
|
| 1281 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-multiply-and-accumulate-instruction-wgmma-mma-async
|
| 1282 |
+
|
| 1283 |
+
// 9.7.14.6.4. Asynchronous Multiply-and-Accumulate Instruction: wgmma.mma_async.sp
|
| 1284 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-multiply-and-accumulate-instruction-wgmma-mma-async-sp
|
| 1285 |
+
|
| 1286 |
+
// 9.7.14.7.1. Asynchronous Multiply-and-Accumulate Instruction: wgmma.fence
|
| 1287 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-multiply-and-accumulate-instruction-wgmma-fence
|
| 1288 |
+
|
| 1289 |
+
// 9.7.14.7.2. Asynchronous Multiply-and-Accumulate Instruction: wgmma.commit_group
|
| 1290 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-multiply-and-accumulate-instruction-wgmma-commit-group
|
| 1291 |
+
|
| 1292 |
+
// 9.7.14.7.3. Asynchronous Multiply-and-Accumulate Instruction: wgmma.wait_group
|
| 1293 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#asynchronous-multiply-and-accumulate-instruction-wgmma-wait-group
|
| 1294 |
+
|
| 1295 |
+
|
| 1296 |
+
/*
|
| 1297 |
+
* 9.7.15. Stack Manipulation Instructions
|
| 1298 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#stack-manipulation-instructions
|
| 1299 |
+
*
|
| 1300 |
+
*/
|
| 1301 |
+
|
| 1302 |
+
// 9.7.15.1. Stack Manipulation Instructions: stacksave
|
| 1303 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#stack-manipulation-instructions-stacksave
|
| 1304 |
+
|
| 1305 |
+
// 9.7.15.2. Stack Manipulation Instructions: stackrestore
|
| 1306 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#stack-manipulation-instructions-stackrestore
|
| 1307 |
+
|
| 1308 |
+
// 9.7.15.3. Stack Manipulation Instructions: alloca
|
| 1309 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#stack-manipulation-instructions-alloca
|
| 1310 |
+
|
| 1311 |
+
|
| 1312 |
+
/*
|
| 1313 |
+
* 9.7.16. Video Instructions
|
| 1314 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#video-instructions
|
| 1315 |
+
*
|
| 1316 |
+
*/
|
| 1317 |
+
|
| 1318 |
+
// 9.7.16.1.1. Scalar Video Instructions: vadd, vsub, vabsdiff, vmin, vmax
|
| 1319 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#scalar-video-instructions-vadd-vsub-vabsdiff-vmin-vmax
|
| 1320 |
+
|
| 1321 |
+
// 9.7.16.1.2. Scalar Video Instructions: vshl, vshr
|
| 1322 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#scalar-video-instructions-vshl-vshr
|
| 1323 |
+
|
| 1324 |
+
// 9.7.16.1.3. Scalar Video Instructions: vmad
|
| 1325 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#scalar-video-instructions-vmad
|
| 1326 |
+
|
| 1327 |
+
// 9.7.16.1.4. Scalar Video Instructions: vset
|
| 1328 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#scalar-video-instructions-vset
|
| 1329 |
+
|
| 1330 |
+
|
| 1331 |
+
/*
|
| 1332 |
+
* 9.7.16.2. SIMD Video Instructions
|
| 1333 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#simd-video-instructions
|
| 1334 |
+
*
|
| 1335 |
+
*/
|
| 1336 |
+
|
| 1337 |
+
// 9.7.16.2.1. SIMD Video Instructions: vadd2, vsub2, vavrg2, vabsdiff2, vmin2, vmax2
|
| 1338 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#simd-video-instructions-vadd2-vsub2-vavrg2-vabsdiff2-vmin2-vmax2
|
| 1339 |
+
|
| 1340 |
+
// 9.7.16.2.2. SIMD Video Instructions: vset2
|
| 1341 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#simd-video-instructions-vset2
|
| 1342 |
+
|
| 1343 |
+
// 9.7.16.2.3. SIMD Video Instructions: vadd4, vsub4, vavrg4, vabsdiff4, vmin4, vmax4
|
| 1344 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#simd-video-instructions-vadd4-vsub4-vavrg4-vabsdiff4-vmin4-vmax4
|
| 1345 |
+
|
| 1346 |
+
// 9.7.16.2.4. SIMD Video Instructions: vset4
|
| 1347 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#simd-video-instructions-vset4
|
| 1348 |
+
|
| 1349 |
+
|
| 1350 |
+
/*
|
| 1351 |
+
* 9.7.17. Miscellaneous Instructions
|
| 1352 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions
|
| 1353 |
+
*
|
| 1354 |
+
*/
|
| 1355 |
+
|
| 1356 |
+
// 9.7.17.1. Miscellaneous Instructions: brkpt
|
| 1357 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-brkpt
|
| 1358 |
+
|
| 1359 |
+
// 9.7.17.2. Miscellaneous Instructions: nanosleep
|
| 1360 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-nanosleep
|
| 1361 |
+
|
| 1362 |
+
// 9.7.17.3. Miscellaneous Instructions: pmevent
|
| 1363 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-pmevent
|
| 1364 |
+
|
| 1365 |
+
// 9.7.17.4. Miscellaneous Instructions: trap
|
| 1366 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-trap
|
| 1367 |
+
|
| 1368 |
+
// 9.7.17.5. Miscellaneous Instructions: setmaxnreg
|
| 1369 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#miscellaneous-instructions-setmaxnreg
|
| 1370 |
+
|
| 1371 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_PTX
|
| 1372 |
+
|
| 1373 |
+
#endif // _LIBCUDACXX___CUDA_PTX_H
|
cuda_toolkit/include/__cuda/ptx/parallel_synchronization_and_communication_instructions_mbarrier.h
ADDED
|
@@ -0,0 +1,1070 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 5 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 6 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 7 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 8 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 9 |
+
//
|
| 10 |
+
//===----------------------------------------------------------------------===//
|
| 11 |
+
|
| 12 |
+
#ifndef _CUDA_PTX_PARALLEL_SYNCHRONIZATION_AND_COMMUNICATION_INSTRUCTIONS_MBARRIER_H_
|
| 13 |
+
#define _CUDA_PTX_PARALLEL_SYNCHRONIZATION_AND_COMMUNICATION_INSTRUCTIONS_MBARRIER_H_
|
| 14 |
+
|
| 15 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 16 |
+
# pragma GCC system_header
|
| 17 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 18 |
+
# pragma clang system_header
|
| 19 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 20 |
+
# pragma system_header
|
| 21 |
+
#endif // no system header
|
| 22 |
+
|
| 23 |
+
#include "ptx_dot_variants.h"
|
| 24 |
+
#include "ptx_helper_functions.h"
|
| 25 |
+
#include "../../cstdint"
|
| 26 |
+
|
| 27 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_PTX
|
| 28 |
+
|
| 29 |
+
/*
|
| 30 |
+
* 9.7.12.15. Parallel Synchronization and Communication Instructions: mbarrier
|
| 31 |
+
* https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier
|
| 32 |
+
*
|
| 33 |
+
*/
|
| 34 |
+
|
| 35 |
+
// 9.7.12.15.9. Parallel Synchronization and Communication Instructions: mbarrier.init
|
| 36 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-init
|
| 37 |
+
|
| 38 |
+
// 9.7.12.15.10. Parallel Synchronization and Communication Instructions: mbarrier.inval
|
| 39 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-inval
|
| 40 |
+
|
| 41 |
+
// 9.7.12.15.11. Parallel Synchronization and Communication Instructions: mbarrier.expect_tx
|
| 42 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-expect-tx
|
| 43 |
+
|
| 44 |
+
// 9.7.12.15.12. Parallel Synchronization and Communication Instructions: mbarrier.complete_tx
|
| 45 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-complete-tx
|
| 46 |
+
|
| 47 |
+
// 9.7.12.15.13. Parallel Synchronization and Communication Instructions: mbarrier.arrive
|
| 48 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive
|
| 49 |
+
|
| 50 |
+
/*
|
| 51 |
+
PTX ISA docs:
|
| 52 |
+
|
| 53 |
+
// mbarrier.arrive:
|
| 54 |
+
mbarrier.arrive{.shared}.b64 state, [addr]; // 1. PTX ISA 70, SM_80
|
| 55 |
+
mbarrier.arrive{.shared{::cta}}.b64 state, [addr]{, count}; // 2. PTX ISA 78, SM_90 (due to count)
|
| 56 |
+
|
| 57 |
+
mbarrier.arrive{.sem}{.scope}{.shared{::cta}}.b64 state, [addr]{, count}; // 3. PTX ISA 80, SM_90 (some variants are SM_80, but are covered by 1)
|
| 58 |
+
mbarrier.arrive{.sem}{.scope}{.shared::cluster}.b64 _, [addr] {,count} // 4. PTX ISA 80, SM_90
|
| 59 |
+
|
| 60 |
+
.sem = { .release }
|
| 61 |
+
.scope = { .cta, .cluster }
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
// mbarrier.arrive.noComplete:
|
| 65 |
+
mbarrier.arrive.noComplete{.shared}.b64 state, [addr], count; // 5. PTX ISA 70, SM_80
|
| 66 |
+
mbarrier.arrive.noComplete{.shared{::cta}}.b64 state, [addr], count; // 6. PTX ISA 78, Not exposed. Just a spelling change (shared -> shared::cta)
|
| 67 |
+
mbarrier.arrive.noComplete{.sem}{.cta}{.shared{::cta}}.b64 state, [addr], count; // 7. PTX ISA 80, Not exposed. Adds .release, and .cta scope.
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
// mbarrier.arrive.expect_tx:
|
| 71 |
+
mbarrier.arrive.expect_tx{.sem}{.scope}{.shared{::cta}}.b64 state, [addr], tx_count; // 8. PTX ISA 80, SM_90
|
| 72 |
+
mbarrier.arrive.expect_tx{.sem}{.scope}{.shared::cluster}.b64 _, [addr], tx_count; // 9. PTX ISA 80, SM_90
|
| 73 |
+
|
| 74 |
+
.sem = { .release }
|
| 75 |
+
.scope = { .cta, .cluster }
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
Corresponding Exposure:
|
| 79 |
+
|
| 80 |
+
// mbarrier_arrive:
|
| 81 |
+
mbarrier.arrive.shared.b64 state, [addr]; // 1. PTX ISA 70, SM_80, !memory
|
| 82 |
+
// count is non-optional, otherwise 3 would not be distinguishable from 1
|
| 83 |
+
mbarrier.arrive.shared::cta.b64 state, [addr], count; // 2. PTX ISA 78, SM_90, !memory
|
| 84 |
+
mbarrier.arrive{.sem}{.scope}{.space}.b64 state, [addr]; // 3a. PTX ISA 80, SM_90, !memory
|
| 85 |
+
.space = { .shared::cta}
|
| 86 |
+
.sem = { .release }
|
| 87 |
+
.scope = { .cta, .cluster }
|
| 88 |
+
|
| 89 |
+
mbarrier.arrive{.sem}{.scope}{.space}.b64 state, [addr], count; // 3b. PTX ISA 80, SM_90, !memory
|
| 90 |
+
.space = { .shared::cta}
|
| 91 |
+
.sem = { .release }
|
| 92 |
+
.scope = { .cta, .cluster }
|
| 93 |
+
|
| 94 |
+
// NOTE: .scope=.cta is dropped on purpose
|
| 95 |
+
mbarrier.arrive{.sem}{.scope}{.space}.b64 _, [addr]; // 4a. PTX ISA 80, SM_90, !memory
|
| 96 |
+
.space = { .shared::cluster}
|
| 97 |
+
.sem = { .release }
|
| 98 |
+
.scope = { .cluster }
|
| 99 |
+
|
| 100 |
+
// NOTE: .scope=.cta is dropped on purpose
|
| 101 |
+
mbarrier.arrive{.sem}{.scope}{.space}.b64 _, [addr], count; // 4b. PTX ISA 80, SM_90, !memory
|
| 102 |
+
.space = { .shared::cluster}
|
| 103 |
+
.sem = { .release }
|
| 104 |
+
.scope = { .cluster }
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
// mbarrier_arrive_no_complete:
|
| 108 |
+
mbarrier.arrive.noComplete.shared.b64 state, [addr], count; // 5. PTX ISA 70, SM_80, !memory
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
mbarrier.arrive.expect_tx{.sem}{.scope}{.space}.b64 state, [addr], tx_count; // 8. PTX ISA 80, SM_90, !memory
|
| 112 |
+
.space = { .shared::cta }
|
| 113 |
+
.sem = { .release }
|
| 114 |
+
.scope = { .cta, .cluster }
|
| 115 |
+
|
| 116 |
+
// NOTE: .scope=.cta is dropped on purpose
|
| 117 |
+
mbarrier.arrive.expect_tx{.sem}{.scope}{.space}.b64 _, [addr], tx_count; // 9. PTX ISA 80, SM_90, !memory
|
| 118 |
+
.space = { .shared::cluster }
|
| 119 |
+
.sem = { .release }
|
| 120 |
+
.scope = { .cluster }
|
| 121 |
+
|
| 122 |
+
*/
|
| 123 |
+
|
| 124 |
+
/*
|
| 125 |
+
// mbarrier.arrive.shared.b64 state, [addr]; // 1. PTX ISA 70, SM_80
|
| 126 |
+
template <typename=void>
|
| 127 |
+
__device__ static inline uint64_t mbarrier_arrive(
|
| 128 |
+
uint64_t* addr);
|
| 129 |
+
*/
|
| 130 |
+
#if __cccl_ptx_isa >= 700
|
| 131 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_80__();
|
| 132 |
+
template <typename=void>
|
| 133 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive(
|
| 134 |
+
_CUDA_VSTD::uint64_t* __addr)
|
| 135 |
+
{
|
| 136 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 137 |
+
_CUDA_VSTD::uint64_t __state;
|
| 138 |
+
asm (
|
| 139 |
+
"mbarrier.arrive.shared.b64 %0, [%1]; // 1. "
|
| 140 |
+
: "=l"(__state)
|
| 141 |
+
: "r"(__as_ptr_smem(__addr))
|
| 142 |
+
: "memory"
|
| 143 |
+
);
|
| 144 |
+
return __state;
|
| 145 |
+
),(
|
| 146 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 147 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_80__();
|
| 148 |
+
));
|
| 149 |
+
}
|
| 150 |
+
#endif // __cccl_ptx_isa >= 700
|
| 151 |
+
|
| 152 |
+
/*
|
| 153 |
+
// mbarrier.arrive.shared::cta.b64 state, [addr], count; // 2. PTX ISA 78, SM_90
|
| 154 |
+
template <typename=void>
|
| 155 |
+
__device__ static inline uint64_t mbarrier_arrive(
|
| 156 |
+
uint64_t* addr,
|
| 157 |
+
const uint32_t& count);
|
| 158 |
+
*/
|
| 159 |
+
#if __cccl_ptx_isa >= 780
|
| 160 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 161 |
+
template <typename=void>
|
| 162 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive(
|
| 163 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 164 |
+
const _CUDA_VSTD::uint32_t& __count)
|
| 165 |
+
{
|
| 166 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 167 |
+
_CUDA_VSTD::uint64_t __state;
|
| 168 |
+
asm (
|
| 169 |
+
"mbarrier.arrive.shared::cta.b64 %0, [%1], %2; // 2. "
|
| 170 |
+
: "=l"(__state)
|
| 171 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 172 |
+
"r"(__count)
|
| 173 |
+
: "memory"
|
| 174 |
+
);
|
| 175 |
+
return __state;
|
| 176 |
+
),(
|
| 177 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 178 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 179 |
+
));
|
| 180 |
+
}
|
| 181 |
+
#endif // __cccl_ptx_isa >= 780
|
| 182 |
+
|
| 183 |
+
/*
|
| 184 |
+
// mbarrier.arrive{.sem}{.scope}{.space}.b64 state, [addr]; // 3a. PTX ISA 80, SM_90
|
| 185 |
+
// .sem = { .release }
|
| 186 |
+
// .scope = { .cta, .cluster }
|
| 187 |
+
// .space = { .shared::cta }
|
| 188 |
+
template <cuda::ptx::dot_scope Scope>
|
| 189 |
+
__device__ static inline uint64_t mbarrier_arrive(
|
| 190 |
+
cuda::ptx::sem_release_t,
|
| 191 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 192 |
+
cuda::ptx::space_shared_t,
|
| 193 |
+
uint64_t* addr);
|
| 194 |
+
*/
|
| 195 |
+
#if __cccl_ptx_isa >= 800
|
| 196 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 197 |
+
template <dot_scope _Scope>
|
| 198 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive(
|
| 199 |
+
sem_release_t,
|
| 200 |
+
scope_t<_Scope> __scope,
|
| 201 |
+
space_shared_t,
|
| 202 |
+
_CUDA_VSTD::uint64_t* __addr)
|
| 203 |
+
{
|
| 204 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 205 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 206 |
+
// __space == space_shared (due to parameter type constraint)
|
| 207 |
+
|
| 208 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 209 |
+
_CUDA_VSTD::uint64_t __state;
|
| 210 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 211 |
+
asm (
|
| 212 |
+
"mbarrier.arrive.release.cta.shared.b64 %0, [%1]; // 3a. "
|
| 213 |
+
: "=l"(__state)
|
| 214 |
+
: "r"(__as_ptr_smem(__addr))
|
| 215 |
+
: "memory"
|
| 216 |
+
);
|
| 217 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 218 |
+
asm (
|
| 219 |
+
"mbarrier.arrive.release.cluster.shared.b64 %0, [%1]; // 3a. "
|
| 220 |
+
: "=l"(__state)
|
| 221 |
+
: "r"(__as_ptr_smem(__addr))
|
| 222 |
+
: "memory"
|
| 223 |
+
);
|
| 224 |
+
}
|
| 225 |
+
return __state;
|
| 226 |
+
),(
|
| 227 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 228 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 229 |
+
));
|
| 230 |
+
}
|
| 231 |
+
#endif // __cccl_ptx_isa >= 800
|
| 232 |
+
|
| 233 |
+
/*
|
| 234 |
+
// mbarrier.arrive{.sem}{.scope}{.space}.b64 state, [addr], count; // 3b. PTX ISA 80, SM_90
|
| 235 |
+
// .sem = { .release }
|
| 236 |
+
// .scope = { .cta, .cluster }
|
| 237 |
+
// .space = { .shared::cta }
|
| 238 |
+
template <cuda::ptx::dot_scope Scope>
|
| 239 |
+
__device__ static inline uint64_t mbarrier_arrive(
|
| 240 |
+
cuda::ptx::sem_release_t,
|
| 241 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 242 |
+
cuda::ptx::space_shared_t,
|
| 243 |
+
uint64_t* addr,
|
| 244 |
+
const uint32_t& count);
|
| 245 |
+
*/
|
| 246 |
+
#if __cccl_ptx_isa >= 800
|
| 247 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 248 |
+
template <dot_scope _Scope>
|
| 249 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive(
|
| 250 |
+
sem_release_t,
|
| 251 |
+
scope_t<_Scope> __scope,
|
| 252 |
+
space_shared_t,
|
| 253 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 254 |
+
const _CUDA_VSTD::uint32_t& __count)
|
| 255 |
+
{
|
| 256 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 257 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 258 |
+
// __space == space_shared (due to parameter type constraint)
|
| 259 |
+
|
| 260 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 261 |
+
_CUDA_VSTD::uint64_t __state;
|
| 262 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 263 |
+
asm (
|
| 264 |
+
"mbarrier.arrive.release.cta.shared.b64 %0, [%1], %2; // 3b. "
|
| 265 |
+
: "=l"(__state)
|
| 266 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 267 |
+
"r"(__count)
|
| 268 |
+
: "memory"
|
| 269 |
+
);
|
| 270 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 271 |
+
asm (
|
| 272 |
+
"mbarrier.arrive.release.cluster.shared.b64 %0, [%1], %2; // 3b. "
|
| 273 |
+
: "=l"(__state)
|
| 274 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 275 |
+
"r"(__count)
|
| 276 |
+
: "memory"
|
| 277 |
+
);
|
| 278 |
+
}
|
| 279 |
+
return __state;
|
| 280 |
+
),(
|
| 281 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 282 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 283 |
+
));
|
| 284 |
+
}
|
| 285 |
+
#endif // __cccl_ptx_isa >= 800
|
| 286 |
+
|
| 287 |
+
/*
|
| 288 |
+
// mbarrier.arrive{.sem}{.scope}{.space}.b64 _, [addr]; // 4a. PTX ISA 80, SM_90
|
| 289 |
+
// .sem = { .release }
|
| 290 |
+
// .scope = { .cluster }
|
| 291 |
+
// .space = { .shared::cluster }
|
| 292 |
+
template <typename=void>
|
| 293 |
+
__device__ static inline void mbarrier_arrive(
|
| 294 |
+
cuda::ptx::sem_release_t,
|
| 295 |
+
cuda::ptx::scope_cluster_t,
|
| 296 |
+
cuda::ptx::space_cluster_t,
|
| 297 |
+
uint64_t* addr);
|
| 298 |
+
*/
|
| 299 |
+
#if __cccl_ptx_isa >= 800
|
| 300 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 301 |
+
template <typename=void>
|
| 302 |
+
_LIBCUDACXX_DEVICE static inline void mbarrier_arrive(
|
| 303 |
+
sem_release_t,
|
| 304 |
+
scope_cluster_t,
|
| 305 |
+
space_cluster_t,
|
| 306 |
+
_CUDA_VSTD::uint64_t* __addr)
|
| 307 |
+
{
|
| 308 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 309 |
+
// __scope == scope_cluster (due to parameter type constraint)
|
| 310 |
+
// __space == space_cluster (due to parameter type constraint)
|
| 311 |
+
|
| 312 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 313 |
+
asm (
|
| 314 |
+
"mbarrier.arrive.release.cluster.shared::cluster.b64 _, [%0]; // 4a. "
|
| 315 |
+
:
|
| 316 |
+
: "r"(__as_ptr_smem(__addr))
|
| 317 |
+
: "memory"
|
| 318 |
+
);
|
| 319 |
+
|
| 320 |
+
),(
|
| 321 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 322 |
+
return __void__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 323 |
+
));
|
| 324 |
+
}
|
| 325 |
+
#endif // __cccl_ptx_isa >= 800
|
| 326 |
+
|
| 327 |
+
/*
|
| 328 |
+
// mbarrier.arrive{.sem}{.scope}{.space}.b64 _, [addr], count; // 4b. PTX ISA 80, SM_90
|
| 329 |
+
// .sem = { .release }
|
| 330 |
+
// .scope = { .cluster }
|
| 331 |
+
// .space = { .shared::cluster }
|
| 332 |
+
template <typename=void>
|
| 333 |
+
__device__ static inline void mbarrier_arrive(
|
| 334 |
+
cuda::ptx::sem_release_t,
|
| 335 |
+
cuda::ptx::scope_cluster_t,
|
| 336 |
+
cuda::ptx::space_cluster_t,
|
| 337 |
+
uint64_t* addr,
|
| 338 |
+
const uint32_t& count);
|
| 339 |
+
*/
|
| 340 |
+
#if __cccl_ptx_isa >= 800
|
| 341 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 342 |
+
template <typename=void>
|
| 343 |
+
_LIBCUDACXX_DEVICE static inline void mbarrier_arrive(
|
| 344 |
+
sem_release_t,
|
| 345 |
+
scope_cluster_t,
|
| 346 |
+
space_cluster_t,
|
| 347 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 348 |
+
const _CUDA_VSTD::uint32_t& __count)
|
| 349 |
+
{
|
| 350 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 351 |
+
// __scope == scope_cluster (due to parameter type constraint)
|
| 352 |
+
// __space == space_cluster (due to parameter type constraint)
|
| 353 |
+
|
| 354 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 355 |
+
asm (
|
| 356 |
+
"mbarrier.arrive.release.cluster.shared::cluster.b64 _, [%0], %1; // 4b. "
|
| 357 |
+
:
|
| 358 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 359 |
+
"r"(__count)
|
| 360 |
+
: "memory"
|
| 361 |
+
);
|
| 362 |
+
|
| 363 |
+
),(
|
| 364 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 365 |
+
return __void__cuda_ptx_mbarrier_arrive_is_not_supported_before_SM_90__();
|
| 366 |
+
));
|
| 367 |
+
}
|
| 368 |
+
#endif // __cccl_ptx_isa >= 800
|
| 369 |
+
|
| 370 |
+
/*
|
| 371 |
+
// mbarrier.arrive.noComplete.shared.b64 state, [addr], count; // 5. PTX ISA 70, SM_80
|
| 372 |
+
template <typename=void>
|
| 373 |
+
__device__ static inline uint64_t mbarrier_arrive_no_complete(
|
| 374 |
+
uint64_t* addr,
|
| 375 |
+
const uint32_t& count);
|
| 376 |
+
*/
|
| 377 |
+
#if __cccl_ptx_isa >= 700
|
| 378 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_no_complete_is_not_supported_before_SM_80__();
|
| 379 |
+
template <typename=void>
|
| 380 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive_no_complete(
|
| 381 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 382 |
+
const _CUDA_VSTD::uint32_t& __count)
|
| 383 |
+
{
|
| 384 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 385 |
+
_CUDA_VSTD::uint64_t __state;
|
| 386 |
+
asm (
|
| 387 |
+
"mbarrier.arrive.noComplete.shared.b64 %0, [%1], %2; // 5. "
|
| 388 |
+
: "=l"(__state)
|
| 389 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 390 |
+
"r"(__count)
|
| 391 |
+
: "memory"
|
| 392 |
+
);
|
| 393 |
+
return __state;
|
| 394 |
+
),(
|
| 395 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 396 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_no_complete_is_not_supported_before_SM_80__();
|
| 397 |
+
));
|
| 398 |
+
}
|
| 399 |
+
#endif // __cccl_ptx_isa >= 700
|
| 400 |
+
|
| 401 |
+
/*
|
| 402 |
+
// mbarrier.arrive.expect_tx{.sem}{.scope}{.space}.b64 state, [addr], tx_count; // 8. PTX ISA 80, SM_90
|
| 403 |
+
// .sem = { .release }
|
| 404 |
+
// .scope = { .cta, .cluster }
|
| 405 |
+
// .space = { .shared::cta }
|
| 406 |
+
template <cuda::ptx::dot_scope Scope>
|
| 407 |
+
__device__ static inline uint64_t mbarrier_arrive_expect_tx(
|
| 408 |
+
cuda::ptx::sem_release_t,
|
| 409 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 410 |
+
cuda::ptx::space_shared_t,
|
| 411 |
+
uint64_t* addr,
|
| 412 |
+
const uint32_t& tx_count);
|
| 413 |
+
*/
|
| 414 |
+
#if __cccl_ptx_isa >= 800
|
| 415 |
+
extern "C" _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_expect_tx_is_not_supported_before_SM_90__();
|
| 416 |
+
template <dot_scope _Scope>
|
| 417 |
+
_LIBCUDACXX_DEVICE static inline _CUDA_VSTD::uint64_t mbarrier_arrive_expect_tx(
|
| 418 |
+
sem_release_t,
|
| 419 |
+
scope_t<_Scope> __scope,
|
| 420 |
+
space_shared_t,
|
| 421 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 422 |
+
const _CUDA_VSTD::uint32_t& __tx_count)
|
| 423 |
+
{
|
| 424 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 425 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 426 |
+
// __space == space_shared (due to parameter type constraint)
|
| 427 |
+
|
| 428 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 429 |
+
_CUDA_VSTD::uint64_t __state;
|
| 430 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 431 |
+
asm (
|
| 432 |
+
"mbarrier.arrive.expect_tx.release.cta.shared.b64 %0, [%1], %2; // 8. "
|
| 433 |
+
: "=l"(__state)
|
| 434 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 435 |
+
"r"(__tx_count)
|
| 436 |
+
: "memory"
|
| 437 |
+
);
|
| 438 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 439 |
+
asm (
|
| 440 |
+
"mbarrier.arrive.expect_tx.release.cluster.shared.b64 %0, [%1], %2; // 8. "
|
| 441 |
+
: "=l"(__state)
|
| 442 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 443 |
+
"r"(__tx_count)
|
| 444 |
+
: "memory"
|
| 445 |
+
);
|
| 446 |
+
}
|
| 447 |
+
return __state;
|
| 448 |
+
),(
|
| 449 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 450 |
+
return ___cuda_vstd_uint64_t__cuda_ptx_mbarrier_arrive_expect_tx_is_not_supported_before_SM_90__();
|
| 451 |
+
));
|
| 452 |
+
}
|
| 453 |
+
#endif // __cccl_ptx_isa >= 800
|
| 454 |
+
|
| 455 |
+
/*
|
| 456 |
+
// mbarrier.arrive.expect_tx{.sem}{.scope}{.space}.b64 _, [addr], tx_count; // 9. PTX ISA 80, SM_90
|
| 457 |
+
// .sem = { .release }
|
| 458 |
+
// .scope = { .cluster }
|
| 459 |
+
// .space = { .shared::cluster }
|
| 460 |
+
template <typename=void>
|
| 461 |
+
__device__ static inline void mbarrier_arrive_expect_tx(
|
| 462 |
+
cuda::ptx::sem_release_t,
|
| 463 |
+
cuda::ptx::scope_cluster_t,
|
| 464 |
+
cuda::ptx::space_cluster_t,
|
| 465 |
+
uint64_t* addr,
|
| 466 |
+
const uint32_t& tx_count);
|
| 467 |
+
*/
|
| 468 |
+
#if __cccl_ptx_isa >= 800
|
| 469 |
+
extern "C" _LIBCUDACXX_DEVICE void __void__cuda_ptx_mbarrier_arrive_expect_tx_is_not_supported_before_SM_90__();
|
| 470 |
+
template <typename=void>
|
| 471 |
+
_LIBCUDACXX_DEVICE static inline void mbarrier_arrive_expect_tx(
|
| 472 |
+
sem_release_t,
|
| 473 |
+
scope_cluster_t,
|
| 474 |
+
space_cluster_t,
|
| 475 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 476 |
+
const _CUDA_VSTD::uint32_t& __tx_count)
|
| 477 |
+
{
|
| 478 |
+
// __sem == sem_release (due to parameter type constraint)
|
| 479 |
+
// __scope == scope_cluster (due to parameter type constraint)
|
| 480 |
+
// __space == space_cluster (due to parameter type constraint)
|
| 481 |
+
|
| 482 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 483 |
+
asm (
|
| 484 |
+
"mbarrier.arrive.expect_tx.release.cluster.shared::cluster.b64 _, [%0], %1; // 9. "
|
| 485 |
+
:
|
| 486 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 487 |
+
"r"(__tx_count)
|
| 488 |
+
: "memory"
|
| 489 |
+
);
|
| 490 |
+
|
| 491 |
+
),(
|
| 492 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 493 |
+
return __void__cuda_ptx_mbarrier_arrive_expect_tx_is_not_supported_before_SM_90__();
|
| 494 |
+
));
|
| 495 |
+
}
|
| 496 |
+
#endif // __cccl_ptx_isa >= 800
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
// 9.7.12.15.14. Parallel Synchronization and Communication Instructions: mbarrier.arrive_drop
|
| 502 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-arrive-drop
|
| 503 |
+
|
| 504 |
+
// 9.7.12.15.15. Parallel Synchronization and Communication Instructions: cp.async.mbarrier.arrive
|
| 505 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-cp-async-mbarrier-arrive
|
| 506 |
+
|
| 507 |
+
// 9.7.12.15.16. Parallel Synchronization and Communication Instructions: mbarrier.test_wait/mbarrier.try_wait
|
| 508 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-test-wait-mbarrier-try-wait
|
| 509 |
+
|
| 510 |
+
/*
|
| 511 |
+
// mbarrier.test_wait.shared.b64 waitComplete, [addr], state; // 1. PTX ISA 70, SM_80
|
| 512 |
+
template <typename=void>
|
| 513 |
+
__device__ static inline bool mbarrier_test_wait(
|
| 514 |
+
uint64_t* addr,
|
| 515 |
+
const uint64_t& state);
|
| 516 |
+
*/
|
| 517 |
+
#if __cccl_ptx_isa >= 700
|
| 518 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_test_wait_is_not_supported_before_SM_80__();
|
| 519 |
+
template <typename=void>
|
| 520 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_test_wait(
|
| 521 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 522 |
+
const _CUDA_VSTD::uint64_t& __state)
|
| 523 |
+
{
|
| 524 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 525 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 526 |
+
asm (
|
| 527 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 528 |
+
"mbarrier.test_wait.shared.b64 P_OUT, [%1], %2; // 1. \n\t"
|
| 529 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 530 |
+
"}"
|
| 531 |
+
: "=r"(__waitComplete)
|
| 532 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 533 |
+
"l"(__state)
|
| 534 |
+
: "memory"
|
| 535 |
+
);
|
| 536 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 537 |
+
),(
|
| 538 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 539 |
+
return __bool__cuda_ptx_mbarrier_test_wait_is_not_supported_before_SM_80__();
|
| 540 |
+
));
|
| 541 |
+
}
|
| 542 |
+
#endif // __cccl_ptx_isa >= 700
|
| 543 |
+
|
| 544 |
+
/*
|
| 545 |
+
// mbarrier.test_wait{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], state; // 2. PTX ISA 80, SM_90
|
| 546 |
+
// .sem = { .acquire }
|
| 547 |
+
// .scope = { .cta, .cluster }
|
| 548 |
+
template <cuda::ptx::dot_scope Scope>
|
| 549 |
+
__device__ static inline bool mbarrier_test_wait(
|
| 550 |
+
cuda::ptx::sem_acquire_t,
|
| 551 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 552 |
+
uint64_t* addr,
|
| 553 |
+
const uint64_t& state);
|
| 554 |
+
*/
|
| 555 |
+
#if __cccl_ptx_isa >= 800
|
| 556 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_test_wait_is_not_supported_before_SM_90__();
|
| 557 |
+
template <dot_scope _Scope>
|
| 558 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_test_wait(
|
| 559 |
+
sem_acquire_t,
|
| 560 |
+
scope_t<_Scope> __scope,
|
| 561 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 562 |
+
const _CUDA_VSTD::uint64_t& __state)
|
| 563 |
+
{
|
| 564 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 565 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 566 |
+
|
| 567 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 568 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 569 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 570 |
+
asm (
|
| 571 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 572 |
+
"mbarrier.test_wait.acquire.cta.shared::cta.b64 P_OUT, [%1], %2; // 2. \n\t"
|
| 573 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 574 |
+
"}"
|
| 575 |
+
: "=r"(__waitComplete)
|
| 576 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 577 |
+
"l"(__state)
|
| 578 |
+
: "memory"
|
| 579 |
+
);
|
| 580 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 581 |
+
asm (
|
| 582 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 583 |
+
"mbarrier.test_wait.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2; // 2. \n\t"
|
| 584 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 585 |
+
"}"
|
| 586 |
+
: "=r"(__waitComplete)
|
| 587 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 588 |
+
"l"(__state)
|
| 589 |
+
: "memory"
|
| 590 |
+
);
|
| 591 |
+
}
|
| 592 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 593 |
+
),(
|
| 594 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 595 |
+
return __bool__cuda_ptx_mbarrier_test_wait_is_not_supported_before_SM_90__();
|
| 596 |
+
));
|
| 597 |
+
}
|
| 598 |
+
#endif // __cccl_ptx_isa >= 800
|
| 599 |
+
|
| 600 |
+
/*
|
| 601 |
+
// mbarrier.test_wait.parity.shared.b64 waitComplete, [addr], phaseParity; // 3. PTX ISA 71, SM_80
|
| 602 |
+
template <typename=void>
|
| 603 |
+
__device__ static inline bool mbarrier_test_wait_parity(
|
| 604 |
+
uint64_t* addr,
|
| 605 |
+
const uint32_t& phaseParity);
|
| 606 |
+
*/
|
| 607 |
+
#if __cccl_ptx_isa >= 710
|
| 608 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_test_wait_parity_is_not_supported_before_SM_80__();
|
| 609 |
+
template <typename=void>
|
| 610 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_test_wait_parity(
|
| 611 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 612 |
+
const _CUDA_VSTD::uint32_t& __phaseParity)
|
| 613 |
+
{
|
| 614 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_80,(
|
| 615 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 616 |
+
asm (
|
| 617 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 618 |
+
"mbarrier.test_wait.parity.shared.b64 P_OUT, [%1], %2; // 3. \n\t"
|
| 619 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 620 |
+
"}"
|
| 621 |
+
: "=r"(__waitComplete)
|
| 622 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 623 |
+
"r"(__phaseParity)
|
| 624 |
+
: "memory"
|
| 625 |
+
);
|
| 626 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 627 |
+
),(
|
| 628 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 629 |
+
return __bool__cuda_ptx_mbarrier_test_wait_parity_is_not_supported_before_SM_80__();
|
| 630 |
+
));
|
| 631 |
+
}
|
| 632 |
+
#endif // __cccl_ptx_isa >= 710
|
| 633 |
+
|
| 634 |
+
/*
|
| 635 |
+
// mbarrier.test_wait.parity{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], phaseParity; // 4. PTX ISA 80, SM_90
|
| 636 |
+
// .sem = { .acquire }
|
| 637 |
+
// .scope = { .cta, .cluster }
|
| 638 |
+
template <cuda::ptx::dot_scope Scope>
|
| 639 |
+
__device__ static inline bool mbarrier_test_wait_parity(
|
| 640 |
+
cuda::ptx::sem_acquire_t,
|
| 641 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 642 |
+
uint64_t* addr,
|
| 643 |
+
const uint32_t& phaseParity);
|
| 644 |
+
*/
|
| 645 |
+
#if __cccl_ptx_isa >= 800
|
| 646 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_test_wait_parity_is_not_supported_before_SM_90__();
|
| 647 |
+
template <dot_scope _Scope>
|
| 648 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_test_wait_parity(
|
| 649 |
+
sem_acquire_t,
|
| 650 |
+
scope_t<_Scope> __scope,
|
| 651 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 652 |
+
const _CUDA_VSTD::uint32_t& __phaseParity)
|
| 653 |
+
{
|
| 654 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 655 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 656 |
+
|
| 657 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 658 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 659 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 660 |
+
asm (
|
| 661 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 662 |
+
"mbarrier.test_wait.parity.acquire.cta.shared::cta.b64 P_OUT, [%1], %2; // 4. \n\t"
|
| 663 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 664 |
+
"}"
|
| 665 |
+
: "=r"(__waitComplete)
|
| 666 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 667 |
+
"r"(__phaseParity)
|
| 668 |
+
: "memory"
|
| 669 |
+
);
|
| 670 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 671 |
+
asm (
|
| 672 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 673 |
+
"mbarrier.test_wait.parity.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2; // 4. \n\t"
|
| 674 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 675 |
+
"}"
|
| 676 |
+
: "=r"(__waitComplete)
|
| 677 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 678 |
+
"r"(__phaseParity)
|
| 679 |
+
: "memory"
|
| 680 |
+
);
|
| 681 |
+
}
|
| 682 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 683 |
+
),(
|
| 684 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 685 |
+
return __bool__cuda_ptx_mbarrier_test_wait_parity_is_not_supported_before_SM_90__();
|
| 686 |
+
));
|
| 687 |
+
}
|
| 688 |
+
#endif // __cccl_ptx_isa >= 800
|
| 689 |
+
|
| 690 |
+
/*
|
| 691 |
+
// mbarrier.try_wait.shared::cta.b64 waitComplete, [addr], state; // 5a. PTX ISA 78, SM_90
|
| 692 |
+
template <typename=void>
|
| 693 |
+
__device__ static inline bool mbarrier_try_wait(
|
| 694 |
+
uint64_t* addr,
|
| 695 |
+
const uint64_t& state);
|
| 696 |
+
*/
|
| 697 |
+
#if __cccl_ptx_isa >= 780
|
| 698 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 699 |
+
template <typename=void>
|
| 700 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait(
|
| 701 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 702 |
+
const _CUDA_VSTD::uint64_t& __state)
|
| 703 |
+
{
|
| 704 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 705 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 706 |
+
asm (
|
| 707 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 708 |
+
"mbarrier.try_wait.shared::cta.b64 P_OUT, [%1], %2; // 5a. \n\t"
|
| 709 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 710 |
+
"}"
|
| 711 |
+
: "=r"(__waitComplete)
|
| 712 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 713 |
+
"l"(__state)
|
| 714 |
+
: "memory"
|
| 715 |
+
);
|
| 716 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 717 |
+
),(
|
| 718 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 719 |
+
return __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 720 |
+
));
|
| 721 |
+
}
|
| 722 |
+
#endif // __cccl_ptx_isa >= 780
|
| 723 |
+
|
| 724 |
+
/*
|
| 725 |
+
// mbarrier.try_wait.shared::cta.b64 waitComplete, [addr], state, suspendTimeHint; // 5b. PTX ISA 78, SM_90
|
| 726 |
+
template <typename=void>
|
| 727 |
+
__device__ static inline bool mbarrier_try_wait(
|
| 728 |
+
uint64_t* addr,
|
| 729 |
+
const uint64_t& state,
|
| 730 |
+
const uint32_t& suspendTimeHint);
|
| 731 |
+
*/
|
| 732 |
+
#if __cccl_ptx_isa >= 780
|
| 733 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 734 |
+
template <typename=void>
|
| 735 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait(
|
| 736 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 737 |
+
const _CUDA_VSTD::uint64_t& __state,
|
| 738 |
+
const _CUDA_VSTD::uint32_t& __suspendTimeHint)
|
| 739 |
+
{
|
| 740 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 741 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 742 |
+
asm (
|
| 743 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 744 |
+
"mbarrier.try_wait.shared::cta.b64 P_OUT, [%1], %2, %3; // 5b. \n\t"
|
| 745 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 746 |
+
"}"
|
| 747 |
+
: "=r"(__waitComplete)
|
| 748 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 749 |
+
"l"(__state),
|
| 750 |
+
"r"(__suspendTimeHint)
|
| 751 |
+
: "memory"
|
| 752 |
+
);
|
| 753 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 754 |
+
),(
|
| 755 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 756 |
+
return __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 757 |
+
));
|
| 758 |
+
}
|
| 759 |
+
#endif // __cccl_ptx_isa >= 780
|
| 760 |
+
|
| 761 |
+
/*
|
| 762 |
+
// mbarrier.try_wait{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], state; // 6a. PTX ISA 80, SM_90
|
| 763 |
+
// .sem = { .acquire }
|
| 764 |
+
// .scope = { .cta, .cluster }
|
| 765 |
+
template <cuda::ptx::dot_scope Scope>
|
| 766 |
+
__device__ static inline bool mbarrier_try_wait(
|
| 767 |
+
cuda::ptx::sem_acquire_t,
|
| 768 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 769 |
+
uint64_t* addr,
|
| 770 |
+
const uint64_t& state);
|
| 771 |
+
*/
|
| 772 |
+
#if __cccl_ptx_isa >= 800
|
| 773 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 774 |
+
template <dot_scope _Scope>
|
| 775 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait(
|
| 776 |
+
sem_acquire_t,
|
| 777 |
+
scope_t<_Scope> __scope,
|
| 778 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 779 |
+
const _CUDA_VSTD::uint64_t& __state)
|
| 780 |
+
{
|
| 781 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 782 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 783 |
+
|
| 784 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 785 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 786 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 787 |
+
asm (
|
| 788 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 789 |
+
"mbarrier.try_wait.acquire.cta.shared::cta.b64 P_OUT, [%1], %2; // 6a. \n\t"
|
| 790 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 791 |
+
"}"
|
| 792 |
+
: "=r"(__waitComplete)
|
| 793 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 794 |
+
"l"(__state)
|
| 795 |
+
: "memory"
|
| 796 |
+
);
|
| 797 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 798 |
+
asm (
|
| 799 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 800 |
+
"mbarrier.try_wait.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2; // 6a. \n\t"
|
| 801 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 802 |
+
"}"
|
| 803 |
+
: "=r"(__waitComplete)
|
| 804 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 805 |
+
"l"(__state)
|
| 806 |
+
: "memory"
|
| 807 |
+
);
|
| 808 |
+
}
|
| 809 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 810 |
+
),(
|
| 811 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 812 |
+
return __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 813 |
+
));
|
| 814 |
+
}
|
| 815 |
+
#endif // __cccl_ptx_isa >= 800
|
| 816 |
+
|
| 817 |
+
/*
|
| 818 |
+
// mbarrier.try_wait{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], state , suspendTimeHint; // 6b. PTX ISA 80, SM_90
|
| 819 |
+
// .sem = { .acquire }
|
| 820 |
+
// .scope = { .cta, .cluster }
|
| 821 |
+
template <cuda::ptx::dot_scope Scope>
|
| 822 |
+
__device__ static inline bool mbarrier_try_wait(
|
| 823 |
+
cuda::ptx::sem_acquire_t,
|
| 824 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 825 |
+
uint64_t* addr,
|
| 826 |
+
const uint64_t& state,
|
| 827 |
+
const uint32_t& suspendTimeHint);
|
| 828 |
+
*/
|
| 829 |
+
#if __cccl_ptx_isa >= 800
|
| 830 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 831 |
+
template <dot_scope _Scope>
|
| 832 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait(
|
| 833 |
+
sem_acquire_t,
|
| 834 |
+
scope_t<_Scope> __scope,
|
| 835 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 836 |
+
const _CUDA_VSTD::uint64_t& __state,
|
| 837 |
+
const _CUDA_VSTD::uint32_t& __suspendTimeHint)
|
| 838 |
+
{
|
| 839 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 840 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 841 |
+
|
| 842 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 843 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 844 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 845 |
+
asm (
|
| 846 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 847 |
+
"mbarrier.try_wait.acquire.cta.shared::cta.b64 P_OUT, [%1], %2 , %3; // 6b. \n\t"
|
| 848 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 849 |
+
"}"
|
| 850 |
+
: "=r"(__waitComplete)
|
| 851 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 852 |
+
"l"(__state),
|
| 853 |
+
"r"(__suspendTimeHint)
|
| 854 |
+
: "memory"
|
| 855 |
+
);
|
| 856 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 857 |
+
asm (
|
| 858 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 859 |
+
"mbarrier.try_wait.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2 , %3; // 6b. \n\t"
|
| 860 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 861 |
+
"}"
|
| 862 |
+
: "=r"(__waitComplete)
|
| 863 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 864 |
+
"l"(__state),
|
| 865 |
+
"r"(__suspendTimeHint)
|
| 866 |
+
: "memory"
|
| 867 |
+
);
|
| 868 |
+
}
|
| 869 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 870 |
+
),(
|
| 871 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 872 |
+
return __bool__cuda_ptx_mbarrier_try_wait_is_not_supported_before_SM_90__();
|
| 873 |
+
));
|
| 874 |
+
}
|
| 875 |
+
#endif // __cccl_ptx_isa >= 800
|
| 876 |
+
|
| 877 |
+
/*
|
| 878 |
+
// mbarrier.try_wait.parity.shared::cta.b64 waitComplete, [addr], phaseParity; // 7a. PTX ISA 78, SM_90
|
| 879 |
+
template <typename=void>
|
| 880 |
+
__device__ static inline bool mbarrier_try_wait_parity(
|
| 881 |
+
uint64_t* addr,
|
| 882 |
+
const uint32_t& phaseParity);
|
| 883 |
+
*/
|
| 884 |
+
#if __cccl_ptx_isa >= 780
|
| 885 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 886 |
+
template <typename=void>
|
| 887 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait_parity(
|
| 888 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 889 |
+
const _CUDA_VSTD::uint32_t& __phaseParity)
|
| 890 |
+
{
|
| 891 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 892 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 893 |
+
asm (
|
| 894 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 895 |
+
"mbarrier.try_wait.parity.shared::cta.b64 P_OUT, [%1], %2; // 7a. \n\t"
|
| 896 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 897 |
+
"}"
|
| 898 |
+
: "=r"(__waitComplete)
|
| 899 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 900 |
+
"r"(__phaseParity)
|
| 901 |
+
: "memory"
|
| 902 |
+
);
|
| 903 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 904 |
+
),(
|
| 905 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 906 |
+
return __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 907 |
+
));
|
| 908 |
+
}
|
| 909 |
+
#endif // __cccl_ptx_isa >= 780
|
| 910 |
+
|
| 911 |
+
/*
|
| 912 |
+
// mbarrier.try_wait.parity.shared::cta.b64 waitComplete, [addr], phaseParity, suspendTimeHint; // 7b. PTX ISA 78, SM_90
|
| 913 |
+
template <typename=void>
|
| 914 |
+
__device__ static inline bool mbarrier_try_wait_parity(
|
| 915 |
+
uint64_t* addr,
|
| 916 |
+
const uint32_t& phaseParity,
|
| 917 |
+
const uint32_t& suspendTimeHint);
|
| 918 |
+
*/
|
| 919 |
+
#if __cccl_ptx_isa >= 780
|
| 920 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 921 |
+
template <typename=void>
|
| 922 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait_parity(
|
| 923 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 924 |
+
const _CUDA_VSTD::uint32_t& __phaseParity,
|
| 925 |
+
const _CUDA_VSTD::uint32_t& __suspendTimeHint)
|
| 926 |
+
{
|
| 927 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 928 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 929 |
+
asm (
|
| 930 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 931 |
+
"mbarrier.try_wait.parity.shared::cta.b64 P_OUT, [%1], %2, %3; // 7b. \n\t"
|
| 932 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 933 |
+
"}"
|
| 934 |
+
: "=r"(__waitComplete)
|
| 935 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 936 |
+
"r"(__phaseParity),
|
| 937 |
+
"r"(__suspendTimeHint)
|
| 938 |
+
: "memory"
|
| 939 |
+
);
|
| 940 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 941 |
+
),(
|
| 942 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 943 |
+
return __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 944 |
+
));
|
| 945 |
+
}
|
| 946 |
+
#endif // __cccl_ptx_isa >= 780
|
| 947 |
+
|
| 948 |
+
/*
|
| 949 |
+
// mbarrier.try_wait.parity{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], phaseParity; // 8a. PTX ISA 80, SM_90
|
| 950 |
+
// .sem = { .acquire }
|
| 951 |
+
// .scope = { .cta, .cluster }
|
| 952 |
+
template <cuda::ptx::dot_scope Scope>
|
| 953 |
+
__device__ static inline bool mbarrier_try_wait_parity(
|
| 954 |
+
cuda::ptx::sem_acquire_t,
|
| 955 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 956 |
+
uint64_t* addr,
|
| 957 |
+
const uint32_t& phaseParity);
|
| 958 |
+
*/
|
| 959 |
+
#if __cccl_ptx_isa >= 800
|
| 960 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 961 |
+
template <dot_scope _Scope>
|
| 962 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait_parity(
|
| 963 |
+
sem_acquire_t,
|
| 964 |
+
scope_t<_Scope> __scope,
|
| 965 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 966 |
+
const _CUDA_VSTD::uint32_t& __phaseParity)
|
| 967 |
+
{
|
| 968 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 969 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 970 |
+
|
| 971 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 972 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 973 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 974 |
+
asm (
|
| 975 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 976 |
+
"mbarrier.try_wait.parity.acquire.cta.shared::cta.b64 P_OUT, [%1], %2; // 8a. \n\t"
|
| 977 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 978 |
+
"}"
|
| 979 |
+
: "=r"(__waitComplete)
|
| 980 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 981 |
+
"r"(__phaseParity)
|
| 982 |
+
: "memory"
|
| 983 |
+
);
|
| 984 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 985 |
+
asm (
|
| 986 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 987 |
+
"mbarrier.try_wait.parity.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2; // 8a. \n\t"
|
| 988 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 989 |
+
"}"
|
| 990 |
+
: "=r"(__waitComplete)
|
| 991 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 992 |
+
"r"(__phaseParity)
|
| 993 |
+
: "memory"
|
| 994 |
+
);
|
| 995 |
+
}
|
| 996 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 997 |
+
),(
|
| 998 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 999 |
+
return __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 1000 |
+
));
|
| 1001 |
+
}
|
| 1002 |
+
#endif // __cccl_ptx_isa >= 800
|
| 1003 |
+
|
| 1004 |
+
/*
|
| 1005 |
+
// mbarrier.try_wait.parity{.sem}{.scope}.shared::cta.b64 waitComplete, [addr], phaseParity, suspendTimeHint; // 8b. PTX ISA 80, SM_90
|
| 1006 |
+
// .sem = { .acquire }
|
| 1007 |
+
// .scope = { .cta, .cluster }
|
| 1008 |
+
template <cuda::ptx::dot_scope Scope>
|
| 1009 |
+
__device__ static inline bool mbarrier_try_wait_parity(
|
| 1010 |
+
cuda::ptx::sem_acquire_t,
|
| 1011 |
+
cuda::ptx::scope_t<Scope> scope,
|
| 1012 |
+
uint64_t* addr,
|
| 1013 |
+
const uint32_t& phaseParity,
|
| 1014 |
+
const uint32_t& suspendTimeHint);
|
| 1015 |
+
*/
|
| 1016 |
+
#if __cccl_ptx_isa >= 800
|
| 1017 |
+
extern "C" _LIBCUDACXX_DEVICE bool __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 1018 |
+
template <dot_scope _Scope>
|
| 1019 |
+
_LIBCUDACXX_DEVICE static inline bool mbarrier_try_wait_parity(
|
| 1020 |
+
sem_acquire_t,
|
| 1021 |
+
scope_t<_Scope> __scope,
|
| 1022 |
+
_CUDA_VSTD::uint64_t* __addr,
|
| 1023 |
+
const _CUDA_VSTD::uint32_t& __phaseParity,
|
| 1024 |
+
const _CUDA_VSTD::uint32_t& __suspendTimeHint)
|
| 1025 |
+
{
|
| 1026 |
+
// __sem == sem_acquire (due to parameter type constraint)
|
| 1027 |
+
static_assert(__scope == scope_cta || __scope == scope_cluster, "");
|
| 1028 |
+
|
| 1029 |
+
NV_IF_ELSE_TARGET(NV_PROVIDES_SM_90,(
|
| 1030 |
+
_CUDA_VSTD::uint32_t __waitComplete;
|
| 1031 |
+
if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cta) {
|
| 1032 |
+
asm (
|
| 1033 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 1034 |
+
"mbarrier.try_wait.parity.acquire.cta.shared::cta.b64 P_OUT, [%1], %2, %3; // 8b. \n\t"
|
| 1035 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 1036 |
+
"}"
|
| 1037 |
+
: "=r"(__waitComplete)
|
| 1038 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 1039 |
+
"r"(__phaseParity),
|
| 1040 |
+
"r"(__suspendTimeHint)
|
| 1041 |
+
: "memory"
|
| 1042 |
+
);
|
| 1043 |
+
} else if _LIBCUDACXX_CONSTEXPR_AFTER_CXX14 (__scope == scope_cluster) {
|
| 1044 |
+
asm (
|
| 1045 |
+
"{\n\t .reg .pred P_OUT; \n\t"
|
| 1046 |
+
"mbarrier.try_wait.parity.acquire.cluster.shared::cta.b64 P_OUT, [%1], %2, %3; // 8b. \n\t"
|
| 1047 |
+
"selp.b32 %0, 1, 0, P_OUT; \n"
|
| 1048 |
+
"}"
|
| 1049 |
+
: "=r"(__waitComplete)
|
| 1050 |
+
: "r"(__as_ptr_smem(__addr)),
|
| 1051 |
+
"r"(__phaseParity),
|
| 1052 |
+
"r"(__suspendTimeHint)
|
| 1053 |
+
: "memory"
|
| 1054 |
+
);
|
| 1055 |
+
}
|
| 1056 |
+
return static_cast<bool>(__waitComplete); // Deliberate downcast.
|
| 1057 |
+
),(
|
| 1058 |
+
// Unsupported architectures will have a linker error with a semi-decent error message
|
| 1059 |
+
return __bool__cuda_ptx_mbarrier_try_wait_parity_is_not_supported_before_SM_90__();
|
| 1060 |
+
));
|
| 1061 |
+
}
|
| 1062 |
+
#endif // __cccl_ptx_isa >= 800
|
| 1063 |
+
|
| 1064 |
+
|
| 1065 |
+
// 9.7.12.15.17. Parallel Synchronization and Communication Instructions: mbarrier.pending_count
|
| 1066 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parallel-synchronization-and-communication-instructions-mbarrier-pending-count
|
| 1067 |
+
|
| 1068 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_PTX
|
| 1069 |
+
|
| 1070 |
+
#endif // _CUDA_PTX_PARALLEL_SYNCHRONIZATION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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 5 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 6 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 7 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 8 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 9 |
+
//
|
| 10 |
+
//===----------------------------------------------------------------------===//
|
| 11 |
+
|
| 12 |
+
#ifndef _CUDA_PTX_DOT_VARIANTS_H_
|
| 13 |
+
#define _CUDA_PTX_DOT_VARIANTS_H_
|
| 14 |
+
|
| 15 |
+
#include "../../__type_traits/integral_constant.h" // std::integral_constant
|
| 16 |
+
|
| 17 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 18 |
+
# pragma GCC system_header
|
| 19 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 20 |
+
# pragma clang system_header
|
| 21 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 22 |
+
# pragma system_header
|
| 23 |
+
#endif // no system header
|
| 24 |
+
|
| 25 |
+
/*
|
| 26 |
+
* Public integral constant types and values for ".variant"s:
|
| 27 |
+
*
|
| 28 |
+
* - .sem: acquire, release, ..
|
| 29 |
+
* - .space: global, shared, constant, ..
|
| 30 |
+
* - .scope: cta, cluster, gpu, ..
|
| 31 |
+
* - .op: add, min, cas, ..
|
| 32 |
+
*
|
| 33 |
+
* For each .variant, the code below defines:
|
| 34 |
+
* - An enum `dot_variant` with each possible value
|
| 35 |
+
* - A type template `variant_t<dot_variant>`
|
| 36 |
+
* - Types `variant_A_t`, ..., `variant_Z_t`
|
| 37 |
+
* - Constexpr values `variant_A` of type `variant_A_t`
|
| 38 |
+
*
|
| 39 |
+
* These types enable specifying fine-grained overloads of a PTX binding. If a
|
| 40 |
+
* binding can handle multiple variants, then it is defined as:
|
| 41 |
+
*
|
| 42 |
+
* template <dot_variant var>
|
| 43 |
+
* [...] void ptx_binding(variant_t<var> __v) { ... }
|
| 44 |
+
*
|
| 45 |
+
* If it only handles a single variant, then it is defined as:
|
| 46 |
+
*
|
| 47 |
+
* [...] void ptx_binding(variant_A __v) { ... }
|
| 48 |
+
*
|
| 49 |
+
* If two variants have different behaviors or return types (see .space
|
| 50 |
+
* overloads of mbarrier.arrive.expect_tx for an example), then these can be
|
| 51 |
+
* provided as separate overloads of the same function:
|
| 52 |
+
*
|
| 53 |
+
* [...] void ptx_binding(variant_A __v) { ... }
|
| 54 |
+
* [...] int ptx_binding(variant_B __v) { ... }
|
| 55 |
+
*
|
| 56 |
+
*/
|
| 57 |
+
|
| 58 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_PTX
|
| 59 |
+
|
| 60 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#operation-types
|
| 61 |
+
enum class dot_sem
|
| 62 |
+
{
|
| 63 |
+
acq_rel,
|
| 64 |
+
acquire,
|
| 65 |
+
relaxed,
|
| 66 |
+
release,
|
| 67 |
+
sc,
|
| 68 |
+
weak
|
| 69 |
+
};
|
| 70 |
+
|
| 71 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#state-spaces
|
| 72 |
+
enum class dot_space
|
| 73 |
+
{
|
| 74 |
+
global,
|
| 75 |
+
cluster, // The PTX spelling is shared::cluster
|
| 76 |
+
shared, // The PTX spelling is shared::cta
|
| 77 |
+
|
| 78 |
+
// The following state spaces are unlikely to be used in cuda::ptx in the near
|
| 79 |
+
// future, so they are not exposed:
|
| 80 |
+
|
| 81 |
+
// reg,
|
| 82 |
+
// sreg,
|
| 83 |
+
// const_mem, // Using const_mem as `const` is reserved in C++.
|
| 84 |
+
// local,
|
| 85 |
+
// param,
|
| 86 |
+
// tex // deprecated
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#scope
|
| 90 |
+
enum class dot_scope
|
| 91 |
+
{
|
| 92 |
+
cta,
|
| 93 |
+
cluster,
|
| 94 |
+
gpu,
|
| 95 |
+
sys
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
enum class dot_op
|
| 99 |
+
{
|
| 100 |
+
add,
|
| 101 |
+
dec,
|
| 102 |
+
inc,
|
| 103 |
+
max,
|
| 104 |
+
min,
|
| 105 |
+
and_op, // Using and_op, as `and, or, xor` are reserved in C++.
|
| 106 |
+
or_op,
|
| 107 |
+
xor_op,
|
| 108 |
+
cas,
|
| 109 |
+
exch
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
template <dot_sem __sem>
|
| 113 |
+
using sem_t = _CUDA_VSTD::integral_constant<dot_sem, __sem>;
|
| 114 |
+
using sem_acq_rel_t = sem_t<dot_sem::acq_rel>;
|
| 115 |
+
using sem_acquire_t = sem_t<dot_sem::acquire>;
|
| 116 |
+
using sem_relaxed_t = sem_t<dot_sem::relaxed>;
|
| 117 |
+
using sem_release_t = sem_t<dot_sem::release>;
|
| 118 |
+
using sem_sc_t = sem_t<dot_sem::sc>;
|
| 119 |
+
using sem_weak_t = sem_t<dot_sem::weak>;
|
| 120 |
+
|
| 121 |
+
static constexpr sem_acq_rel_t sem_acq_rel{};
|
| 122 |
+
static constexpr sem_acquire_t sem_acquire{};
|
| 123 |
+
static constexpr sem_relaxed_t sem_relaxed{};
|
| 124 |
+
static constexpr sem_release_t sem_release{};
|
| 125 |
+
static constexpr sem_sc_t sem_sc{};
|
| 126 |
+
static constexpr sem_weak_t sem_weak{};
|
| 127 |
+
|
| 128 |
+
template <dot_space __spc>
|
| 129 |
+
using space_t = _CUDA_VSTD::integral_constant<dot_space, __spc>;
|
| 130 |
+
using space_global_t = space_t<dot_space::global>;
|
| 131 |
+
using space_shared_t = space_t<dot_space::shared>;
|
| 132 |
+
using space_cluster_t = space_t<dot_space::cluster>;
|
| 133 |
+
|
| 134 |
+
static constexpr space_global_t space_global{};
|
| 135 |
+
static constexpr space_shared_t space_shared{};
|
| 136 |
+
static constexpr space_cluster_t space_cluster{};
|
| 137 |
+
|
| 138 |
+
template <dot_scope __scope>
|
| 139 |
+
using scope_t = _CUDA_VSTD::integral_constant<dot_scope, __scope>;
|
| 140 |
+
using scope_cluster_t = scope_t<dot_scope::cluster>;
|
| 141 |
+
using scope_cta_t = scope_t<dot_scope::cta>;
|
| 142 |
+
using scope_gpu_t = scope_t<dot_scope::gpu>;
|
| 143 |
+
using scope_sys_t = scope_t<dot_scope::sys>;
|
| 144 |
+
|
| 145 |
+
static constexpr scope_cluster_t scope_cluster{};
|
| 146 |
+
static constexpr scope_cta_t scope_cta{};
|
| 147 |
+
static constexpr scope_gpu_t scope_gpu{};
|
| 148 |
+
static constexpr scope_sys_t scope_sys{};
|
| 149 |
+
|
| 150 |
+
template <dot_op __op>
|
| 151 |
+
using op_t = _CUDA_VSTD::integral_constant<dot_op, __op>;
|
| 152 |
+
using op_add_t = op_t<dot_op::add>;
|
| 153 |
+
using op_dec_t = op_t<dot_op::dec>;
|
| 154 |
+
using op_inc_t = op_t<dot_op::inc>;
|
| 155 |
+
using op_max_t = op_t<dot_op::max>;
|
| 156 |
+
using op_min_t = op_t<dot_op::min>;
|
| 157 |
+
using op_and_op_t = op_t<dot_op::and_op>;
|
| 158 |
+
using op_or_op_t = op_t<dot_op::or_op>;
|
| 159 |
+
using op_xor_op_t = op_t<dot_op::xor_op>;
|
| 160 |
+
using op_cas_t = op_t<dot_op::cas>;
|
| 161 |
+
using op_exch_t = op_t<dot_op::exch>;
|
| 162 |
+
|
| 163 |
+
static constexpr op_add_t op_add{};
|
| 164 |
+
static constexpr op_dec_t op_dec{};
|
| 165 |
+
static constexpr op_inc_t op_inc{};
|
| 166 |
+
static constexpr op_max_t op_max{};
|
| 167 |
+
static constexpr op_min_t op_min{};
|
| 168 |
+
static constexpr op_and_op_t op_and_op{};
|
| 169 |
+
static constexpr op_or_op_t op_or_op{};
|
| 170 |
+
static constexpr op_xor_op_t op_xor_op{};
|
| 171 |
+
static constexpr op_cas_t op_cas{};
|
| 172 |
+
static constexpr op_exch_t op_exch{};
|
| 173 |
+
|
| 174 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_PTX
|
| 175 |
+
|
| 176 |
+
#endif // _CUDA_PTX_DOT_VARIANTS_H_
|
cuda_toolkit/include/__cuda/ptx/ptx_helper_functions.h
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of libcu++, the C++ Standard Library for your entire system,
|
| 5 |
+
// under the Apache License v2.0 with LLVM Exceptions.
|
| 6 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 7 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 8 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 9 |
+
//
|
| 10 |
+
//===----------------------------------------------------------------------===//
|
| 11 |
+
|
| 12 |
+
#ifndef _CUDA_PTX_HELPER_FUNCTIONS_H_
|
| 13 |
+
#define _CUDA_PTX_HELPER_FUNCTIONS_H_
|
| 14 |
+
|
| 15 |
+
#include "../../cstdint" // uint32_t
|
| 16 |
+
|
| 17 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 18 |
+
# pragma GCC system_header
|
| 19 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 20 |
+
# pragma clang system_header
|
| 21 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 22 |
+
# pragma system_header
|
| 23 |
+
#endif // no system header
|
| 24 |
+
|
| 25 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA_PTX
|
| 26 |
+
|
| 27 |
+
inline _LIBCUDACXX_DEVICE _CUDA_VSTD::uint32_t __as_ptr_smem(const void* __ptr)
|
| 28 |
+
{
|
| 29 |
+
// Consider adding debug asserts here.
|
| 30 |
+
return static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__ptr));
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
inline _LIBCUDACXX_DEVICE _CUDA_VSTD::uint32_t __as_ptr_remote_dsmem(const void* __ptr)
|
| 34 |
+
{
|
| 35 |
+
// No difference in implementation to __as_ptr_smem.
|
| 36 |
+
// Consider adding debug asserts here.
|
| 37 |
+
return static_cast<_CUDA_VSTD::uint32_t>(__cvta_generic_to_shared(__ptr));
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
inline _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t __as_ptr_gmem(const void* __ptr)
|
| 41 |
+
{
|
| 42 |
+
// Consider adding debug asserts here.
|
| 43 |
+
return static_cast<_CUDA_VSTD::uint64_t>(__cvta_generic_to_global(__ptr));
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
template <typename _Tp>
|
| 47 |
+
inline _LIBCUDACXX_DEVICE _CUDA_VSTD::uint32_t __as_b32(_Tp __val)
|
| 48 |
+
{
|
| 49 |
+
#if _LIBCUDACXX_STD_VER >= 17 && !defined(_LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR)
|
| 50 |
+
static_assert(sizeof(_Tp) == 4, "");
|
| 51 |
+
#endif // _LIBCUDACXX_STD_VER >= 17 && !_LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR
|
| 52 |
+
// Consider using std::bitcast
|
| 53 |
+
return *reinterpret_cast<_CUDA_VSTD::uint32_t*>(&__val);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
template <typename _Tp>
|
| 57 |
+
inline _LIBCUDACXX_DEVICE _CUDA_VSTD::uint64_t __as_b64(_Tp __val)
|
| 58 |
+
{
|
| 59 |
+
#if _LIBCUDACXX_STD_VER >= 17 && !defined(_LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR)
|
| 60 |
+
static_assert(sizeof(_Tp) == 8, "");
|
| 61 |
+
#endif // _LIBCUDACXX_STD_VER >= 17 && !_LIBCUDACXX_HAS_NO_CXX14_CONSTEXPR
|
| 62 |
+
// Consider using std::bitcast
|
| 63 |
+
return *reinterpret_cast<_CUDA_VSTD::uint64_t*>(&__val);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA_PTX
|
| 67 |
+
|
| 68 |
+
#endif // _CUDA_PTX_HELPER_FUNCTIONS_H_
|
cuda_toolkit/include/__cuda/semaphore.h
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___CUDA_SEMAPHORE_H
|
| 12 |
+
#define _LIBCUDACXX___CUDA_SEMAPHORE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#error "<__cuda/semaphore> should only be included in from <cuda/std/semaphore>"
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 19 |
+
# pragma GCC system_header
|
| 20 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 21 |
+
# pragma clang system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 23 |
+
# pragma system_header
|
| 24 |
+
#endif // no system header
|
| 25 |
+
|
| 26 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA
|
| 27 |
+
|
| 28 |
+
template<thread_scope _Sco, ptrdiff_t __least_max_value = INT_MAX>
|
| 29 |
+
class counting_semaphore : public _CUDA_VSTD::__semaphore_base<__least_max_value, _Sco>
|
| 30 |
+
{
|
| 31 |
+
static_assert(__least_max_value <= _CUDA_VSTD::__semaphore_base<__least_max_value, _Sco>::max(), "");
|
| 32 |
+
public:
|
| 33 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 34 |
+
counting_semaphore(ptrdiff_t __count = 0) : _CUDA_VSTD::__semaphore_base<__least_max_value, _Sco>(__count) { }
|
| 35 |
+
~counting_semaphore() = default;
|
| 36 |
+
|
| 37 |
+
counting_semaphore(const counting_semaphore&) = delete;
|
| 38 |
+
counting_semaphore& operator=(const counting_semaphore&) = delete;
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
template<thread_scope _Sco>
|
| 42 |
+
using binary_semaphore = counting_semaphore<_Sco, 1>;
|
| 43 |
+
|
| 44 |
+
_LIBCUDACXX_END_NAMESPACE_CUDA
|
| 45 |
+
|
| 46 |
+
#endif // _LIBCUDACXX___CUDA_SEMAPHORE_H
|
cuda_toolkit/include/__expected/bad_expected_access.h
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
#ifndef _LIBCUDACXX___EXPECTED_BAD_EXPECTED_ACCESS_H
|
| 10 |
+
#define _LIBCUDACXX___EXPECTED_BAD_EXPECTED_ACCESS_H
|
| 11 |
+
|
| 12 |
+
#ifndef __cuda_std__
|
| 13 |
+
#include <__config>
|
| 14 |
+
#endif // __cuda_std__
|
| 15 |
+
|
| 16 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 17 |
+
# pragma GCC system_header
|
| 18 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 19 |
+
# pragma clang system_header
|
| 20 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 21 |
+
# pragma system_header
|
| 22 |
+
#endif // no system header
|
| 23 |
+
|
| 24 |
+
#include "../__utility/move.h"
|
| 25 |
+
#include "../exception"
|
| 26 |
+
|
| 27 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 28 |
+
|
| 29 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 30 |
+
|
| 31 |
+
template <class _Err>
|
| 32 |
+
class bad_expected_access;
|
| 33 |
+
|
| 34 |
+
template <>
|
| 35 |
+
class bad_expected_access<void> : public exception {
|
| 36 |
+
protected:
|
| 37 |
+
bad_expected_access() noexcept = default;
|
| 38 |
+
bad_expected_access(const bad_expected_access&) = default;
|
| 39 |
+
bad_expected_access(bad_expected_access&&) = default;
|
| 40 |
+
bad_expected_access& operator=(const bad_expected_access&) = default;
|
| 41 |
+
bad_expected_access& operator=(bad_expected_access&&) = default;
|
| 42 |
+
~bad_expected_access() noexcept override = default;
|
| 43 |
+
|
| 44 |
+
public:
|
| 45 |
+
// The way this has been designed (by using a class template below) means that we'll already
|
| 46 |
+
// have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch
|
| 47 |
+
// of work to do. So it is not worth hiding the <void> specialization in the dylib, given that
|
| 48 |
+
// it adds deployment target restrictions.
|
| 49 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 50 |
+
const char* what() const noexcept override { return "bad access to std::expected"; }
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
template <class _Err>
|
| 54 |
+
class bad_expected_access : public bad_expected_access<void> {
|
| 55 |
+
public:
|
| 56 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 57 |
+
explicit bad_expected_access(_Err __e) : __unex_(_CUDA_VSTD::move(__e)) {}
|
| 58 |
+
|
| 59 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 60 |
+
_Err& error() & noexcept { return __unex_; }
|
| 61 |
+
|
| 62 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 63 |
+
const _Err& error() const& noexcept { return __unex_; }
|
| 64 |
+
|
| 65 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 66 |
+
_Err&& error() && noexcept { return _CUDA_VSTD::move(__unex_); }
|
| 67 |
+
|
| 68 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 69 |
+
const _Err&& error() const&& noexcept { return _CUDA_VSTD::move(__unex_); }
|
| 70 |
+
|
| 71 |
+
private:
|
| 72 |
+
_Err __unex_;
|
| 73 |
+
};
|
| 74 |
+
|
| 75 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 76 |
+
|
| 77 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 78 |
+
|
| 79 |
+
#endif // _LIBCUDACXX___EXPECTED_BAD_EXPECTED_ACCESS_H
|
cuda_toolkit/include/__expected/expected.h
ADDED
|
@@ -0,0 +1,1790 @@
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
#ifndef _LIBCUDACXX___EXPECTED_EXPECTED_H
|
| 10 |
+
#define _LIBCUDACXX___EXPECTED_EXPECTED_H
|
| 11 |
+
|
| 12 |
+
#ifndef __cuda_std__
|
| 13 |
+
#include <__config>
|
| 14 |
+
#endif // __cuda_std__
|
| 15 |
+
|
| 16 |
+
#include "../__assert"
|
| 17 |
+
#include "../__concepts/invocable.h"
|
| 18 |
+
#ifndef _LIBCUDACXX_NO_EXCEPTIONS
|
| 19 |
+
#include "../__expected/bad_expected_access.h"
|
| 20 |
+
#endif // _LIBCUDACXX_NO_EXCEPTIONS
|
| 21 |
+
#include "../__expected/expected_base.h"
|
| 22 |
+
#include "../__expected/unexpect.h"
|
| 23 |
+
#include "../__expected/unexpected.h"
|
| 24 |
+
#include "../__memory/addressof.h"
|
| 25 |
+
#include "../__memory/construct_at.h"
|
| 26 |
+
#include "../__type_traits/conjunction.h"
|
| 27 |
+
#include "../__type_traits/disjunction.h"
|
| 28 |
+
#include "../__type_traits/is_assignable.h"
|
| 29 |
+
#include "../__type_traits/is_constructible.h"
|
| 30 |
+
#include "../__type_traits/is_convertible.h"
|
| 31 |
+
#include "../__type_traits/is_copy_assignable.h"
|
| 32 |
+
#include "../__type_traits/is_copy_constructible.h"
|
| 33 |
+
#include "../__type_traits/is_default_constructible.h"
|
| 34 |
+
#include "../__type_traits/is_function.h"
|
| 35 |
+
#include "../__type_traits/is_move_assignable.h"
|
| 36 |
+
#include "../__type_traits/is_move_constructible.h"
|
| 37 |
+
#include "../__type_traits/is_nothrow_constructible.h"
|
| 38 |
+
#include "../__type_traits/is_nothrow_copy_assignable.h"
|
| 39 |
+
#include "../__type_traits/is_nothrow_copy_constructible.h"
|
| 40 |
+
#include "../__type_traits/is_nothrow_default_constructible.h"
|
| 41 |
+
#include "../__type_traits/is_nothrow_move_assignable.h"
|
| 42 |
+
#include "../__type_traits/is_nothrow_move_constructible.h"
|
| 43 |
+
#include "../__type_traits/is_reference.h"
|
| 44 |
+
#include "../__type_traits/is_same.h"
|
| 45 |
+
#include "../__type_traits/is_swappable.h"
|
| 46 |
+
#include "../__type_traits/is_trivially_copy_constructible.h"
|
| 47 |
+
#include "../__type_traits/is_trivially_destructible.h"
|
| 48 |
+
#include "../__type_traits/is_trivially_move_constructible.h"
|
| 49 |
+
#include "../__type_traits/is_void.h"
|
| 50 |
+
#include "../__type_traits/lazy.h"
|
| 51 |
+
#include "../__type_traits/negation.h"
|
| 52 |
+
#include "../__type_traits/remove_cv.h"
|
| 53 |
+
#include "../__type_traits/remove_cvref.h"
|
| 54 |
+
#include "../__utility/exception_guard.h"
|
| 55 |
+
#include "../__utility/forward.h"
|
| 56 |
+
#include "../__utility/in_place.h"
|
| 57 |
+
#include "../__utility/move.h"
|
| 58 |
+
#include "../__utility/swap.h"
|
| 59 |
+
|
| 60 |
+
#include "../cstdlib"
|
| 61 |
+
#include "../initializer_list"
|
| 62 |
+
|
| 63 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 64 |
+
# pragma GCC system_header
|
| 65 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 66 |
+
# pragma clang system_header
|
| 67 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 68 |
+
# pragma system_header
|
| 69 |
+
#endif // no system header
|
| 70 |
+
|
| 71 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 72 |
+
|
| 73 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 74 |
+
|
| 75 |
+
template <class _Tp, class _Err>
|
| 76 |
+
class expected;
|
| 77 |
+
|
| 78 |
+
namespace __expected {
|
| 79 |
+
|
| 80 |
+
template <class _Err, class _Arg>
|
| 81 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 82 |
+
void __throw_bad_expected_access(_Arg&& __arg) {
|
| 83 |
+
#ifndef _LIBCUDACXX_NO_EXCEPTIONS
|
| 84 |
+
throw _CUDA_STD::bad_expected_access<_Err>(_CUDA_VSTD::forward<_Arg>(__arg));
|
| 85 |
+
#else
|
| 86 |
+
(void)__arg;
|
| 87 |
+
_LIBCUDACXX_UNREACHABLE();
|
| 88 |
+
#endif // _LIBCUDACXX_NO_EXCEPTIONS
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
template <class _Tp, class _Err>
|
| 92 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __valid_expected =
|
| 93 |
+
!_LIBCUDACXX_TRAIT(is_reference, _Tp) &&
|
| 94 |
+
!_LIBCUDACXX_TRAIT(is_function, _Tp) &&
|
| 95 |
+
!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<_Tp>, in_place_t) &&
|
| 96 |
+
!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<_Tp>, unexpect_t) &&
|
| 97 |
+
!__unexpected::__is_unexpected<__remove_cv_t<_Tp>> &&
|
| 98 |
+
__unexpected::__valid_unexpected<_Err>;
|
| 99 |
+
|
| 100 |
+
template <class _Tp>
|
| 101 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_expected = false;
|
| 102 |
+
|
| 103 |
+
template <class _Tp, class _Err>
|
| 104 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_expected<expected<_Tp, _Err>> = true;
|
| 105 |
+
|
| 106 |
+
template <class _Tp>
|
| 107 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_expected_nonvoid = __is_expected<_Tp>;
|
| 108 |
+
|
| 109 |
+
template <class _Err>
|
| 110 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_expected_nonvoid<expected<void, _Err>> = false;
|
| 111 |
+
|
| 112 |
+
template<class _Tp, class _Err>
|
| 113 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __can_swap =
|
| 114 |
+
_LIBCUDACXX_TRAIT(is_swappable, _Tp)
|
| 115 |
+
&& _LIBCUDACXX_TRAIT(is_swappable, _Err)
|
| 116 |
+
&& _LIBCUDACXX_TRAIT(is_move_constructible, _Tp)
|
| 117 |
+
&& _LIBCUDACXX_TRAIT(is_move_constructible, _Err)
|
| 118 |
+
&& (_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp)
|
| 119 |
+
|| _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err));
|
| 120 |
+
|
| 121 |
+
template<class _Err>
|
| 122 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __can_swap<void, _Err> =
|
| 123 |
+
_LIBCUDACXX_TRAIT(is_swappable, _Err)
|
| 124 |
+
&& _LIBCUDACXX_TRAIT(is_move_constructible, _Err);
|
| 125 |
+
} // namespace __expected
|
| 126 |
+
|
| 127 |
+
template <class _Tp, class _Err>
|
| 128 |
+
class expected : private __expected_move_assign<_Tp, _Err>
|
| 129 |
+
, private __expected_sfinae_ctor_base_t<_Tp, _Err>
|
| 130 |
+
, private __expected_sfinae_assign_base_t<_Tp, _Err>
|
| 131 |
+
{
|
| 132 |
+
using __base = __expected_move_assign<_Tp, _Err>;
|
| 133 |
+
|
| 134 |
+
static_assert(__expected::__valid_expected<_Tp, _Err>,
|
| 135 |
+
"[expected.object.general] A program that instantiates the definition of template expected<T, E> for a "
|
| 136 |
+
"reference type, a function type, or for possibly cv-qualified types in_place_t, unexpect_t, or a "
|
| 137 |
+
"specialization of unexpected for the T parameter is ill-formed. A program that instantiates the "
|
| 138 |
+
"definition of the template expected<T, E> with a type for the E parameter that is not a valid "
|
| 139 |
+
"template argument for unexpected is ill-formed.");
|
| 140 |
+
|
| 141 |
+
template <class, class>
|
| 142 |
+
friend class expected;
|
| 143 |
+
|
| 144 |
+
public:
|
| 145 |
+
using value_type = _Tp;
|
| 146 |
+
using error_type = _Err;
|
| 147 |
+
using unexpected_type = unexpected<_Err>;
|
| 148 |
+
|
| 149 |
+
template <class _Up>
|
| 150 |
+
using rebind = expected<_Up, error_type>;
|
| 151 |
+
|
| 152 |
+
// [expected.object.ctor], constructors
|
| 153 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)
|
| 154 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_default_constructible, _Tp2))
|
| 155 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 156 |
+
expected() noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Tp2))
|
| 157 |
+
: __base(true)
|
| 158 |
+
{}
|
| 159 |
+
|
| 160 |
+
constexpr expected(const expected&) = default;
|
| 161 |
+
constexpr expected(expected&&) = default;
|
| 162 |
+
constexpr expected& operator=(const expected&) = default;
|
| 163 |
+
constexpr expected& operator=(expected&&) = default;
|
| 164 |
+
|
| 165 |
+
private:
|
| 166 |
+
template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual>
|
| 167 |
+
using __can_convert =
|
| 168 |
+
_And< is_constructible<_Tp, _UfQual>,
|
| 169 |
+
is_constructible<_Err, _OtherErrQual>,
|
| 170 |
+
_Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
|
| 171 |
+
_Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,
|
| 172 |
+
_Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,
|
| 173 |
+
_Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,
|
| 174 |
+
_Not<is_convertible<expected<_Up, _OtherErr>&, _Tp>>,
|
| 175 |
+
_Not<is_convertible<expected<_Up, _OtherErr>&&, _Tp>>,
|
| 176 |
+
_Not<is_convertible<const expected<_Up, _OtherErr>&, _Tp>>,
|
| 177 |
+
_Not<is_convertible<const expected<_Up, _OtherErr>&&, _Tp>>,
|
| 178 |
+
_Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
|
| 179 |
+
_Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
|
| 180 |
+
_Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
|
| 181 |
+
_Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>> >;
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
public:
|
| 185 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 186 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value _LIBCUDACXX_AND
|
| 187 |
+
_LIBCUDACXX_TRAIT(is_convertible, const _Up&, _Tp) _LIBCUDACXX_AND
|
| 188 |
+
_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)
|
| 189 |
+
)
|
| 190 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 191 |
+
expected(const expected<_Up, _OtherErr>& __other)
|
| 192 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, const _Up&) &&
|
| 193 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 194 |
+
: __base(__other.__has_val_)
|
| 195 |
+
{
|
| 196 |
+
if (__other.__has_val_) {
|
| 197 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __other.__union_.__val_);
|
| 198 |
+
} else {
|
| 199 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 204 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _Up&, const _OtherErr&>::value _LIBCUDACXX_AND
|
| 205 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, const _Up&, _Tp) || !_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))
|
| 206 |
+
)
|
| 207 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 208 |
+
explicit expected(const expected<_Up, _OtherErr>& __other)
|
| 209 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, const _Up&) &&
|
| 210 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 211 |
+
: __base(__other.__has_val_)
|
| 212 |
+
{
|
| 213 |
+
if (__other.__has_val_) {
|
| 214 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __other.__union_.__val_);
|
| 215 |
+
} else {
|
| 216 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 221 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCUDACXX_AND
|
| 222 |
+
_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp) _LIBCUDACXX_AND
|
| 223 |
+
_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)
|
| 224 |
+
)
|
| 225 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 226 |
+
expected(expected<_Up, _OtherErr>&& __other)
|
| 227 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) &&
|
| 228 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 229 |
+
: __base(__other.__has_val_)
|
| 230 |
+
{
|
| 231 |
+
if (__other.__has_val_) {
|
| 232 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__val_));
|
| 233 |
+
} else {
|
| 234 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 235 |
+
}
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 239 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCUDACXX_AND
|
| 240 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp) || !_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))
|
| 241 |
+
)
|
| 242 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 243 |
+
explicit expected(expected<_Up, _OtherErr>&& __other)
|
| 244 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) &&
|
| 245 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 246 |
+
: __base(__other.__has_val_)
|
| 247 |
+
{
|
| 248 |
+
if (__other.__has_val_) {
|
| 249 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__val_));
|
| 250 |
+
} else {
|
| 251 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
_LIBCUDACXX_TEMPLATE(class _Up = _Tp)
|
| 256 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, __remove_cvref_t<_Up>, in_place_t)) _LIBCUDACXX_AND
|
| 257 |
+
(!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND
|
| 258 |
+
(!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND
|
| 259 |
+
_LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND
|
| 260 |
+
_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp)
|
| 261 |
+
)
|
| 262 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 263 |
+
expected(_Up&& __u) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up)) // strengthened
|
| 264 |
+
: __base(in_place, _CUDA_VSTD::forward<_Up>(__u))
|
| 265 |
+
{}
|
| 266 |
+
|
| 267 |
+
_LIBCUDACXX_TEMPLATE(class _Up = _Tp)
|
| 268 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, __remove_cvref_t<_Up>, in_place_t)) _LIBCUDACXX_AND
|
| 269 |
+
(!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND
|
| 270 |
+
(!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND
|
| 271 |
+
_LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND
|
| 272 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp))
|
| 273 |
+
)
|
| 274 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 275 |
+
explicit expected(_Up&& __u) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up)) // strengthened
|
| 276 |
+
: __base(in_place, _CUDA_VSTD::forward<_Up>(__u))
|
| 277 |
+
{}
|
| 278 |
+
|
| 279 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 280 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND
|
| 281 |
+
_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)
|
| 282 |
+
)
|
| 283 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 284 |
+
expected(const unexpected<_OtherErr>& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 285 |
+
: __base(unexpect, __unex.error())
|
| 286 |
+
{}
|
| 287 |
+
|
| 288 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 289 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND
|
| 290 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))
|
| 291 |
+
)
|
| 292 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 293 |
+
explicit expected(const unexpected<_OtherErr>& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 294 |
+
: __base(unexpect, __unex.error())
|
| 295 |
+
{}
|
| 296 |
+
|
| 297 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 298 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND
|
| 299 |
+
_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)
|
| 300 |
+
)
|
| 301 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 302 |
+
expected(unexpected<_OtherErr>&& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 303 |
+
: __base(unexpect, _CUDA_VSTD::move(__unex.error()))
|
| 304 |
+
{}
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 308 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND
|
| 309 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))
|
| 310 |
+
)
|
| 311 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 312 |
+
explicit expected(unexpected<_OtherErr>&& __unex) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 313 |
+
: __base(unexpect, _CUDA_VSTD::move(__unex.error()))
|
| 314 |
+
{}
|
| 315 |
+
|
| 316 |
+
_LIBCUDACXX_TEMPLATE(class... _Args)
|
| 317 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp, _Args...))
|
| 318 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 319 |
+
explicit expected(in_place_t, _Args&&... __args) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...)) // strengthened
|
| 320 |
+
: __base(in_place, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 321 |
+
{}
|
| 322 |
+
|
| 323 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class... _Args)
|
| 324 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp, initializer_list<_Up>&, _Args...))
|
| 325 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 326 |
+
explicit expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
|
| 327 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, initializer_list<_Up>&, _Args...)) // strengthened
|
| 328 |
+
: __base(in_place, __il, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 329 |
+
{}
|
| 330 |
+
|
| 331 |
+
_LIBCUDACXX_TEMPLATE(class... _Args)
|
| 332 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _Args...))
|
| 333 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 334 |
+
explicit expected(unexpect_t, _Args&&... __args) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...)) // strengthened
|
| 335 |
+
: __base(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 336 |
+
{}
|
| 337 |
+
|
| 338 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class... _Args)
|
| 339 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, initializer_list<_Up>&, _Args...))
|
| 340 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 341 |
+
explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
|
| 342 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, initializer_list<_Up>&, _Args...)) // strengthened
|
| 343 |
+
: __base(unexpect, __il, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 344 |
+
{}
|
| 345 |
+
|
| 346 |
+
private:
|
| 347 |
+
template<class _Fun, class... _Args>
|
| 348 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 349 |
+
expected(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 350 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 351 |
+
: __base(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 352 |
+
{}
|
| 353 |
+
|
| 354 |
+
template<class _Fun, class... _Args>
|
| 355 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 356 |
+
expected(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 357 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 358 |
+
: __base(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 359 |
+
{}
|
| 360 |
+
|
| 361 |
+
public:
|
| 362 |
+
// [expected.object.assign], assignment
|
| 363 |
+
_LIBCUDACXX_TEMPLATE(class _Up = _Tp)
|
| 364 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, expected, __remove_cvref_t<_Up>)) _LIBCUDACXX_AND
|
| 365 |
+
(!__unexpected::__is_unexpected<__remove_cvref_t<_Up>>) _LIBCUDACXX_AND
|
| 366 |
+
_LIBCUDACXX_TRAIT(is_constructible, _Tp, _Up) _LIBCUDACXX_AND
|
| 367 |
+
_LIBCUDACXX_TRAIT(is_assignable, _Tp&, _Up) _LIBCUDACXX_AND
|
| 368 |
+
(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Up) ||
|
| 369 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) ||
|
| 370 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err))
|
| 371 |
+
)
|
| 372 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 373 |
+
expected& operator=(_Up&& __v) {
|
| 374 |
+
if (this->__has_val_) {
|
| 375 |
+
this->__union_.__val_ = _CUDA_VSTD::forward<_Up>(__v);
|
| 376 |
+
} else {
|
| 377 |
+
this->__reinit_expected(this->__union_.__val_, this->__union_.__unex_, _CUDA_VSTD::forward<_Up>(__v));
|
| 378 |
+
this->__has_val_ = true;
|
| 379 |
+
}
|
| 380 |
+
return *this;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
private:
|
| 384 |
+
template <class _OtherErrQual>
|
| 385 |
+
static constexpr bool __can_assign_from_unexpected =
|
| 386 |
+
_And< is_constructible<_Err, _OtherErrQual>,
|
| 387 |
+
is_assignable<_Err&, _OtherErrQual>,
|
| 388 |
+
_Lazy<_Or,
|
| 389 |
+
is_nothrow_constructible<_Err, _OtherErrQual>,
|
| 390 |
+
is_nothrow_move_constructible<_Tp>,
|
| 391 |
+
is_nothrow_move_constructible<_Err>> >::value;
|
| 392 |
+
|
| 393 |
+
public:
|
| 394 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 395 |
+
_LIBCUDACXX_REQUIRES( __can_assign_from_unexpected<const _OtherErr&>)
|
| 396 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 397 |
+
expected& operator=(const unexpected<_OtherErr>& __un) {
|
| 398 |
+
if (this->__has_val_) {
|
| 399 |
+
this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, __un.error());
|
| 400 |
+
this->__has_val_ = false;
|
| 401 |
+
} else {
|
| 402 |
+
this->__union_.__unex_ = __un.error();
|
| 403 |
+
}
|
| 404 |
+
return *this;
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 408 |
+
_LIBCUDACXX_REQUIRES( __can_assign_from_unexpected<_OtherErr>)
|
| 409 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 410 |
+
expected& operator=(unexpected<_OtherErr>&& __un) {
|
| 411 |
+
if (this->__has_val_) {
|
| 412 |
+
this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, _CUDA_VSTD::move(__un.error()));
|
| 413 |
+
this->__has_val_ = false;
|
| 414 |
+
} else {
|
| 415 |
+
this->__union_.__unex_ = _CUDA_VSTD::move(__un.error());
|
| 416 |
+
}
|
| 417 |
+
return *this;
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
_LIBCUDACXX_TEMPLATE(class... _Args)
|
| 421 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 422 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 423 |
+
_Tp& emplace(_Args&&... __args) noexcept {
|
| 424 |
+
if (this->__has_val_) {
|
| 425 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__val_));
|
| 426 |
+
} else {
|
| 427 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));
|
| 428 |
+
this->__has_val_ = true;
|
| 429 |
+
}
|
| 430 |
+
return *_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::forward<_Args>(__args)...);
|
| 431 |
+
}
|
| 432 |
+
|
| 433 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class... _Args)
|
| 434 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, initializer_list<_Up>&, _Args...))
|
| 435 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 436 |
+
_Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept {
|
| 437 |
+
if (this->__has_val_) {
|
| 438 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__val_));
|
| 439 |
+
} else {
|
| 440 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));
|
| 441 |
+
this->__has_val_ = true;
|
| 442 |
+
}
|
| 443 |
+
return *_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __il, _CUDA_VSTD::forward<_Args>(__args)...);
|
| 444 |
+
}
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
public:
|
| 448 |
+
// [expected.object.swap], swap
|
| 449 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp, class _Err2 = _Err)
|
| 450 |
+
_LIBCUDACXX_REQUIRES( __expected::__can_swap<_Tp2, _Err2>)
|
| 451 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 452 |
+
void swap(expected<_Tp2, _Err>& __rhs)
|
| 453 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp2) &&
|
| 454 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Tp2) &&
|
| 455 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err) &&
|
| 456 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err))
|
| 457 |
+
{
|
| 458 |
+
if (this->__has_val_) {
|
| 459 |
+
if (__rhs.__has_val_) {
|
| 460 |
+
using _CUDA_VSTD::swap;
|
| 461 |
+
swap(this->__union_.__val_, __rhs.__union_.__val_);
|
| 462 |
+
} else {
|
| 463 |
+
this->__swap_val_unex_impl(*this, __rhs);
|
| 464 |
+
}
|
| 465 |
+
} else {
|
| 466 |
+
if (__rhs.__has_val_) {
|
| 467 |
+
this->__swap_val_unex_impl(__rhs, *this);
|
| 468 |
+
} else {
|
| 469 |
+
using _CUDA_VSTD::swap;
|
| 470 |
+
swap(this->__union_.__unex_, __rhs.__union_.__unex_);
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
template<class _Tp2 = _Tp, class _Err2 = _Err>
|
| 476 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 477 |
+
auto swap(expected& __x, expected& __y) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp2) &&
|
| 478 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Tp2) &&
|
| 479 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2) &&
|
| 480 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err2))
|
| 481 |
+
_LIBCUDACXX_TRAILING_REQUIRES(void)(__expected::__can_swap<_Tp2, _Err2>)
|
| 482 |
+
{
|
| 483 |
+
return __x.swap(__y); // some compiler warn about non void function without return
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
// [expected.object.obs], observers
|
| 487 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp* operator->() const noexcept {
|
| 488 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator-> requires the expected to contain a value");
|
| 489 |
+
return _CUDA_VSTD::addressof(this->__union_.__val_);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp* operator->() noexcept {
|
| 493 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator-> requires the expected to contain a value");
|
| 494 |
+
return _CUDA_VSTD::addressof(this->__union_.__val_);
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp& operator*() const& noexcept {
|
| 498 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");
|
| 499 |
+
return this->__union_.__val_;
|
| 500 |
+
}
|
| 501 |
+
|
| 502 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp& operator*() & noexcept {
|
| 503 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");
|
| 504 |
+
return this->__union_.__val_;
|
| 505 |
+
}
|
| 506 |
+
|
| 507 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp&& operator*() const&& noexcept {
|
| 508 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");
|
| 509 |
+
return _CUDA_VSTD::move(this->__union_.__val_);
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr _Tp&& operator*() && noexcept {
|
| 513 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");
|
| 514 |
+
return _CUDA_VSTD::move(this->__union_.__val_);
|
| 515 |
+
}
|
| 516 |
+
|
| 517 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr explicit operator bool() const noexcept { return this->__has_val_; }
|
| 518 |
+
|
| 519 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr bool has_value() const noexcept { return this->__has_val_; }
|
| 520 |
+
|
| 521 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Tp& value() const& {
|
| 522 |
+
if (!this->__has_val_) {
|
| 523 |
+
__expected::__throw_bad_expected_access<_Err>(this->__union_.__unex_);
|
| 524 |
+
}
|
| 525 |
+
return this->__union_.__val_;
|
| 526 |
+
}
|
| 527 |
+
|
| 528 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 529 |
+
_Tp& value() & {
|
| 530 |
+
if (!this->__has_val_) {
|
| 531 |
+
__expected::__throw_bad_expected_access<_Err>(this->__union_.__unex_);
|
| 532 |
+
}
|
| 533 |
+
return this->__union_.__val_;
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 537 |
+
const _Tp&& value() const&& {
|
| 538 |
+
if (!this->__has_val_) {
|
| 539 |
+
__expected::__throw_bad_expected_access<_Err>(_CUDA_VSTD::move(this->__union_.__unex_));
|
| 540 |
+
}
|
| 541 |
+
return _CUDA_VSTD::move(this->__union_.__val_);
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 545 |
+
_Tp&& value() && {
|
| 546 |
+
if (!this->__has_val_) {
|
| 547 |
+
__expected::__throw_bad_expected_access<_Err>(_CUDA_VSTD::move(this->__union_.__unex_));
|
| 548 |
+
}
|
| 549 |
+
return _CUDA_VSTD::move(this->__union_.__val_);
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 553 |
+
const _Err& error() const& noexcept {
|
| 554 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 555 |
+
return this->__union_.__unex_;
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 559 |
+
_Err& error() & noexcept {
|
| 560 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 561 |
+
return this->__union_.__unex_;
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 565 |
+
const _Err&& error() const&& noexcept {
|
| 566 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 567 |
+
return _CUDA_VSTD::move(this->__union_.__unex_);
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 571 |
+
_Err&& error() && noexcept {
|
| 572 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 573 |
+
return _CUDA_VSTD::move(this->__union_.__unex_);
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
template <class _Up>
|
| 577 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 578 |
+
_Tp value_or(_Up&& __v) const& {
|
| 579 |
+
static_assert(_LIBCUDACXX_TRAIT(is_copy_constructible, _Tp), "value_type has to be copy constructible");
|
| 580 |
+
static_assert(_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp), "argument has to be convertible to value_type");
|
| 581 |
+
return this->__has_val_ ? this->__union_.__val_ : static_cast<_Tp>(_CUDA_VSTD::forward<_Up>(__v));
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
template <class _Up>
|
| 585 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 586 |
+
_Tp value_or(_Up&& __v) && {
|
| 587 |
+
static_assert(_LIBCUDACXX_TRAIT(is_move_constructible, _Tp), "value_type has to be move constructible");
|
| 588 |
+
static_assert(_LIBCUDACXX_TRAIT(is_convertible, _Up, _Tp), "argument has to be convertible to value_type");
|
| 589 |
+
return this->__has_val_ ? _CUDA_VSTD::move(this->__union_.__val_) : static_cast<_Tp>(_CUDA_VSTD::forward<_Up>(__v));
|
| 590 |
+
}
|
| 591 |
+
|
| 592 |
+
// [expected.object.monadic]
|
| 593 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 594 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&))
|
| 595 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 596 |
+
auto and_then(_Fun&& __fun) & {
|
| 597 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Tp&>>;
|
| 598 |
+
|
| 599 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 600 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 601 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 602 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 603 |
+
|
| 604 |
+
if (this->__has_val_) {
|
| 605 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);
|
| 606 |
+
} else {
|
| 607 |
+
return _Res{unexpect, this->__union_.__unex_};
|
| 608 |
+
}
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 612 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2))
|
| 613 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 614 |
+
auto and_then(_Fun&& __fun) const& {
|
| 615 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Tp&>>;
|
| 616 |
+
|
| 617 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 618 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 619 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 620 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 621 |
+
|
| 622 |
+
if (this->__has_val_) {
|
| 623 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);
|
| 624 |
+
} else {
|
| 625 |
+
return _Res{unexpect, this->__union_.__unex_};
|
| 626 |
+
}
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 630 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2))
|
| 631 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 632 |
+
auto and_then(_Fun&& __fun) && {
|
| 633 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Tp>>;
|
| 634 |
+
|
| 635 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 636 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 637 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 638 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 639 |
+
|
| 640 |
+
if (this->__has_val_) {
|
| 641 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));
|
| 642 |
+
} else {
|
| 643 |
+
return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 644 |
+
}
|
| 645 |
+
}
|
| 646 |
+
|
| 647 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 648 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2))
|
| 649 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 650 |
+
auto and_then(_Fun&& __fun) const&& {
|
| 651 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Tp>>;
|
| 652 |
+
|
| 653 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 654 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 655 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 656 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 657 |
+
|
| 658 |
+
if (this->__has_val_) {
|
| 659 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));
|
| 660 |
+
} else {
|
| 661 |
+
return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 662 |
+
}
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 666 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, _Tp2&))
|
| 667 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 668 |
+
auto or_else(_Fun&& __fun) & {
|
| 669 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err&>>;
|
| 670 |
+
|
| 671 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 672 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 673 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),
|
| 674 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 675 |
+
|
| 676 |
+
if (this->__has_val_) {
|
| 677 |
+
return _Res{in_place, this->__union_.__val_};
|
| 678 |
+
} else {
|
| 679 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);
|
| 680 |
+
}
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 684 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Tp2))
|
| 685 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 686 |
+
auto or_else(_Fun&& __fun) const& {
|
| 687 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err&>>;
|
| 688 |
+
|
| 689 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 690 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 691 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),
|
| 692 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 693 |
+
|
| 694 |
+
if (this->__has_val_) {
|
| 695 |
+
return _Res{in_place, this->__union_.__val_};
|
| 696 |
+
} else {
|
| 697 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);
|
| 698 |
+
}
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 702 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Tp2))
|
| 703 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 704 |
+
auto or_else(_Fun&& __fun) && {
|
| 705 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err>>;
|
| 706 |
+
|
| 707 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 708 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 709 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),
|
| 710 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 711 |
+
|
| 712 |
+
if (this->__has_val_) {
|
| 713 |
+
return _Res{in_place, _CUDA_VSTD::move(this->__union_.__val_)};
|
| 714 |
+
} else {
|
| 715 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));
|
| 716 |
+
}
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 720 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, const _Tp2))
|
| 721 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 722 |
+
auto or_else(_Fun&& __fun) const&& {
|
| 723 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err>>;
|
| 724 |
+
|
| 725 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 726 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 727 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, _Tp),
|
| 728 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 729 |
+
|
| 730 |
+
if (this->__has_val_) {
|
| 731 |
+
return _Res{in_place, _CUDA_VSTD::move(this->__union_.__val_)};
|
| 732 |
+
} else {
|
| 733 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));
|
| 734 |
+
}
|
| 735 |
+
}
|
| 736 |
+
|
| 737 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 738 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND
|
| 739 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2&>>, void))
|
| 740 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 741 |
+
auto transform(_Fun&& __fun) & {
|
| 742 |
+
static_assert(invocable<_Fun, _Tp&>,
|
| 743 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 744 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp&>>;
|
| 745 |
+
|
| 746 |
+
if (this->__has_val_) {
|
| 747 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);
|
| 748 |
+
return expected<void, _Err>{};
|
| 749 |
+
} else {
|
| 750 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 751 |
+
}
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 755 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND
|
| 756 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2&>>, void)))
|
| 757 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 758 |
+
auto transform(_Fun&& __fun) & {
|
| 759 |
+
static_assert(invocable<_Fun, _Tp&>,
|
| 760 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 761 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp&>>;
|
| 762 |
+
|
| 763 |
+
static_assert(__invoke_constructible<_Fun, _Tp&>,
|
| 764 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 765 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 766 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 767 |
+
|
| 768 |
+
if (this->__has_val_) {
|
| 769 |
+
return expected<_Res, _Err>{
|
| 770 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_};
|
| 771 |
+
} else {
|
| 772 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 773 |
+
}
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 777 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND
|
| 778 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2&>>, void))
|
| 779 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 780 |
+
auto transform(_Fun&& __fun) const& {
|
| 781 |
+
static_assert(invocable<_Fun, const _Tp&>,
|
| 782 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 783 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp&>>;
|
| 784 |
+
|
| 785 |
+
if (this->__has_val_) {
|
| 786 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_);
|
| 787 |
+
return expected<_Res, _Err>{};
|
| 788 |
+
} else {
|
| 789 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 790 |
+
}
|
| 791 |
+
}
|
| 792 |
+
|
| 793 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 794 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND
|
| 795 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2&>>, void)))
|
| 796 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 797 |
+
auto transform(_Fun&& __fun) const& {
|
| 798 |
+
static_assert(invocable<_Fun, const _Tp&>,
|
| 799 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 800 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp&>>;
|
| 801 |
+
|
| 802 |
+
static_assert(__invoke_constructible<_Fun, const _Tp&>,
|
| 803 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 804 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 805 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 806 |
+
|
| 807 |
+
if (this->__has_val_) {
|
| 808 |
+
return expected<_Res, _Err>{
|
| 809 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__val_};
|
| 810 |
+
} else {
|
| 811 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 812 |
+
}
|
| 813 |
+
}
|
| 814 |
+
|
| 815 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 816 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND
|
| 817 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2>>, void))
|
| 818 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 819 |
+
auto transform(_Fun&& __fun) && {
|
| 820 |
+
static_assert(invocable<_Fun, _Tp>,
|
| 821 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 822 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp>>;
|
| 823 |
+
|
| 824 |
+
if (this->__has_val_) {
|
| 825 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));
|
| 826 |
+
return expected<_Res, _Err>{};
|
| 827 |
+
} else {
|
| 828 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 829 |
+
}
|
| 830 |
+
}
|
| 831 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 832 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND
|
| 833 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, _Tp2>>, void)))
|
| 834 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 835 |
+
auto transform(_Fun&& __fun) && {
|
| 836 |
+
static_assert(invocable<_Fun, _Tp>,
|
| 837 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 838 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Tp>>;
|
| 839 |
+
|
| 840 |
+
static_assert(__invoke_constructible<_Fun, _Tp>,
|
| 841 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 842 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 843 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 844 |
+
|
| 845 |
+
if (this->__has_val_) {
|
| 846 |
+
return expected<_Res, _Err>{
|
| 847 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_)};
|
| 848 |
+
} else {
|
| 849 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 850 |
+
}
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 854 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND
|
| 855 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2>>, void))
|
| 856 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 857 |
+
auto transform(_Fun&& __fun) const&& {
|
| 858 |
+
static_assert(invocable<_Fun, const _Tp>,
|
| 859 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 860 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp>>;
|
| 861 |
+
|
| 862 |
+
if (this->__has_val_) {
|
| 863 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_));
|
| 864 |
+
return expected<_Res, _Err>{};
|
| 865 |
+
} else {
|
| 866 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 867 |
+
}
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp, class _Err2 = _Err)
|
| 871 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND
|
| 872 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun, const _Tp2>>, void)))
|
| 873 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 874 |
+
auto transform(_Fun&& __fun) const&& {
|
| 875 |
+
static_assert(invocable<_Fun, const _Tp>,
|
| 876 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 877 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Tp>>;
|
| 878 |
+
|
| 879 |
+
static_assert(__invoke_constructible<_Fun, const _Tp>,
|
| 880 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 881 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 882 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 883 |
+
|
| 884 |
+
if (this->__has_val_) {
|
| 885 |
+
return expected<_Res, _Err>{
|
| 886 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__val_)};
|
| 887 |
+
} else {
|
| 888 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 889 |
+
}
|
| 890 |
+
}
|
| 891 |
+
|
| 892 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 893 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, _Tp2&))
|
| 894 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 895 |
+
auto transform_error(_Fun&& __fun) & {
|
| 896 |
+
static_assert(invocable<_Fun, _Err&>,
|
| 897 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 898 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err&>>;
|
| 899 |
+
|
| 900 |
+
static_assert(__invoke_constructible<_Fun, _Err&>,
|
| 901 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 902 |
+
static_assert(__expected::__valid_expected<_Tp, _Res>,
|
| 903 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 904 |
+
|
| 905 |
+
if (this->__has_val_) {
|
| 906 |
+
return expected<_Tp, _Res>{in_place, this->__union_.__val_};
|
| 907 |
+
} else {
|
| 908 |
+
return expected<_Tp, _Res>{
|
| 909 |
+
__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};
|
| 910 |
+
}
|
| 911 |
+
}
|
| 912 |
+
|
| 913 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 914 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Tp2))
|
| 915 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 916 |
+
auto transform_error(_Fun&& __fun) const& {
|
| 917 |
+
static_assert(invocable<_Fun, const _Err&>,
|
| 918 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 919 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err&>>;
|
| 920 |
+
|
| 921 |
+
static_assert(__invoke_constructible<_Fun, const _Err&>,
|
| 922 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 923 |
+
static_assert(__expected::__valid_expected<_Tp, _Res>,
|
| 924 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 925 |
+
|
| 926 |
+
if (this->__has_val_) {
|
| 927 |
+
return expected<_Tp, _Res>{in_place, this->__union_.__val_};
|
| 928 |
+
} else {
|
| 929 |
+
return expected<_Tp, _Res>{
|
| 930 |
+
__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};
|
| 931 |
+
}
|
| 932 |
+
}
|
| 933 |
+
|
| 934 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 935 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Tp2))
|
| 936 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 937 |
+
auto transform_error(_Fun&& __fun) && {
|
| 938 |
+
static_assert(invocable<_Fun, _Err>,
|
| 939 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 940 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err>>;
|
| 941 |
+
|
| 942 |
+
static_assert(__invoke_constructible<_Fun, _Err>,
|
| 943 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 944 |
+
static_assert(__expected::__valid_expected<_Tp, _Res>,
|
| 945 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 946 |
+
|
| 947 |
+
if (this->__has_val_) {
|
| 948 |
+
return expected<_Tp, _Res>{in_place, _CUDA_VSTD::move(this->__union_.__val_)};
|
| 949 |
+
} else {
|
| 950 |
+
return expected<_Tp, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),
|
| 951 |
+
_CUDA_VSTD::move(this->__union_.__unex_)};
|
| 952 |
+
}
|
| 953 |
+
}
|
| 954 |
+
|
| 955 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Tp2 = _Tp)
|
| 956 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Tp2, const _Tp2))
|
| 957 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 958 |
+
auto transform_error(_Fun&& __fun) const&& {
|
| 959 |
+
static_assert(invocable<_Fun, const _Err>,
|
| 960 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 961 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err>>;
|
| 962 |
+
|
| 963 |
+
static_assert(__invoke_constructible<_Fun, const _Err>,
|
| 964 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 965 |
+
static_assert(__expected::__valid_expected<_Tp, _Res>,
|
| 966 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 967 |
+
|
| 968 |
+
if (this->__has_val_) {
|
| 969 |
+
return expected<_Tp, _Res>{in_place, _CUDA_VSTD::move(this->__union_.__val_)};
|
| 970 |
+
} else {
|
| 971 |
+
return expected<_Tp, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),
|
| 972 |
+
_CUDA_VSTD::move(this->__union_.__unex_)};
|
| 973 |
+
}
|
| 974 |
+
}
|
| 975 |
+
|
| 976 |
+
// [expected.object.eq], equality operators
|
| 977 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 978 |
+
bool operator==(const expected& __x, const expected& __y) {
|
| 979 |
+
if (__x.__has_val_ != __y.has_value()) {
|
| 980 |
+
return false;
|
| 981 |
+
} else {
|
| 982 |
+
if (__x.__has_val_) {
|
| 983 |
+
return __x.__union_.__val_ == __y.value();
|
| 984 |
+
} else {
|
| 985 |
+
return __x.__union_.__unex_ == __y.error();
|
| 986 |
+
}
|
| 987 |
+
}
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 991 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 992 |
+
bool operator!=(const expected& __x, const expected& __y) {
|
| 993 |
+
return !(__x == __y);
|
| 994 |
+
}
|
| 995 |
+
#endif // _LIBCUDACXX_STD_VER < 20
|
| 996 |
+
|
| 997 |
+
_LIBCUDACXX_TEMPLATE(class _T2, class _E2)
|
| 998 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_void, _T2)))
|
| 999 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1000 |
+
bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {
|
| 1001 |
+
if (__x.__has_val_ != __y.has_value()) {
|
| 1002 |
+
return false;
|
| 1003 |
+
} else {
|
| 1004 |
+
if (__x.__has_val_) {
|
| 1005 |
+
return __x.__union_.__val_ == __y.value();
|
| 1006 |
+
} else {
|
| 1007 |
+
return __x.__union_.__unex_ == __y.error();
|
| 1008 |
+
}
|
| 1009 |
+
}
|
| 1010 |
+
}
|
| 1011 |
+
|
| 1012 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1013 |
+
_LIBCUDACXX_TEMPLATE(class _T2, class _E2)
|
| 1014 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_void, _T2)))
|
| 1015 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1016 |
+
bool operator!=(const expected& __x, const expected<_T2, _E2>& __y) {
|
| 1017 |
+
return !(__x == __y);
|
| 1018 |
+
}
|
| 1019 |
+
#endif // _LIBCUDACXX_STD_VER < 20
|
| 1020 |
+
|
| 1021 |
+
_LIBCUDACXX_TEMPLATE(class _T2)
|
| 1022 |
+
_LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))
|
| 1023 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1024 |
+
bool operator==(const expected& __x, const _T2& __v) {
|
| 1025 |
+
return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);
|
| 1026 |
+
}
|
| 1027 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1028 |
+
_LIBCUDACXX_TEMPLATE(class _T2)
|
| 1029 |
+
_LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))
|
| 1030 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1031 |
+
bool operator==(const _T2& __v, const expected& __x) {
|
| 1032 |
+
return __x.__has_val_ && static_cast<bool>(__x.__union_.__val_ == __v);
|
| 1033 |
+
}
|
| 1034 |
+
_LIBCUDACXX_TEMPLATE(class _T2)
|
| 1035 |
+
_LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))
|
| 1036 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1037 |
+
bool operator!=(const expected& __x, const _T2& __v) {
|
| 1038 |
+
return !__x.__has_val_ || static_cast<bool>(__x.__union_.__val_ != __v);
|
| 1039 |
+
}
|
| 1040 |
+
_LIBCUDACXX_TEMPLATE(class _T2)
|
| 1041 |
+
_LIBCUDACXX_REQUIRES( (!__expected::__is_expected_nonvoid<_T2>))
|
| 1042 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1043 |
+
bool operator!=(const _T2& __v, const expected& __x) {
|
| 1044 |
+
return !__x.__has_val_ || static_cast<bool>(__x.__union_.__val_ != __v);
|
| 1045 |
+
}
|
| 1046 |
+
#endif // _LIBCUDACXX_STD_VER < 20
|
| 1047 |
+
|
| 1048 |
+
template <class _E2>
|
| 1049 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1050 |
+
bool operator==(const expected& __x, const unexpected<_E2>& __e) {
|
| 1051 |
+
return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());
|
| 1052 |
+
}
|
| 1053 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1054 |
+
template <class _E2>
|
| 1055 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1056 |
+
bool operator==(const unexpected<_E2>& __e, const expected& __x) {
|
| 1057 |
+
return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __e.error());
|
| 1058 |
+
}
|
| 1059 |
+
template <class _E2>
|
| 1060 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1061 |
+
bool operator!=(const expected& __x, const unexpected<_E2>& __e) {
|
| 1062 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __e.error());
|
| 1063 |
+
}
|
| 1064 |
+
template <class _E2>
|
| 1065 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1066 |
+
bool operator!=(const unexpected<_E2>& __e, const expected& __x) {
|
| 1067 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __e.error());
|
| 1068 |
+
}
|
| 1069 |
+
#endif // _LIBCUDACXX_STD_VER < 20
|
| 1070 |
+
};
|
| 1071 |
+
|
| 1072 |
+
|
| 1073 |
+
template <class _Err>
|
| 1074 |
+
class expected<void, _Err> : private __expected_move_assign<void, _Err>
|
| 1075 |
+
, private __expected_void_sfinae_ctor_base_t<_Err>
|
| 1076 |
+
, private __expected_void_sfinae_assign_base_t<_Err>
|
| 1077 |
+
{
|
| 1078 |
+
using __base = __expected_move_assign<void, _Err>;
|
| 1079 |
+
static_assert(__unexpected::__valid_unexpected<_Err>,
|
| 1080 |
+
"[expected.void.general] A program that instantiates expected<T, E> with a E that is not a "
|
| 1081 |
+
"valid argument for unexpected<E> is ill-formed");
|
| 1082 |
+
|
| 1083 |
+
template <class, class>
|
| 1084 |
+
friend class expected;
|
| 1085 |
+
|
| 1086 |
+
template <class _Up, class _OtherErr, class _OtherErrQual>
|
| 1087 |
+
using __can_convert =
|
| 1088 |
+
_And< is_void<_Up>,
|
| 1089 |
+
is_constructible<_Err, _OtherErrQual>,
|
| 1090 |
+
_Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>&>>,
|
| 1091 |
+
_Not<is_constructible<unexpected<_Err>, expected<_Up, _OtherErr>>>,
|
| 1092 |
+
_Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>&>>,
|
| 1093 |
+
_Not<is_constructible<unexpected<_Err>, const expected<_Up, _OtherErr>>>>;
|
| 1094 |
+
|
| 1095 |
+
public:
|
| 1096 |
+
using value_type = void;
|
| 1097 |
+
using error_type = _Err;
|
| 1098 |
+
using unexpected_type = unexpected<_Err>;
|
| 1099 |
+
|
| 1100 |
+
template <class _Up>
|
| 1101 |
+
using rebind = expected<_Up, error_type>;
|
| 1102 |
+
|
| 1103 |
+
// [expected.void.ctor], constructors
|
| 1104 |
+
constexpr expected() = default;
|
| 1105 |
+
constexpr expected(const expected&) = default;
|
| 1106 |
+
constexpr expected(expected&&) = default;
|
| 1107 |
+
constexpr expected& operator=(const expected&) = default;
|
| 1108 |
+
constexpr expected& operator=(expected&&) = default;
|
| 1109 |
+
|
| 1110 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 1111 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCUDACXX_AND
|
| 1112 |
+
_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)
|
| 1113 |
+
)
|
| 1114 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1115 |
+
expected(const expected<_Up, _OtherErr>& __other)
|
| 1116 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 1117 |
+
: __base(__other.__has_val_)
|
| 1118 |
+
{
|
| 1119 |
+
if (!__other.__has_val_) {
|
| 1120 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 1121 |
+
}
|
| 1122 |
+
}
|
| 1123 |
+
|
| 1124 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 1125 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCUDACXX_AND
|
| 1126 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))
|
| 1127 |
+
)
|
| 1128 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1129 |
+
explicit expected(const expected<_Up, _OtherErr>& __other)
|
| 1130 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 1131 |
+
: __base(__other.__has_val_)
|
| 1132 |
+
{
|
| 1133 |
+
if (!__other.__has_val_) {
|
| 1134 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 1135 |
+
}
|
| 1136 |
+
}
|
| 1137 |
+
|
| 1138 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 1139 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCUDACXX_AND
|
| 1140 |
+
_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err)
|
| 1141 |
+
)
|
| 1142 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1143 |
+
expected(expected<_Up, _OtherErr>&& __other)
|
| 1144 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 1145 |
+
: __base(__other.__has_val_)
|
| 1146 |
+
{
|
| 1147 |
+
if (!__other.__has_val_) {
|
| 1148 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 1149 |
+
}
|
| 1150 |
+
}
|
| 1151 |
+
|
| 1152 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class _OtherErr)
|
| 1153 |
+
_LIBCUDACXX_REQUIRES( __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCUDACXX_AND
|
| 1154 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))
|
| 1155 |
+
)
|
| 1156 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1157 |
+
explicit expected(expected<_Up, _OtherErr>&& __other)
|
| 1158 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 1159 |
+
: __base(__other.__has_val_)
|
| 1160 |
+
{
|
| 1161 |
+
if (!__other.__has_val_) {
|
| 1162 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 1163 |
+
}
|
| 1164 |
+
}
|
| 1165 |
+
|
| 1166 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1167 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND
|
| 1168 |
+
_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err)
|
| 1169 |
+
)
|
| 1170 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1171 |
+
expected(const unexpected<_OtherErr>& __unex)
|
| 1172 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 1173 |
+
: __base(unexpect, __unex.error())
|
| 1174 |
+
{}
|
| 1175 |
+
|
| 1176 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1177 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND
|
| 1178 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, const _OtherErr&, _Err))
|
| 1179 |
+
)
|
| 1180 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1181 |
+
explicit expected(const unexpected<_OtherErr>& __unex)
|
| 1182 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 1183 |
+
: __base(unexpect, __unex.error())
|
| 1184 |
+
{}
|
| 1185 |
+
|
| 1186 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1187 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND
|
| 1188 |
+
_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))
|
| 1189 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1190 |
+
expected(unexpected<_OtherErr>&& __unex)
|
| 1191 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 1192 |
+
: __base(unexpect, _CUDA_VSTD::move(__unex.error()))
|
| 1193 |
+
{}
|
| 1194 |
+
|
| 1195 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1196 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND
|
| 1197 |
+
(!_LIBCUDACXX_TRAIT(is_convertible, _OtherErr, _Err))
|
| 1198 |
+
)
|
| 1199 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1200 |
+
explicit expected(unexpected<_OtherErr>&& __unex)
|
| 1201 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr)) // strengthened
|
| 1202 |
+
: __base(unexpect, _CUDA_VSTD::move(__unex.error()))
|
| 1203 |
+
{}
|
| 1204 |
+
|
| 1205 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1206 |
+
explicit expected(in_place_t) noexcept : __base(true) {}
|
| 1207 |
+
|
| 1208 |
+
_LIBCUDACXX_TEMPLATE(class... _Args)
|
| 1209 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _Args...))
|
| 1210 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1211 |
+
explicit expected(unexpect_t, _Args&&... __args)
|
| 1212 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...)) // strengthened
|
| 1213 |
+
: __base(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 1214 |
+
{}
|
| 1215 |
+
|
| 1216 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class... _Args)
|
| 1217 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, initializer_list<_Up>&, _Args...))
|
| 1218 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1219 |
+
explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args)
|
| 1220 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, initializer_list<_Up>, _Args...)) // strengthened
|
| 1221 |
+
: __base(unexpect, __il, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 1222 |
+
{}
|
| 1223 |
+
|
| 1224 |
+
private:
|
| 1225 |
+
template<class _Fun, class... _Args>
|
| 1226 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1227 |
+
expected(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 1228 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 1229 |
+
: __base(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 1230 |
+
{}
|
| 1231 |
+
|
| 1232 |
+
public:
|
| 1233 |
+
|
| 1234 |
+
// [expected.void.dtor], destructor
|
| 1235 |
+
// [expected.void.assign], assignment
|
| 1236 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1237 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, const _OtherErr&) _LIBCUDACXX_AND
|
| 1238 |
+
_LIBCUDACXX_TRAIT(is_assignable, _Err&, const _OtherErr&)
|
| 1239 |
+
)
|
| 1240 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1241 |
+
expected& operator=(const unexpected<_OtherErr>& __un)
|
| 1242 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_assignable, _Err&, const _OtherErr&) &&
|
| 1243 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, const _OtherErr&)) // strengthened
|
| 1244 |
+
{
|
| 1245 |
+
if (this->__has_val_) {
|
| 1246 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __un.error());
|
| 1247 |
+
this->__has_val_ = false;
|
| 1248 |
+
} else {
|
| 1249 |
+
this->__union_.__unex_ = __un.error();
|
| 1250 |
+
}
|
| 1251 |
+
return *this;
|
| 1252 |
+
}
|
| 1253 |
+
|
| 1254 |
+
_LIBCUDACXX_TEMPLATE(class _OtherErr)
|
| 1255 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _OtherErr) _LIBCUDACXX_AND
|
| 1256 |
+
_LIBCUDACXX_TRAIT(is_assignable, _Err&, _OtherErr)
|
| 1257 |
+
)
|
| 1258 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1259 |
+
expected& operator=(unexpected<_OtherErr>&& __un)
|
| 1260 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_assignable, _Err&, _OtherErr) &&
|
| 1261 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _OtherErr))
|
| 1262 |
+
{
|
| 1263 |
+
if (this->__has_val_) {
|
| 1264 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__un.error()));
|
| 1265 |
+
this->__has_val_ = false;
|
| 1266 |
+
} else {
|
| 1267 |
+
this->__union_.__unex_ = _CUDA_VSTD::move(__un.error());
|
| 1268 |
+
}
|
| 1269 |
+
return *this;
|
| 1270 |
+
}
|
| 1271 |
+
|
| 1272 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1273 |
+
void emplace() noexcept
|
| 1274 |
+
{
|
| 1275 |
+
if (!this->__has_val_) {
|
| 1276 |
+
this->__union_.__unex_.~_Err();
|
| 1277 |
+
this->__has_val_ = true;
|
| 1278 |
+
}
|
| 1279 |
+
}
|
| 1280 |
+
|
| 1281 |
+
// [expected.void.swap], swap
|
| 1282 |
+
_LIBCUDACXX_TEMPLATE(class _Err2 = _Err)
|
| 1283 |
+
_LIBCUDACXX_REQUIRES( __expected::__can_swap<void, _Err2>)
|
| 1284 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1285 |
+
void swap(expected<void, _Err2>& __rhs) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2) &&
|
| 1286 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err2))
|
| 1287 |
+
{
|
| 1288 |
+
if (this->__has_val_) {
|
| 1289 |
+
if (!__rhs.__has_val_) {
|
| 1290 |
+
this->__swap_val_unex_impl(*this, __rhs);
|
| 1291 |
+
}
|
| 1292 |
+
} else {
|
| 1293 |
+
if (__rhs.__has_val_) {
|
| 1294 |
+
this->__swap_val_unex_impl(__rhs, *this);
|
| 1295 |
+
} else {
|
| 1296 |
+
using _CUDA_VSTD::swap;
|
| 1297 |
+
swap(this->__union_.__unex_, __rhs.__union_.__unex_);
|
| 1298 |
+
}
|
| 1299 |
+
}
|
| 1300 |
+
}
|
| 1301 |
+
|
| 1302 |
+
template<class _Err2 = _Err>
|
| 1303 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1304 |
+
auto swap(expected& __x, expected& __y) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2) &&
|
| 1305 |
+
_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err2))
|
| 1306 |
+
_LIBCUDACXX_TRAILING_REQUIRES(void)(__expected::__can_swap<void, _Err2>)
|
| 1307 |
+
{
|
| 1308 |
+
return __x.swap(__y); // some compiler warn about non void function without return
|
| 1309 |
+
}
|
| 1310 |
+
|
| 1311 |
+
// [expected.void.obs], observers
|
| 1312 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1313 |
+
constexpr explicit operator bool() const noexcept { return this->__has_val_; }
|
| 1314 |
+
|
| 1315 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1316 |
+
constexpr bool has_value() const noexcept { return this->__has_val_; }
|
| 1317 |
+
|
| 1318 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1319 |
+
constexpr void operator*() const noexcept {
|
| 1320 |
+
_LIBCUDACXX_ASSERT(this->__has_val_, "expected::operator* requires the expected to contain a value");
|
| 1321 |
+
}
|
| 1322 |
+
|
| 1323 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1324 |
+
constexpr void value() const& {
|
| 1325 |
+
if (!this->__has_val_) {
|
| 1326 |
+
__expected::__throw_bad_expected_access<_Err>(this->__union_.__unex_);
|
| 1327 |
+
}
|
| 1328 |
+
}
|
| 1329 |
+
|
| 1330 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1331 |
+
constexpr void value() && {
|
| 1332 |
+
if (!this->__has_val_) {
|
| 1333 |
+
__expected::__throw_bad_expected_access<_Err>(_CUDA_VSTD::move(this->__union_.__unex_));
|
| 1334 |
+
}
|
| 1335 |
+
}
|
| 1336 |
+
|
| 1337 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1338 |
+
constexpr const _Err& error() const& noexcept {
|
| 1339 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 1340 |
+
return this->__union_.__unex_;
|
| 1341 |
+
}
|
| 1342 |
+
|
| 1343 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1344 |
+
constexpr _Err& error() & noexcept {
|
| 1345 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 1346 |
+
return this->__union_.__unex_;
|
| 1347 |
+
}
|
| 1348 |
+
|
| 1349 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1350 |
+
constexpr const _Err&& error() const&& noexcept {
|
| 1351 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 1352 |
+
return _CUDA_VSTD::move(this->__union_.__unex_);
|
| 1353 |
+
}
|
| 1354 |
+
|
| 1355 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1356 |
+
constexpr _Err&& error() && noexcept {
|
| 1357 |
+
_LIBCUDACXX_ASSERT(!this->__has_val_, "expected::error requires the expected to contain an error");
|
| 1358 |
+
return _CUDA_VSTD::move(this->__union_.__unex_);
|
| 1359 |
+
}
|
| 1360 |
+
|
| 1361 |
+
// [expected.void.monadic]
|
| 1362 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1363 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&))
|
| 1364 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1365 |
+
auto and_then(_Fun&& __fun) & {
|
| 1366 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun>>;
|
| 1367 |
+
|
| 1368 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1369 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 1370 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 1371 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 1372 |
+
|
| 1373 |
+
if (this->__has_val_) {
|
| 1374 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1375 |
+
} else {
|
| 1376 |
+
return _Res{unexpect, this->__union_.__unex_};
|
| 1377 |
+
}
|
| 1378 |
+
}
|
| 1379 |
+
|
| 1380 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1381 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2))
|
| 1382 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1383 |
+
auto and_then(_Fun&& __fun) const& {
|
| 1384 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun>>;
|
| 1385 |
+
|
| 1386 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1387 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 1388 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 1389 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 1390 |
+
|
| 1391 |
+
if (this->__has_val_) {
|
| 1392 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1393 |
+
} else {
|
| 1394 |
+
return _Res{unexpect, this->__union_.__unex_};
|
| 1395 |
+
}
|
| 1396 |
+
}
|
| 1397 |
+
|
| 1398 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1399 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2))
|
| 1400 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1401 |
+
auto and_then(_Fun&& __fun) && {
|
| 1402 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun>>;
|
| 1403 |
+
|
| 1404 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1405 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 1406 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 1407 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 1408 |
+
|
| 1409 |
+
if (this->__has_val_) {
|
| 1410 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1411 |
+
} else {
|
| 1412 |
+
return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1413 |
+
}
|
| 1414 |
+
}
|
| 1415 |
+
|
| 1416 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1417 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2))
|
| 1418 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1419 |
+
auto and_then(_Fun&& __fun) const&& {
|
| 1420 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun>>;
|
| 1421 |
+
|
| 1422 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1423 |
+
"Result of f(value()) must be a specialization of std::expected");
|
| 1424 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::error_type, _Err),
|
| 1425 |
+
"The error type of the result of f(value()) must be the same as that of std::expected");
|
| 1426 |
+
|
| 1427 |
+
if (this->__has_val_) {
|
| 1428 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1429 |
+
} else {
|
| 1430 |
+
return _Res{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1431 |
+
}
|
| 1432 |
+
}
|
| 1433 |
+
|
| 1434 |
+
template<class _Fun>
|
| 1435 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1436 |
+
auto or_else(_Fun&& __fun) & {
|
| 1437 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err&>>;
|
| 1438 |
+
|
| 1439 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1440 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 1441 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, void),
|
| 1442 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 1443 |
+
|
| 1444 |
+
if (this->__has_val_) {
|
| 1445 |
+
return _Res{};
|
| 1446 |
+
} else {
|
| 1447 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);
|
| 1448 |
+
}
|
| 1449 |
+
}
|
| 1450 |
+
|
| 1451 |
+
template<class _Fun>
|
| 1452 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1453 |
+
auto or_else(_Fun&& __fun) const& {
|
| 1454 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err&>>;
|
| 1455 |
+
|
| 1456 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1457 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 1458 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, void),
|
| 1459 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 1460 |
+
|
| 1461 |
+
if (this->__has_val_) {
|
| 1462 |
+
return _Res{};
|
| 1463 |
+
} else {
|
| 1464 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_);
|
| 1465 |
+
}
|
| 1466 |
+
}
|
| 1467 |
+
|
| 1468 |
+
template<class _Fun>
|
| 1469 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1470 |
+
auto or_else(_Fun&& __fun) && {
|
| 1471 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, _Err>>;
|
| 1472 |
+
|
| 1473 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1474 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 1475 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, void),
|
| 1476 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 1477 |
+
|
| 1478 |
+
if (this->__has_val_) {
|
| 1479 |
+
return _Res{};
|
| 1480 |
+
} else {
|
| 1481 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));
|
| 1482 |
+
}
|
| 1483 |
+
}
|
| 1484 |
+
|
| 1485 |
+
template<class _Fun>
|
| 1486 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1487 |
+
auto or_else(_Fun&& __fun) const&& {
|
| 1488 |
+
using _Res = __remove_cvref_t<invoke_result_t<_Fun, const _Err>>;
|
| 1489 |
+
|
| 1490 |
+
static_assert(__expected::__is_expected<_Res>,
|
| 1491 |
+
"Result of std::expected::or_else must be a specialization of std::expected");
|
| 1492 |
+
static_assert(_LIBCUDACXX_TRAIT(is_same, typename _Res::value_type, void),
|
| 1493 |
+
"The value type of the result of std::expected::or_else must be the same as that of std::expected");
|
| 1494 |
+
|
| 1495 |
+
if (this->__has_val_) {
|
| 1496 |
+
return _Res{};
|
| 1497 |
+
} else {
|
| 1498 |
+
return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::move(this->__union_.__unex_));
|
| 1499 |
+
}
|
| 1500 |
+
}
|
| 1501 |
+
|
| 1502 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1503 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND
|
| 1504 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void))
|
| 1505 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1506 |
+
auto transform(_Fun&& __fun) & {
|
| 1507 |
+
static_assert(invocable<_Fun>,
|
| 1508 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 1509 |
+
if (this->__has_val_) {
|
| 1510 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1511 |
+
return expected<void, _Err>{};
|
| 1512 |
+
} else {
|
| 1513 |
+
return expected<void, _Err>{unexpect, this->__union_.__unex_};
|
| 1514 |
+
}
|
| 1515 |
+
}
|
| 1516 |
+
|
| 1517 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1518 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, _Err2&) _LIBCUDACXX_AND
|
| 1519 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void)))
|
| 1520 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1521 |
+
auto transform(_Fun&& __fun) & {
|
| 1522 |
+
static_assert(invocable<_Fun>,
|
| 1523 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 1524 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun>>;
|
| 1525 |
+
|
| 1526 |
+
static_assert(__invoke_constructible<_Fun>,
|
| 1527 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 1528 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 1529 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 1530 |
+
|
| 1531 |
+
if (this->__has_val_) {
|
| 1532 |
+
return expected<_Res, _Err>{
|
| 1533 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun)};
|
| 1534 |
+
} else {
|
| 1535 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 1536 |
+
}
|
| 1537 |
+
}
|
| 1538 |
+
|
| 1539 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1540 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND
|
| 1541 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void))
|
| 1542 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1543 |
+
auto transform(_Fun&& __fun) const& {
|
| 1544 |
+
static_assert(invocable<_Fun>,
|
| 1545 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 1546 |
+
if (this->__has_val_) {
|
| 1547 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1548 |
+
return expected<void, _Err>{};
|
| 1549 |
+
} else {
|
| 1550 |
+
return expected<void, _Err>{unexpect, this->__union_.__unex_};
|
| 1551 |
+
}
|
| 1552 |
+
}
|
| 1553 |
+
|
| 1554 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1555 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_copy_constructible, _Err2) _LIBCUDACXX_AND
|
| 1556 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void)))
|
| 1557 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1558 |
+
auto transform(_Fun&& __fun) const& {
|
| 1559 |
+
static_assert(invocable<_Fun>,
|
| 1560 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 1561 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun>>;
|
| 1562 |
+
|
| 1563 |
+
static_assert(__invoke_constructible<_Fun>,
|
| 1564 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 1565 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 1566 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 1567 |
+
|
| 1568 |
+
if (this->__has_val_) {
|
| 1569 |
+
return expected<_Res, _Err>{
|
| 1570 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun)};
|
| 1571 |
+
} else {
|
| 1572 |
+
return expected<_Res, _Err>{unexpect, this->__union_.__unex_};
|
| 1573 |
+
}
|
| 1574 |
+
}
|
| 1575 |
+
|
| 1576 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1577 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND
|
| 1578 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void))
|
| 1579 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1580 |
+
auto transform(_Fun&& __fun) && {
|
| 1581 |
+
static_assert(invocable<_Fun>,
|
| 1582 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 1583 |
+
if (this->__has_val_) {
|
| 1584 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1585 |
+
return expected<void, _Err>{};
|
| 1586 |
+
} else {
|
| 1587 |
+
return expected<void, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1588 |
+
}
|
| 1589 |
+
}
|
| 1590 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1591 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_move_constructible, _Err2) _LIBCUDACXX_AND
|
| 1592 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void)))
|
| 1593 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1594 |
+
auto transform(_Fun&& __fun) && {
|
| 1595 |
+
static_assert(invocable<_Fun>,
|
| 1596 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 1597 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun>>;
|
| 1598 |
+
|
| 1599 |
+
static_assert(__invoke_constructible<_Fun>,
|
| 1600 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 1601 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 1602 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 1603 |
+
|
| 1604 |
+
if (this->__has_val_) {
|
| 1605 |
+
return expected<_Res, _Err>{
|
| 1606 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun)};
|
| 1607 |
+
} else {
|
| 1608 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1609 |
+
}
|
| 1610 |
+
}
|
| 1611 |
+
|
| 1612 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1613 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND
|
| 1614 |
+
_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void))
|
| 1615 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1616 |
+
auto transform(_Fun&& __fun) const&& {
|
| 1617 |
+
static_assert(invocable<_Fun>,
|
| 1618 |
+
"std::expected::transform requires that F must be invocable with T.");
|
| 1619 |
+
if (this->__has_val_) {
|
| 1620 |
+
_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun));
|
| 1621 |
+
return expected<void, _Err>{};
|
| 1622 |
+
} else {
|
| 1623 |
+
return expected<void, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1624 |
+
}
|
| 1625 |
+
}
|
| 1626 |
+
|
| 1627 |
+
_LIBCUDACXX_TEMPLATE(class _Fun, class _Err2 = _Err)
|
| 1628 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err2, const _Err2) _LIBCUDACXX_AND
|
| 1629 |
+
(!_LIBCUDACXX_TRAIT(is_same, __remove_cv_t<invoke_result_t<_Fun>>, void)))
|
| 1630 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1631 |
+
auto transform(_Fun&& __fun) const&& {
|
| 1632 |
+
static_assert(invocable<_Fun>,
|
| 1633 |
+
"std::expected::transform requires that F must be invocable with T");
|
| 1634 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun>>;
|
| 1635 |
+
|
| 1636 |
+
static_assert(__invoke_constructible<_Fun>,
|
| 1637 |
+
"std::expected::transform requires that the return type of F is constructible with the result of invoking F");
|
| 1638 |
+
static_assert(__expected::__valid_expected<_Res, _Err>,
|
| 1639 |
+
"std::expected::transform requires that the return type of F must be a valid argument for std::expected");
|
| 1640 |
+
|
| 1641 |
+
if (this->__has_val_) {
|
| 1642 |
+
return expected<_Res, _Err>{
|
| 1643 |
+
__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun)};
|
| 1644 |
+
} else {
|
| 1645 |
+
return expected<_Res, _Err>{unexpect, _CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1646 |
+
}
|
| 1647 |
+
}
|
| 1648 |
+
|
| 1649 |
+
template<class _Fun>
|
| 1650 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1651 |
+
auto transform_error(_Fun&& __fun) & {
|
| 1652 |
+
static_assert(invocable<_Fun, _Err&>,
|
| 1653 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 1654 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err&>>;
|
| 1655 |
+
|
| 1656 |
+
static_assert(__invoke_constructible<_Fun, _Err&>,
|
| 1657 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 1658 |
+
static_assert(__expected::__valid_expected<void, _Res>,
|
| 1659 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 1660 |
+
|
| 1661 |
+
if (this->__has_val_) {
|
| 1662 |
+
return expected<void, _Res>{};
|
| 1663 |
+
} else {
|
| 1664 |
+
return expected<void, _Res>{
|
| 1665 |
+
__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};
|
| 1666 |
+
}
|
| 1667 |
+
}
|
| 1668 |
+
|
| 1669 |
+
template<class _Fun>
|
| 1670 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1671 |
+
auto transform_error(_Fun&& __fun) const& {
|
| 1672 |
+
static_assert(invocable<_Fun, const _Err&>,
|
| 1673 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 1674 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err&>>;
|
| 1675 |
+
|
| 1676 |
+
static_assert(__invoke_constructible<_Fun, const _Err&>,
|
| 1677 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 1678 |
+
static_assert(__expected::__valid_expected<void, _Res>,
|
| 1679 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 1680 |
+
|
| 1681 |
+
if (this->__has_val_) {
|
| 1682 |
+
return expected<void, _Res>{};
|
| 1683 |
+
} else {
|
| 1684 |
+
return expected<void, _Res>{
|
| 1685 |
+
__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), this->__union_.__unex_};
|
| 1686 |
+
}
|
| 1687 |
+
}
|
| 1688 |
+
|
| 1689 |
+
template<class _Fun>
|
| 1690 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1691 |
+
auto transform_error(_Fun&& __fun) && {
|
| 1692 |
+
static_assert(invocable<_Fun, _Err>,
|
| 1693 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 1694 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, _Err>>;
|
| 1695 |
+
|
| 1696 |
+
static_assert(__invoke_constructible<_Fun, _Err>,
|
| 1697 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 1698 |
+
static_assert(__expected::__valid_expected<void, _Res>,
|
| 1699 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 1700 |
+
|
| 1701 |
+
if (this->__has_val_) {
|
| 1702 |
+
return expected<void, _Res>{};
|
| 1703 |
+
} else {
|
| 1704 |
+
return expected<void, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),
|
| 1705 |
+
_CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1706 |
+
}
|
| 1707 |
+
}
|
| 1708 |
+
|
| 1709 |
+
template<class _Fun>
|
| 1710 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1711 |
+
auto transform_error(_Fun&& __fun) const&& {
|
| 1712 |
+
static_assert(invocable<_Fun, const _Err>,
|
| 1713 |
+
"std::expected::transform_error requires that F must be invocable with E");
|
| 1714 |
+
using _Res = __remove_cv_t<invoke_result_t<_Fun, const _Err>>;
|
| 1715 |
+
|
| 1716 |
+
static_assert(__invoke_constructible<_Fun, const _Err>,
|
| 1717 |
+
"std::expected::transform_error requires that the return type of F is constructible with the result of invoking F");
|
| 1718 |
+
static_assert(__expected::__valid_expected<void, _Res>,
|
| 1719 |
+
"std::expected::transform_error requires that the return type of F must be a valid argument for std::expected");
|
| 1720 |
+
|
| 1721 |
+
if (this->__has_val_) {
|
| 1722 |
+
return expected<void, _Res>{};
|
| 1723 |
+
} else {
|
| 1724 |
+
return expected<void, _Res>{__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun),
|
| 1725 |
+
_CUDA_VSTD::move(this->__union_.__unex_)};
|
| 1726 |
+
}
|
| 1727 |
+
}
|
| 1728 |
+
|
| 1729 |
+
// [expected.void.eq], equality operators
|
| 1730 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1731 |
+
bool operator==(const expected& __x, const expected& __y) noexcept {
|
| 1732 |
+
if (__x.__has_val_ != __y.has_value()) {
|
| 1733 |
+
return false;
|
| 1734 |
+
} else {
|
| 1735 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ == __y.error());
|
| 1736 |
+
}
|
| 1737 |
+
}
|
| 1738 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1739 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1740 |
+
bool operator!=(const expected& __x, const expected& __y) noexcept {
|
| 1741 |
+
return !(__x == __y);
|
| 1742 |
+
}
|
| 1743 |
+
#endif
|
| 1744 |
+
|
| 1745 |
+
template <class _E2>
|
| 1746 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1747 |
+
bool operator==(const expected& __x, const expected<void, _E2>& __y) noexcept {
|
| 1748 |
+
if (__x.__has_val_ != __y.has_value()) {
|
| 1749 |
+
return false;
|
| 1750 |
+
} else {
|
| 1751 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ == __y.error());
|
| 1752 |
+
}
|
| 1753 |
+
}
|
| 1754 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1755 |
+
template <class _E2>
|
| 1756 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1757 |
+
bool operator!=(const expected& __x, const expected<void, _E2>& __y) noexcept {
|
| 1758 |
+
return !(__x == __y);
|
| 1759 |
+
}
|
| 1760 |
+
#endif
|
| 1761 |
+
|
| 1762 |
+
template <class _E2>
|
| 1763 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1764 |
+
bool operator==(const expected& __x, const unexpected<_E2>& __y) noexcept {
|
| 1765 |
+
return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __y.error());
|
| 1766 |
+
}
|
| 1767 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 1768 |
+
template <class _E2>
|
| 1769 |
+
friend _LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 1770 |
+
bool operator==(const unexpected<_E2>& __y, const expected& __x) noexcept {
|
| 1771 |
+
return !__x.__has_val_ && static_cast<bool>(__x.__union_.__unex_ == __y.error());
|
| 1772 |
+
}
|
| 1773 |
+
template <class _E2>
|
| 1774 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1775 |
+
friend constexpr bool operator!=(const expected& __x, const unexpected<_E2>& __y) noexcept {
|
| 1776 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __y.error());
|
| 1777 |
+
}
|
| 1778 |
+
template <class _E2>
|
| 1779 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 1780 |
+
friend constexpr bool operator!=(const unexpected<_E2>& __y, const expected& __x) noexcept {
|
| 1781 |
+
return __x.__has_val_ || static_cast<bool>(__x.__union_.__unex_ != __y.error());
|
| 1782 |
+
}
|
| 1783 |
+
#endif
|
| 1784 |
+
};
|
| 1785 |
+
|
| 1786 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 1787 |
+
|
| 1788 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 1789 |
+
|
| 1790 |
+
#endif // _LIBCUDACXX___EXPECTED_EXPECTED_H
|
cuda_toolkit/include/__expected/expected_base.h
ADDED
|
@@ -0,0 +1,1048 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
#ifndef _LIBCUDACXX___EXPECTED_EXPECTED_BASE_H
|
| 10 |
+
#define _LIBCUDACXX___EXPECTED_EXPECTED_BASE_H
|
| 11 |
+
|
| 12 |
+
#ifndef __cuda_std__
|
| 13 |
+
#include <__config>
|
| 14 |
+
#endif // __cuda_std__
|
| 15 |
+
|
| 16 |
+
#include "../__assert"
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__concepts/invocable.h"
|
| 19 |
+
#include "../__expected/unexpect.h"
|
| 20 |
+
#include "../__memory/addressof.h"
|
| 21 |
+
#include "../__memory/construct_at.h"
|
| 22 |
+
#include "../__tuple_dir/sfinae_helpers.h"
|
| 23 |
+
#include "../__type_traits/is_assignable.h"
|
| 24 |
+
#include "../__type_traits/is_constructible.h"
|
| 25 |
+
#include "../__type_traits/is_convertible.h"
|
| 26 |
+
#include "../__type_traits/is_copy_assignable.h"
|
| 27 |
+
#include "../__type_traits/is_copy_constructible.h"
|
| 28 |
+
#include "../__type_traits/is_default_constructible.h"
|
| 29 |
+
#include "../__type_traits/is_move_assignable.h"
|
| 30 |
+
#include "../__type_traits/is_move_constructible.h"
|
| 31 |
+
#include "../__type_traits/is_nothrow_constructible.h"
|
| 32 |
+
#include "../__type_traits/is_nothrow_copy_assignable.h"
|
| 33 |
+
#include "../__type_traits/is_nothrow_copy_constructible.h"
|
| 34 |
+
#include "../__type_traits/is_nothrow_default_constructible.h"
|
| 35 |
+
#include "../__type_traits/is_nothrow_move_assignable.h"
|
| 36 |
+
#include "../__type_traits/is_nothrow_move_constructible.h"
|
| 37 |
+
#include "../__type_traits/is_trivially_copy_assignable.h"
|
| 38 |
+
#include "../__type_traits/is_trivially_copy_constructible.h"
|
| 39 |
+
#include "../__type_traits/is_trivially_destructible.h"
|
| 40 |
+
#include "../__type_traits/is_trivially_move_assignable.h"
|
| 41 |
+
#include "../__type_traits/is_trivially_move_constructible.h"
|
| 42 |
+
#include "../__type_traits/is_void.h"
|
| 43 |
+
#include "../__utility/exception_guard.h"
|
| 44 |
+
#include "../__utility/forward.h"
|
| 45 |
+
#include "../__utility/in_place.h"
|
| 46 |
+
#include "../__utility/move.h"
|
| 47 |
+
|
| 48 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 49 |
+
# pragma GCC system_header
|
| 50 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 51 |
+
# pragma clang system_header
|
| 52 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 53 |
+
# pragma system_header
|
| 54 |
+
#endif // no system header
|
| 55 |
+
|
| 56 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 57 |
+
|
| 58 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 59 |
+
|
| 60 |
+
// MSVC complains about [[no_unique_address]] prior to C++20 as a vendor extension
|
| 61 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 62 |
+
#pragma warning(push)
|
| 63 |
+
#pragma warning(disable : 4848)
|
| 64 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 65 |
+
|
| 66 |
+
struct __expected_construct_from_invoke_tag {
|
| 67 |
+
explicit __expected_construct_from_invoke_tag() = default;
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
template <class _Tp, class _Err,
|
| 71 |
+
bool = _LIBCUDACXX_TRAIT(is_trivially_destructible, _Tp)
|
| 72 |
+
&& _LIBCUDACXX_TRAIT(is_trivially_destructible, _Err)>
|
| 73 |
+
union __expected_union_t {
|
| 74 |
+
struct __empty_t {};
|
| 75 |
+
|
| 76 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)
|
| 77 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_default_constructible, _Tp2))
|
| 78 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 79 |
+
__expected_union_t() noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Tp2)) : __val_() {}
|
| 80 |
+
|
| 81 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)
|
| 82 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_default_constructible, _Tp2)))
|
| 83 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 84 |
+
__expected_union_t() noexcept : __empty_() {}
|
| 85 |
+
|
| 86 |
+
template<class... _Args>
|
| 87 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 88 |
+
__expected_union_t(in_place_t, _Args&&... __args)
|
| 89 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 90 |
+
: __val_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 91 |
+
|
| 92 |
+
template<class... _Args>
|
| 93 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 94 |
+
__expected_union_t(unexpect_t, _Args&&... __args)
|
| 95 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 96 |
+
: __unex_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 97 |
+
|
| 98 |
+
template<class _Fun, class... _Args>
|
| 99 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 100 |
+
__expected_union_t(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 101 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 102 |
+
: __val_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 103 |
+
|
| 104 |
+
template<class _Fun, class... _Args>
|
| 105 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 106 |
+
__expected_union_t(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 107 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 108 |
+
: __unex_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 109 |
+
|
| 110 |
+
// the __expected_destruct's destructor handles this
|
| 111 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 112 |
+
~__expected_union_t() {}
|
| 113 |
+
|
| 114 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __empty_t __empty_;
|
| 115 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Tp __val_;
|
| 116 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Err __unex_;
|
| 117 |
+
};
|
| 118 |
+
|
| 119 |
+
template <class _Tp, class _Err>
|
| 120 |
+
union __expected_union_t<_Tp, _Err, true> {
|
| 121 |
+
struct __empty_t {};
|
| 122 |
+
|
| 123 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)
|
| 124 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_default_constructible, _Tp2))
|
| 125 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 126 |
+
__expected_union_t() noexcept(_LIBCUDACXX_TRAIT(is_nothrow_default_constructible, _Tp2)) : __val_() {}
|
| 127 |
+
|
| 128 |
+
_LIBCUDACXX_TEMPLATE(class _Tp2 = _Tp)
|
| 129 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_default_constructible, _Tp2)))
|
| 130 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 131 |
+
__expected_union_t() noexcept : __empty_() {}
|
| 132 |
+
|
| 133 |
+
template<class... _Args>
|
| 134 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 135 |
+
__expected_union_t(in_place_t, _Args&&... __args)
|
| 136 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 137 |
+
: __val_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 138 |
+
|
| 139 |
+
template<class... _Args>
|
| 140 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 141 |
+
__expected_union_t(unexpect_t, _Args&&... __args)
|
| 142 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 143 |
+
: __unex_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 144 |
+
|
| 145 |
+
template<class _Fun, class... _Args>
|
| 146 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 147 |
+
__expected_union_t(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 148 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 149 |
+
: __val_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 150 |
+
|
| 151 |
+
template<class _Fun, class... _Args>
|
| 152 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 153 |
+
__expected_union_t(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 154 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 155 |
+
: __unex_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 156 |
+
|
| 157 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __empty_t __empty_;
|
| 158 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Tp __val_;
|
| 159 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Err __unex_;
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
template <class _Tp, class _Err,
|
| 163 |
+
bool = _LIBCUDACXX_TRAIT(is_trivially_destructible, _Tp),
|
| 164 |
+
bool = _LIBCUDACXX_TRAIT(is_trivially_destructible, _Err)>
|
| 165 |
+
struct __expected_destruct;
|
| 166 |
+
|
| 167 |
+
template <class _Tp, class _Err>
|
| 168 |
+
struct __expected_destruct<_Tp, _Err, false, false> {
|
| 169 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __expected_union_t<_Tp, _Err> __union_{};
|
| 170 |
+
bool __has_val_{true};
|
| 171 |
+
|
| 172 |
+
constexpr __expected_destruct() noexcept = default;
|
| 173 |
+
|
| 174 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 175 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 176 |
+
|
| 177 |
+
template<class... _Args>
|
| 178 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 179 |
+
__expected_destruct(in_place_t, _Args&&... __args)
|
| 180 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 181 |
+
: __union_(in_place, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 182 |
+
, __has_val_(true)
|
| 183 |
+
{}
|
| 184 |
+
|
| 185 |
+
template<class... _Args>
|
| 186 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 187 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 188 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 189 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 190 |
+
, __has_val_(false)
|
| 191 |
+
{}
|
| 192 |
+
|
| 193 |
+
template<class _Fun, class... _Args>
|
| 194 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 195 |
+
__expected_destruct(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 196 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 197 |
+
: __union_(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 198 |
+
, __has_val_(true)
|
| 199 |
+
{}
|
| 200 |
+
|
| 201 |
+
template<class _Fun, class... _Args>
|
| 202 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 203 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 204 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 205 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 206 |
+
, __has_val_(false)
|
| 207 |
+
{}
|
| 208 |
+
|
| 209 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 210 |
+
~__expected_destruct() {
|
| 211 |
+
if (__has_val_) {
|
| 212 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__val_));
|
| 213 |
+
} else {
|
| 214 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__unex_));
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
template <class _Tp, class _Err>
|
| 220 |
+
struct __expected_destruct<_Tp, _Err, true, false> {
|
| 221 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __expected_union_t<_Tp, _Err> __union_{};
|
| 222 |
+
bool __has_val_{true};
|
| 223 |
+
|
| 224 |
+
constexpr __expected_destruct() noexcept = default;
|
| 225 |
+
|
| 226 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 227 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 228 |
+
|
| 229 |
+
template<class... _Args>
|
| 230 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 231 |
+
__expected_destruct(in_place_t, _Args&&... __args)
|
| 232 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 233 |
+
: __union_(in_place, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 234 |
+
, __has_val_(true)
|
| 235 |
+
{}
|
| 236 |
+
|
| 237 |
+
template<class... _Args>
|
| 238 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 239 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 240 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 241 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 242 |
+
, __has_val_(false)
|
| 243 |
+
{}
|
| 244 |
+
|
| 245 |
+
template<class _Fun, class... _Args>
|
| 246 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 247 |
+
__expected_destruct(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 248 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 249 |
+
: __union_(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 250 |
+
, __has_val_(true)
|
| 251 |
+
{}
|
| 252 |
+
|
| 253 |
+
template<class _Fun, class... _Args>
|
| 254 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 255 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 256 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 257 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 258 |
+
, __has_val_(false)
|
| 259 |
+
{}
|
| 260 |
+
|
| 261 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 262 |
+
~__expected_destruct() {
|
| 263 |
+
if (!__has_val_) {
|
| 264 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__unex_));
|
| 265 |
+
}
|
| 266 |
+
}
|
| 267 |
+
};
|
| 268 |
+
|
| 269 |
+
template <class _Tp, class _Err>
|
| 270 |
+
struct __expected_destruct<_Tp, _Err, false, true> {
|
| 271 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __expected_union_t<_Tp, _Err> __union_{};
|
| 272 |
+
bool __has_val_{true};
|
| 273 |
+
|
| 274 |
+
constexpr __expected_destruct() noexcept = default;
|
| 275 |
+
|
| 276 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 277 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 278 |
+
|
| 279 |
+
template<class... _Args>
|
| 280 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 281 |
+
__expected_destruct(in_place_t, _Args&&... __args)
|
| 282 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 283 |
+
: __union_(in_place, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 284 |
+
, __has_val_(true)
|
| 285 |
+
{}
|
| 286 |
+
|
| 287 |
+
template<class... _Args>
|
| 288 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 289 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 290 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 291 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 292 |
+
, __has_val_(false)
|
| 293 |
+
{}
|
| 294 |
+
|
| 295 |
+
template<class _Fun, class... _Args>
|
| 296 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 297 |
+
__expected_destruct(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 298 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 299 |
+
: __union_(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 300 |
+
, __has_val_(true)
|
| 301 |
+
{}
|
| 302 |
+
|
| 303 |
+
template<class _Fun, class... _Args>
|
| 304 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 305 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 306 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 307 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 308 |
+
, __has_val_(false)
|
| 309 |
+
{}
|
| 310 |
+
|
| 311 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 312 |
+
~__expected_destruct() {
|
| 313 |
+
if (__has_val_) {
|
| 314 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__val_));
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
};
|
| 318 |
+
|
| 319 |
+
template <class _Tp, class _Err>
|
| 320 |
+
struct __expected_destruct<_Tp, _Err, true, true> {
|
| 321 |
+
// This leads to an ICE with nvcc, see nvbug4103076
|
| 322 |
+
/* _LIBCUDACXX_NO_UNIQUE_ADDRESS */ __expected_union_t<_Tp, _Err> __union_{};
|
| 323 |
+
bool __has_val_{true};
|
| 324 |
+
|
| 325 |
+
constexpr __expected_destruct() noexcept = default;
|
| 326 |
+
|
| 327 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 328 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 329 |
+
|
| 330 |
+
template<class... _Args>
|
| 331 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 332 |
+
__expected_destruct(in_place_t, _Args&&... __args)
|
| 333 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 334 |
+
: __union_(in_place, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 335 |
+
, __has_val_(true)
|
| 336 |
+
{}
|
| 337 |
+
|
| 338 |
+
template<class... _Args>
|
| 339 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 340 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 341 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, _Args...))
|
| 342 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 343 |
+
, __has_val_(false)
|
| 344 |
+
{}
|
| 345 |
+
|
| 346 |
+
template<class _Fun, class... _Args>
|
| 347 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 348 |
+
__expected_destruct(__expected_construct_from_invoke_tag, in_place_t, _Fun&& __fun, _Args&&... __args)
|
| 349 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Tp, invoke_result_t<_Fun, _Args...>))
|
| 350 |
+
: __union_(__expected_construct_from_invoke_tag{}, in_place, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 351 |
+
, __has_val_(true)
|
| 352 |
+
{}
|
| 353 |
+
|
| 354 |
+
template<class _Fun, class... _Args>
|
| 355 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 356 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 357 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 358 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 359 |
+
, __has_val_(false)
|
| 360 |
+
{}
|
| 361 |
+
};
|
| 362 |
+
|
| 363 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 364 |
+
#pragma warning(pop)
|
| 365 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 366 |
+
|
| 367 |
+
template <class _Tp, class _Err>
|
| 368 |
+
struct __expected_storage : __expected_destruct<_Tp, _Err>
|
| 369 |
+
{
|
| 370 |
+
using __base = __expected_destruct<_Tp, _Err>;
|
| 371 |
+
|
| 372 |
+
// nvbug3961621
|
| 373 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 374 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 375 |
+
constexpr __expected_storage() noexcept = default;
|
| 376 |
+
|
| 377 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 378 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 379 |
+
__expected_storage(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 380 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 381 |
+
{}
|
| 382 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 383 |
+
using __base::__base;
|
| 384 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 385 |
+
|
| 386 |
+
_LIBCUDACXX_TEMPLATE(class _T1, class _T2, class... _Args)
|
| 387 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_constructible, _T1, _Args...))
|
| 388 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 389 |
+
void __reinit_expected(_T1& __newval, _T2& __oldval, _Args&&... __args) noexcept {
|
| 390 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__oldval));
|
| 391 |
+
_LIBCUDACXX_CONSTRUCT_AT(__newval, _CUDA_VSTD::forward<_Args>(__args)...);
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
_LIBCUDACXX_TEMPLATE(class _T1, class _T2, class... _Args)
|
| 395 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_nothrow_constructible, _T1, _Args...)) _LIBCUDACXX_AND
|
| 396 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _T1)
|
| 397 |
+
)
|
| 398 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 399 |
+
void __reinit_expected(_T1& __newval, _T2& __oldval, _Args&&... __args) {
|
| 400 |
+
_T1 __tmp(_CUDA_VSTD::forward<_Args>(__args)...);
|
| 401 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__oldval));
|
| 402 |
+
_LIBCUDACXX_CONSTRUCT_AT(__newval, _CUDA_VSTD::move(__tmp));
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
_LIBCUDACXX_TEMPLATE(class _T1, class _T2, class... _Args)
|
| 406 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_nothrow_constructible, _T1, _Args...)) _LIBCUDACXX_AND
|
| 407 |
+
(!_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _T1))
|
| 408 |
+
)
|
| 409 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 410 |
+
void __reinit_expected(_T1& __newval, _T2& __oldval, _Args&&... __args) {
|
| 411 |
+
static_assert(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _T2),
|
| 412 |
+
"To provide strong exception guarantee, T2 has to satisfy `is_nothrow_move_constructible_v` so that it can "
|
| 413 |
+
"be reverted to the previous state in case an exception is thrown during the assignment.");
|
| 414 |
+
_T2 __tmp(_CUDA_VSTD::move(__oldval));
|
| 415 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__oldval));
|
| 416 |
+
auto __trans =
|
| 417 |
+
_CUDA_VSTD::__make_exception_guard([&] { _LIBCUDACXX_CONSTRUCT_AT(__oldval, _CUDA_VSTD::move(__tmp)); });
|
| 418 |
+
_LIBCUDACXX_CONSTRUCT_AT(__newval, _CUDA_VSTD::forward<_Args>(__args)...);
|
| 419 |
+
__trans.__complete();
|
| 420 |
+
}
|
| 421 |
+
|
| 422 |
+
_LIBCUDACXX_TEMPLATE(class _Err2 = _Err)
|
| 423 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2))
|
| 424 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 425 |
+
void __swap_val_unex_impl(__expected_storage<_Tp, _Err2>& __with_val, __expected_storage& __with_err) {
|
| 426 |
+
_Err __tmp(_CUDA_VSTD::move(__with_err.__union_.__unex_));
|
| 427 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__with_err.__union_.__unex_));
|
| 428 |
+
auto __trans = _CUDA_VSTD::__make_exception_guard([&] {
|
| 429 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_err.__union_.__unex_, _CUDA_VSTD::move(__tmp));
|
| 430 |
+
});
|
| 431 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_err.__union_.__val_, _CUDA_VSTD::move(__with_val.__union_.__val_));
|
| 432 |
+
__trans.__complete();
|
| 433 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__with_val.__union_.__val_));
|
| 434 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_val.__union_.__unex_, _CUDA_VSTD::move(__tmp));
|
| 435 |
+
__with_val.__has_val_ = false;
|
| 436 |
+
__with_err.__has_val_ = true;
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
_LIBCUDACXX_TEMPLATE(class _Err2 = _Err)
|
| 440 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err2)))
|
| 441 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 442 |
+
void __swap_val_unex_impl(__expected_storage<_Tp, _Err2>& __with_val, __expected_storage& __with_err) {
|
| 443 |
+
static_assert(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp),
|
| 444 |
+
"To provide strong exception guarantee, Tp has to satisfy `is_nothrow_move_constructible_v` so "
|
| 445 |
+
"that it can be reverted to the previous state in case an exception is thrown during swap.");
|
| 446 |
+
_Tp __tmp(_CUDA_VSTD::move(__with_val.__union_.__val_));
|
| 447 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__with_val.__union_.__val_));
|
| 448 |
+
auto __trans = _CUDA_VSTD::__make_exception_guard([&] {
|
| 449 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_val.__union_.__val_, _CUDA_VSTD::move(__tmp));
|
| 450 |
+
});
|
| 451 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_val.__union_.__unex_, _CUDA_VSTD::move(__with_err.__union_.__unex_));
|
| 452 |
+
__trans.__complete();
|
| 453 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__with_err.__union_.__unex_));
|
| 454 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_err.__union_.__val_, _CUDA_VSTD::move(__tmp));
|
| 455 |
+
__with_val.__has_val_ = false;
|
| 456 |
+
__with_err.__has_val_ = true;
|
| 457 |
+
}
|
| 458 |
+
};
|
| 459 |
+
|
| 460 |
+
template <class _Tp, class _Err, bool =
|
| 461 |
+
(_LIBCUDACXX_TRAIT(is_trivially_copy_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 462 |
+
_LIBCUDACXX_TRAIT(is_trivially_copy_constructible, _Err)>
|
| 463 |
+
struct __expected_copy : __expected_storage<_Tp, _Err>
|
| 464 |
+
{
|
| 465 |
+
using __base = __expected_storage<_Tp, _Err>;
|
| 466 |
+
// nvbug3961621
|
| 467 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 468 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 469 |
+
constexpr __expected_copy() noexcept = default;
|
| 470 |
+
|
| 471 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 472 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 473 |
+
__expected_copy(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 474 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 475 |
+
{}
|
| 476 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 477 |
+
using __base::__base;
|
| 478 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 479 |
+
};
|
| 480 |
+
|
| 481 |
+
template <class _Tp, class _Err>
|
| 482 |
+
struct __expected_copy<_Tp, _Err, false> : __expected_storage<_Tp, _Err>
|
| 483 |
+
{
|
| 484 |
+
using __base = __expected_storage<_Tp, _Err>;
|
| 485 |
+
|
| 486 |
+
// nvbug3961621
|
| 487 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 488 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 489 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 490 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 491 |
+
__expected_copy(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 492 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 493 |
+
{}
|
| 494 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 495 |
+
using __base::__base;
|
| 496 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 497 |
+
|
| 498 |
+
constexpr __expected_copy() noexcept = default;
|
| 499 |
+
|
| 500 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 501 |
+
__expected_copy(const __expected_copy& __other)
|
| 502 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Tp)
|
| 503 |
+
&& _LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Err))
|
| 504 |
+
: __base(__other.__has_val_)
|
| 505 |
+
{
|
| 506 |
+
if (__other.__has_val_) {
|
| 507 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, __other.__union_.__val_);
|
| 508 |
+
} else {
|
| 509 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 510 |
+
}
|
| 511 |
+
}
|
| 512 |
+
|
| 513 |
+
__expected_copy(__expected_copy&&) = default;
|
| 514 |
+
__expected_copy& operator=(const __expected_copy&) = default;
|
| 515 |
+
__expected_copy& operator=(__expected_copy&&) = default;
|
| 516 |
+
};
|
| 517 |
+
|
| 518 |
+
template <class _Tp, class _Err, bool =
|
| 519 |
+
(_LIBCUDACXX_TRAIT(is_trivially_move_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 520 |
+
_LIBCUDACXX_TRAIT(is_trivially_move_constructible, _Err)>
|
| 521 |
+
struct __expected_move : __expected_copy<_Tp, _Err>
|
| 522 |
+
{
|
| 523 |
+
using __base = __expected_copy<_Tp, _Err>;
|
| 524 |
+
// nvbug3961621
|
| 525 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 526 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 527 |
+
constexpr __expected_move() noexcept = default;
|
| 528 |
+
|
| 529 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 530 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 531 |
+
__expected_move(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 532 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 533 |
+
{}
|
| 534 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 535 |
+
using __base::__base;
|
| 536 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 537 |
+
};
|
| 538 |
+
|
| 539 |
+
template <class _Tp, class _Err>
|
| 540 |
+
struct __expected_move<_Tp, _Err, false> : __expected_copy<_Tp, _Err>
|
| 541 |
+
{
|
| 542 |
+
using __base = __expected_copy<_Tp, _Err>;
|
| 543 |
+
// nvbug3961621
|
| 544 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 545 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 546 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 547 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 548 |
+
__expected_move(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 549 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 550 |
+
{}
|
| 551 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 552 |
+
using __base::__base;
|
| 553 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 554 |
+
|
| 555 |
+
__expected_move() = default;
|
| 556 |
+
__expected_move(const __expected_move&) = default;
|
| 557 |
+
|
| 558 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 559 |
+
__expected_move(__expected_move&& __other)
|
| 560 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp)
|
| 561 |
+
&& _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err))
|
| 562 |
+
: __base(__other.__has_val_)
|
| 563 |
+
{
|
| 564 |
+
if (__other.__has_val_) {
|
| 565 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__val_));
|
| 566 |
+
} else {
|
| 567 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 568 |
+
}
|
| 569 |
+
}
|
| 570 |
+
|
| 571 |
+
__expected_move& operator=(const __expected_move&) = default;
|
| 572 |
+
__expected_move& operator=(__expected_move&&) = default;
|
| 573 |
+
};
|
| 574 |
+
|
| 575 |
+
template <class _Tp, class _Err, bool =
|
| 576 |
+
(_LIBCUDACXX_TRAIT(is_trivially_destructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 577 |
+
_LIBCUDACXX_TRAIT(is_trivially_destructible, _Err) &&
|
| 578 |
+
(_LIBCUDACXX_TRAIT(is_trivially_copy_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void))&&
|
| 579 |
+
_LIBCUDACXX_TRAIT(is_trivially_copy_constructible, _Err) &&
|
| 580 |
+
(_LIBCUDACXX_TRAIT(is_trivially_copy_assignable, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void))&&
|
| 581 |
+
_LIBCUDACXX_TRAIT(is_trivially_copy_assignable, _Err)>
|
| 582 |
+
struct __expected_copy_assign : __expected_move<_Tp, _Err>
|
| 583 |
+
{
|
| 584 |
+
using __base = __expected_move<_Tp, _Err>;
|
| 585 |
+
// nvbug3961621
|
| 586 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 587 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 588 |
+
constexpr __expected_copy_assign() noexcept = default;
|
| 589 |
+
|
| 590 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 591 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 592 |
+
__expected_copy_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 593 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 594 |
+
{}
|
| 595 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 596 |
+
using __base::__base;
|
| 597 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 598 |
+
};
|
| 599 |
+
|
| 600 |
+
template <class _Tp, class _Err>
|
| 601 |
+
struct __expected_copy_assign<_Tp, _Err, false> : __expected_move<_Tp, _Err>
|
| 602 |
+
{
|
| 603 |
+
using __base = __expected_move<_Tp, _Err>;
|
| 604 |
+
// nvbug3961621
|
| 605 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 606 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 607 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 608 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 609 |
+
__expected_copy_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 610 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 611 |
+
{}
|
| 612 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 613 |
+
using __base::__base;
|
| 614 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 615 |
+
|
| 616 |
+
__expected_copy_assign() = default;
|
| 617 |
+
__expected_copy_assign(const __expected_copy_assign&) = default;
|
| 618 |
+
__expected_copy_assign(__expected_copy_assign&&) = default;
|
| 619 |
+
|
| 620 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 621 |
+
__expected_copy_assign& operator=(const __expected_copy_assign& __other)
|
| 622 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_copy_assignable, _Tp) &&
|
| 623 |
+
_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Tp) &&
|
| 624 |
+
_LIBCUDACXX_TRAIT(is_nothrow_copy_assignable, _Err) &&
|
| 625 |
+
_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Err)) // strengthened
|
| 626 |
+
{
|
| 627 |
+
if (this->__has_val_ && __other.__has_val_) {
|
| 628 |
+
this->__union_.__val_ = __other.__union_.__val_;
|
| 629 |
+
} else if (this->__has_val_ && !__other.__has_val_) {
|
| 630 |
+
this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, __other.__union_.__unex_);
|
| 631 |
+
this->__has_val_ = false;
|
| 632 |
+
} else if (!this->__has_val_ && __other.__has_val_) {
|
| 633 |
+
this->__reinit_expected(this->__union_.__val_, this->__union_.__unex_, __other.__union_.__val_);
|
| 634 |
+
this->__has_val_ = true;
|
| 635 |
+
} else { // !this->__has_val_ && !__other.__has_val_
|
| 636 |
+
this->__union_.__unex_ = __other.__union_.__unex_;
|
| 637 |
+
}
|
| 638 |
+
return *this;
|
| 639 |
+
}
|
| 640 |
+
|
| 641 |
+
__expected_copy_assign& operator=(__expected_copy_assign&&) = default;
|
| 642 |
+
};
|
| 643 |
+
|
| 644 |
+
template <class _Tp, class _Err, bool =
|
| 645 |
+
(_LIBCUDACXX_TRAIT(is_trivially_destructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 646 |
+
_LIBCUDACXX_TRAIT(is_trivially_destructible, _Err) &&
|
| 647 |
+
(_LIBCUDACXX_TRAIT(is_trivially_move_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 648 |
+
_LIBCUDACXX_TRAIT(is_trivially_move_constructible, _Err) &&
|
| 649 |
+
(_LIBCUDACXX_TRAIT(is_trivially_move_assignable, _Tp) || _LIBCUDACXX_TRAIT(is_same, _Tp, void)) &&
|
| 650 |
+
_LIBCUDACXX_TRAIT(is_trivially_move_assignable, _Err)>
|
| 651 |
+
struct __expected_move_assign : __expected_copy_assign<_Tp, _Err>
|
| 652 |
+
{
|
| 653 |
+
using __base = __expected_copy_assign<_Tp, _Err>;
|
| 654 |
+
// nvbug3961621
|
| 655 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 656 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 657 |
+
constexpr __expected_move_assign() noexcept = default;
|
| 658 |
+
|
| 659 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 660 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 661 |
+
__expected_move_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 662 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 663 |
+
{}
|
| 664 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 665 |
+
using __base::__base;
|
| 666 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 667 |
+
};
|
| 668 |
+
|
| 669 |
+
template <class _Tp, class _Err>
|
| 670 |
+
struct __expected_move_assign<_Tp, _Err, false> : __expected_copy_assign<_Tp, _Err>
|
| 671 |
+
{
|
| 672 |
+
using __base = __expected_copy_assign<_Tp, _Err>;
|
| 673 |
+
// nvbug3961621
|
| 674 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 675 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 676 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 677 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 678 |
+
__expected_move_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 679 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 680 |
+
{}
|
| 681 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 682 |
+
using __base::__base;
|
| 683 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 684 |
+
|
| 685 |
+
__expected_move_assign() = default;
|
| 686 |
+
__expected_move_assign(const __expected_move_assign&) = default;
|
| 687 |
+
__expected_move_assign(__expected_move_assign&&) = default;
|
| 688 |
+
__expected_move_assign& operator=(const __expected_move_assign&) = default;
|
| 689 |
+
|
| 690 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 691 |
+
__expected_move_assign& operator=(__expected_move_assign&& __other)
|
| 692 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_assignable, _Tp) &&
|
| 693 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) &&
|
| 694 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_assignable, _Err) &&
|
| 695 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err)) // strengthened
|
| 696 |
+
{
|
| 697 |
+
if (this->__has_val_ && __other.__has_val_) {
|
| 698 |
+
this->__union_.__val_ = _CUDA_VSTD::move(__other.__union_.__val_);
|
| 699 |
+
} else if (this->__has_val_ && !__other.__has_val_) {
|
| 700 |
+
this->__reinit_expected(this->__union_.__unex_, this->__union_.__val_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 701 |
+
this->__has_val_ = false;
|
| 702 |
+
} else if (!this->__has_val_ && __other.__has_val_) {
|
| 703 |
+
this->__reinit_expected(this->__union_.__val_, this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__val_));
|
| 704 |
+
this->__has_val_ = true;
|
| 705 |
+
} else { // !this->__has_val_ && !__other.__has_val_
|
| 706 |
+
this->__union_.__unex_ = _CUDA_VSTD::move(__other.__union_.__unex_);
|
| 707 |
+
}
|
| 708 |
+
return *this;
|
| 709 |
+
}
|
| 710 |
+
};
|
| 711 |
+
|
| 712 |
+
template <class _Tp, class _Err>
|
| 713 |
+
using __expected_sfinae_ctor_base_t = __sfinae_ctor_base<
|
| 714 |
+
_LIBCUDACXX_TRAIT(is_copy_constructible, _Tp) && _LIBCUDACXX_TRAIT(is_copy_constructible, _Err),
|
| 715 |
+
_LIBCUDACXX_TRAIT(is_move_constructible, _Tp) && _LIBCUDACXX_TRAIT(is_move_constructible, _Err)
|
| 716 |
+
>;
|
| 717 |
+
|
| 718 |
+
template <class _Tp, class _Err>
|
| 719 |
+
using __expected_sfinae_assign_base_t = __sfinae_assign_base<
|
| 720 |
+
_LIBCUDACXX_TRAIT(is_copy_constructible, _Tp) && _LIBCUDACXX_TRAIT(is_copy_constructible, _Err) &&
|
| 721 |
+
_LIBCUDACXX_TRAIT(is_copy_assignable, _Tp) && _LIBCUDACXX_TRAIT(is_copy_assignable, _Err) &&
|
| 722 |
+
(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err)),
|
| 723 |
+
_LIBCUDACXX_TRAIT(is_move_constructible, _Tp) && _LIBCUDACXX_TRAIT(is_move_constructible, _Err) &&
|
| 724 |
+
_LIBCUDACXX_TRAIT(is_move_assignable, _Tp) && _LIBCUDACXX_TRAIT(is_move_assignable, _Err) &&
|
| 725 |
+
(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Tp) || _LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err))
|
| 726 |
+
>;
|
| 727 |
+
|
| 728 |
+
// expected<void, E> base classtemplate <class _Tp, class _Err>
|
| 729 |
+
// MSVC complains about [[no_unique_address]] prior to C++20 as a vendor extension
|
| 730 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 731 |
+
#pragma warning(push)
|
| 732 |
+
#pragma warning(disable : 4848)
|
| 733 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 734 |
+
|
| 735 |
+
template <class _Err>
|
| 736 |
+
struct __expected_destruct<void, _Err, false, false> {
|
| 737 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS union __expected_union_t {
|
| 738 |
+
struct __empty_t {};
|
| 739 |
+
|
| 740 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 741 |
+
__expected_union_t() noexcept : __empty_() {}
|
| 742 |
+
|
| 743 |
+
template<class... _Args>
|
| 744 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 745 |
+
__expected_union_t(unexpect_t, _Args&&... __args)
|
| 746 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 747 |
+
: __unex_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 748 |
+
|
| 749 |
+
template<class _Fun, class... _Args>
|
| 750 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 751 |
+
__expected_union_t(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 752 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 753 |
+
: __unex_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 754 |
+
|
| 755 |
+
// the __expected_destruct's destructor handles this
|
| 756 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 757 |
+
~__expected_union_t() {}
|
| 758 |
+
|
| 759 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __empty_t __empty_;
|
| 760 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Err __unex_;
|
| 761 |
+
} __union_{};
|
| 762 |
+
bool __has_val_{true};
|
| 763 |
+
|
| 764 |
+
constexpr __expected_destruct() noexcept = default;
|
| 765 |
+
|
| 766 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 767 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 768 |
+
|
| 769 |
+
template<class... _Args>
|
| 770 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 771 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 772 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 773 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 774 |
+
, __has_val_(false)
|
| 775 |
+
{}
|
| 776 |
+
|
| 777 |
+
template<class _Fun, class... _Args>
|
| 778 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 779 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 780 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 781 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 782 |
+
, __has_val_(false)
|
| 783 |
+
{}
|
| 784 |
+
|
| 785 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 786 |
+
~__expected_destruct() {
|
| 787 |
+
if (!__has_val_) {
|
| 788 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__union_.__unex_));
|
| 789 |
+
}
|
| 790 |
+
}
|
| 791 |
+
};
|
| 792 |
+
|
| 793 |
+
template <class _Err>
|
| 794 |
+
struct __expected_destruct<void, _Err, false, true> {
|
| 795 |
+
// Using `_LIBCUDACXX_NO_UNIQUE_ADDRESS` here crashes nvcc
|
| 796 |
+
/* _LIBCUDACXX_NO_UNIQUE_ADDRESS */ union __expected_union_t {
|
| 797 |
+
struct __empty_t {};
|
| 798 |
+
|
| 799 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 800 |
+
__expected_union_t() noexcept : __empty_() {}
|
| 801 |
+
|
| 802 |
+
template<class... _Args>
|
| 803 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 804 |
+
__expected_union_t(unexpect_t, _Args&&... __args)
|
| 805 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 806 |
+
: __unex_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 807 |
+
|
| 808 |
+
template<class _Fun, class... _Args>
|
| 809 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 810 |
+
__expected_union_t(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 811 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 812 |
+
: __unex_(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)) {}
|
| 813 |
+
|
| 814 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS __empty_t __empty_;
|
| 815 |
+
_LIBCUDACXX_NO_UNIQUE_ADDRESS _Err __unex_;
|
| 816 |
+
} __union_{};
|
| 817 |
+
bool __has_val_{true};
|
| 818 |
+
|
| 819 |
+
constexpr __expected_destruct() noexcept = default;
|
| 820 |
+
|
| 821 |
+
template<class... _Args>
|
| 822 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 823 |
+
__expected_destruct(in_place_t)
|
| 824 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 825 |
+
: __union_()
|
| 826 |
+
, __has_val_(true)
|
| 827 |
+
{}
|
| 828 |
+
|
| 829 |
+
template<class... _Args>
|
| 830 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 831 |
+
__expected_destruct(unexpect_t, _Args&&... __args)
|
| 832 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 833 |
+
: __union_(unexpect, _CUDA_VSTD::forward<_Args>(__args)...)
|
| 834 |
+
, __has_val_(false)
|
| 835 |
+
{}
|
| 836 |
+
|
| 837 |
+
template<class _Fun, class... _Args>
|
| 838 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 839 |
+
__expected_destruct(__expected_construct_from_invoke_tag, unexpect_t, _Fun&& __fun, _Args&&... __args)
|
| 840 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, invoke_result_t<_Fun, _Args...>))
|
| 841 |
+
: __union_(__expected_construct_from_invoke_tag{}, unexpect, _CUDA_VSTD::forward<_Fun>(__fun), _CUDA_VSTD::forward<_Args>(__args)...)
|
| 842 |
+
, __has_val_(false)
|
| 843 |
+
{}
|
| 844 |
+
|
| 845 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 846 |
+
__expected_destruct(const bool __has_val) noexcept : __has_val_(__has_val) {}
|
| 847 |
+
};
|
| 848 |
+
|
| 849 |
+
#if defined(_LIBCUDACXX_COMPILER_MSVC)
|
| 850 |
+
#pragma warning(pop)
|
| 851 |
+
#endif // _LIBCUDACXX_COMPILER_MSVC
|
| 852 |
+
|
| 853 |
+
template <class _Err>
|
| 854 |
+
struct __expected_storage<void, _Err> : __expected_destruct<void, _Err>
|
| 855 |
+
{
|
| 856 |
+
using __base = __expected_destruct<void, _Err>;
|
| 857 |
+
// nvbug3961621
|
| 858 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 859 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 860 |
+
constexpr __expected_storage() noexcept = default;
|
| 861 |
+
|
| 862 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 863 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 864 |
+
__expected_storage(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 865 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 866 |
+
{}
|
| 867 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 868 |
+
using __base::__base;
|
| 869 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 870 |
+
|
| 871 |
+
static _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 872 |
+
void __swap_val_unex_impl(__expected_storage& __with_val, __expected_storage& __with_err)
|
| 873 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err)) {
|
| 874 |
+
_LIBCUDACXX_CONSTRUCT_AT(__with_val.__union_.__unex_, _CUDA_VSTD::move(__with_err.__union_.__unex_));
|
| 875 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(__with_err.__union_.__unex_));
|
| 876 |
+
__with_val.__has_val_ = false;
|
| 877 |
+
__with_err.__has_val_ = true;
|
| 878 |
+
}
|
| 879 |
+
};
|
| 880 |
+
|
| 881 |
+
template <class _Err>
|
| 882 |
+
struct __expected_copy<void, _Err, false> : __expected_storage<void, _Err>
|
| 883 |
+
{
|
| 884 |
+
using __base = __expected_storage<void, _Err>;
|
| 885 |
+
// nvbug3961621
|
| 886 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 887 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 888 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 889 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 890 |
+
__expected_copy(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 891 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 892 |
+
{}
|
| 893 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 894 |
+
using __base::__base;
|
| 895 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 896 |
+
|
| 897 |
+
constexpr __expected_copy() = default;
|
| 898 |
+
|
| 899 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 900 |
+
__expected_copy(const __expected_copy& __other)
|
| 901 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Err))
|
| 902 |
+
: __base(__other.__has_val_)
|
| 903 |
+
{
|
| 904 |
+
if (!__other.__has_val_) {
|
| 905 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 906 |
+
}
|
| 907 |
+
}
|
| 908 |
+
|
| 909 |
+
__expected_copy(__expected_copy&&) = default;
|
| 910 |
+
__expected_copy& operator=(const __expected_copy&) = default;
|
| 911 |
+
__expected_copy& operator=(__expected_copy&&) = default;
|
| 912 |
+
};
|
| 913 |
+
|
| 914 |
+
template <class _Err>
|
| 915 |
+
struct __expected_move<void, _Err, false> : __expected_copy<void, _Err>
|
| 916 |
+
{
|
| 917 |
+
using __base = __expected_copy<void, _Err>;
|
| 918 |
+
// nvbug3961621
|
| 919 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 920 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 921 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 922 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 923 |
+
__expected_move(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 924 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 925 |
+
{}
|
| 926 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 927 |
+
using __base::__base;
|
| 928 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 929 |
+
|
| 930 |
+
__expected_move() = default;
|
| 931 |
+
__expected_move(const __expected_move&) = default;
|
| 932 |
+
|
| 933 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 934 |
+
__expected_move(__expected_move&& __other)
|
| 935 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err))
|
| 936 |
+
: __base(__other.__has_val_)
|
| 937 |
+
{
|
| 938 |
+
if (!__other.__has_val_) {
|
| 939 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 940 |
+
}
|
| 941 |
+
}
|
| 942 |
+
|
| 943 |
+
__expected_move& operator=(const __expected_move&) = default;
|
| 944 |
+
__expected_move& operator=(__expected_move&&) = default;
|
| 945 |
+
};
|
| 946 |
+
|
| 947 |
+
template <class _Err>
|
| 948 |
+
struct __expected_copy_assign<void, _Err, false> : __expected_move<void, _Err>
|
| 949 |
+
{
|
| 950 |
+
using __base = __expected_move<void, _Err>;
|
| 951 |
+
// nvbug3961621
|
| 952 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 953 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 954 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 955 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 956 |
+
__expected_copy_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 957 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 958 |
+
{}
|
| 959 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 960 |
+
using __base::__base;
|
| 961 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 962 |
+
|
| 963 |
+
__expected_copy_assign() = default;
|
| 964 |
+
__expected_copy_assign(const __expected_copy_assign&) = default;
|
| 965 |
+
__expected_copy_assign(__expected_copy_assign&&) = default;
|
| 966 |
+
|
| 967 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 968 |
+
__expected_copy_assign& operator=(const __expected_copy_assign& __other)
|
| 969 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_copy_assignable, _Err) &&
|
| 970 |
+
_LIBCUDACXX_TRAIT(is_nothrow_copy_constructible, _Err)) // strengthened
|
| 971 |
+
{
|
| 972 |
+
if (this->__has_val_ && __other.__has_val_) {
|
| 973 |
+
// nothing to do
|
| 974 |
+
} else if (this->__has_val_ && !__other.__has_val_) {
|
| 975 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, __other.__union_.__unex_);
|
| 976 |
+
this->__has_val_ = false;
|
| 977 |
+
} else if (!this->__has_val_ && __other.__has_val_) {
|
| 978 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));
|
| 979 |
+
this->__has_val_ = true;
|
| 980 |
+
} else { // !this->__has_val_ && !__other.__has_val_
|
| 981 |
+
this->__union_.__unex_ = __other.__union_.__unex_;
|
| 982 |
+
}
|
| 983 |
+
return *this;
|
| 984 |
+
}
|
| 985 |
+
|
| 986 |
+
__expected_copy_assign& operator=(__expected_copy_assign&&) = default;
|
| 987 |
+
};
|
| 988 |
+
|
| 989 |
+
template <class _Err>
|
| 990 |
+
struct __expected_move_assign<void, _Err, false> : __expected_copy_assign<void, _Err>
|
| 991 |
+
{
|
| 992 |
+
using __base = __expected_copy_assign<void, _Err>;
|
| 993 |
+
// nvbug3961621
|
| 994 |
+
#if defined(_LIBCUDACXX_COMPILER_NVRTC) \
|
| 995 |
+
|| (defined(_LIBCUDACXX_CUDACC_BELOW_11_3) && defined(_LIBCUDACXX_COMPILER_CLANG))
|
| 996 |
+
template<class... _Args, __enable_if_t<_LIBCUDACXX_TRAIT(is_constructible, __base, _Args...), int> = 0>
|
| 997 |
+
_LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 998 |
+
__expected_move_assign(_Args&&... __args) noexcept(noexcept(__base(_CUDA_VSTD::declval<_Args>()...)))
|
| 999 |
+
: __base(_CUDA_VSTD::forward<_Args>(__args)...)
|
| 1000 |
+
{}
|
| 1001 |
+
#else // ^^^ _LIBCUDACXX_COMPILER_NVRTC || nvcc < 11.3 ^^^ / vvv !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3 vvv
|
| 1002 |
+
using __base::__base;
|
| 1003 |
+
#endif // !_LIBCUDACXX_COMPILER_NVRTC || nvcc >= 11.3
|
| 1004 |
+
|
| 1005 |
+
__expected_move_assign() = default;
|
| 1006 |
+
__expected_move_assign(const __expected_move_assign&) = default;
|
| 1007 |
+
__expected_move_assign(__expected_move_assign&&) = default;
|
| 1008 |
+
__expected_move_assign& operator=(const __expected_move_assign&) = default;
|
| 1009 |
+
|
| 1010 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 1011 |
+
__expected_move_assign& operator=(__expected_move_assign&& __other)
|
| 1012 |
+
noexcept(_LIBCUDACXX_TRAIT(is_nothrow_move_assignable, _Err) &&
|
| 1013 |
+
_LIBCUDACXX_TRAIT(is_nothrow_move_constructible, _Err)) // strengthened
|
| 1014 |
+
{
|
| 1015 |
+
if (this->__has_val_ && __other.__has_val_) {
|
| 1016 |
+
// nothing to do
|
| 1017 |
+
} else if (this->__has_val_ && !__other.__has_val_) {
|
| 1018 |
+
_LIBCUDACXX_CONSTRUCT_AT(this->__union_.__unex_, _CUDA_VSTD::move(__other.__union_.__unex_));
|
| 1019 |
+
this->__has_val_ = false;
|
| 1020 |
+
} else if (!this->__has_val_ && __other.__has_val_) {
|
| 1021 |
+
_CUDA_VSTD::__destroy_at(_CUDA_VSTD::addressof(this->__union_.__unex_));
|
| 1022 |
+
this->__has_val_ = true;
|
| 1023 |
+
} else { // !this->__has_val_ && !__other.__has_val_
|
| 1024 |
+
this->__union_.__unex_ = _CUDA_VSTD::move(__other.__union_.__unex_);
|
| 1025 |
+
}
|
| 1026 |
+
return *this;
|
| 1027 |
+
}
|
| 1028 |
+
};
|
| 1029 |
+
|
| 1030 |
+
template <class _Err>
|
| 1031 |
+
using __expected_void_sfinae_ctor_base_t = __sfinae_ctor_base<
|
| 1032 |
+
_LIBCUDACXX_TRAIT(is_copy_constructible, _Err),
|
| 1033 |
+
_LIBCUDACXX_TRAIT(is_move_constructible, _Err)
|
| 1034 |
+
>;
|
| 1035 |
+
|
| 1036 |
+
template <class _Err>
|
| 1037 |
+
using __expected_void_sfinae_assign_base_t = __sfinae_assign_base<
|
| 1038 |
+
_LIBCUDACXX_TRAIT(is_copy_constructible, _Err) &&
|
| 1039 |
+
_LIBCUDACXX_TRAIT(is_copy_assignable, _Err),
|
| 1040 |
+
_LIBCUDACXX_TRAIT(is_move_constructible, _Err) &&
|
| 1041 |
+
_LIBCUDACXX_TRAIT(is_move_assignable, _Err)
|
| 1042 |
+
>;
|
| 1043 |
+
|
| 1044 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 1045 |
+
|
| 1046 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 1047 |
+
|
| 1048 |
+
#endif // _LIBCUDACXX___EXPECTED_EXPECTED_BASE_H
|
cuda_toolkit/include/__expected/unexpect.h
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
#ifndef _LIBCUDACXX___EXPECTED_UNEXPECT_H
|
| 10 |
+
#define _LIBCUDACXX___EXPECTED_UNEXPECT_H
|
| 11 |
+
|
| 12 |
+
#ifndef __cuda_std__
|
| 13 |
+
#include <__config>
|
| 14 |
+
#endif // __cuda_std__
|
| 15 |
+
|
| 16 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 17 |
+
# pragma GCC system_header
|
| 18 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 19 |
+
# pragma clang system_header
|
| 20 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 21 |
+
# pragma system_header
|
| 22 |
+
#endif // no system header
|
| 23 |
+
|
| 24 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 25 |
+
|
| 26 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 27 |
+
|
| 28 |
+
struct unexpect_t {
|
| 29 |
+
explicit unexpect_t() = default;
|
| 30 |
+
};
|
| 31 |
+
|
| 32 |
+
_LIBCUDACXX_CPO_ACCESSIBILITY unexpect_t unexpect{};
|
| 33 |
+
|
| 34 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 35 |
+
|
| 36 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 37 |
+
|
| 38 |
+
#endif // _LIBCUDACXX___EXPECTED_UNEXPECT_H
|
cuda_toolkit/include/__expected/unexpected.h
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//===----------------------------------------------------------------------===//
|
| 2 |
+
//
|
| 3 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 4 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 5 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 6 |
+
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES.
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___EXPECTED_UNEXPECTED_H
|
| 11 |
+
#define _LIBCUDACXX___EXPECTED_UNEXPECTED_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif // __cuda_std__
|
| 16 |
+
|
| 17 |
+
#include "../__concepts/__concept_macros.h"
|
| 18 |
+
#include "../__type_traits/integral_constant.h"
|
| 19 |
+
#include "../__type_traits/is_array.h"
|
| 20 |
+
#include "../__type_traits/is_const.h"
|
| 21 |
+
#include "../__type_traits/is_constructible.h"
|
| 22 |
+
#include "../__type_traits/is_nothrow_constructible.h"
|
| 23 |
+
#include "../__type_traits/is_object.h"
|
| 24 |
+
#include "../__type_traits/is_same.h"
|
| 25 |
+
#include "../__type_traits/is_swappable.h"
|
| 26 |
+
#include "../__type_traits/is_volatile.h"
|
| 27 |
+
#include "../__type_traits/remove_cvref.h"
|
| 28 |
+
#include "../__utility/forward.h"
|
| 29 |
+
#include "../__utility/in_place.h"
|
| 30 |
+
#include "../__utility/move.h"
|
| 31 |
+
|
| 32 |
+
#include "../initializer_list"
|
| 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 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 43 |
+
|
| 44 |
+
#if _LIBCUDACXX_STD_VER > 11
|
| 45 |
+
|
| 46 |
+
template <class _Err>
|
| 47 |
+
class unexpected;
|
| 48 |
+
|
| 49 |
+
namespace __unexpected {
|
| 50 |
+
template <class _Tp>
|
| 51 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_unexpected = false;
|
| 52 |
+
|
| 53 |
+
template <class _Err>
|
| 54 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __is_unexpected<unexpected<_Err>> = true;
|
| 55 |
+
|
| 56 |
+
template <class _Tp>
|
| 57 |
+
_LIBCUDACXX_INLINE_VAR constexpr bool __valid_unexpected = _LIBCUDACXX_TRAIT(is_object, _Tp) &&
|
| 58 |
+
!_LIBCUDACXX_TRAIT(is_array, _Tp) &&
|
| 59 |
+
!__is_unexpected<_Tp> &&
|
| 60 |
+
!_LIBCUDACXX_TRAIT(is_const, _Tp) &&
|
| 61 |
+
!_LIBCUDACXX_TRAIT(is_volatile, _Tp);
|
| 62 |
+
} // namespace __unexpected
|
| 63 |
+
|
| 64 |
+
// [expected.un.general]
|
| 65 |
+
template <class _Err>
|
| 66 |
+
class unexpected {
|
| 67 |
+
static_assert(__unexpected::__valid_unexpected<_Err>,
|
| 68 |
+
"[expected.un.general] states a program that instantiates std::unexpected for a non-object type, an "
|
| 69 |
+
"array type, a specialization of unexpected, or a cv-qualified type is ill-formed.");
|
| 70 |
+
|
| 71 |
+
template <class, class>
|
| 72 |
+
friend class expected;
|
| 73 |
+
|
| 74 |
+
public:
|
| 75 |
+
// [expected.un.ctor]
|
| 76 |
+
_LIBCUDACXX_HIDE_FROM_ABI unexpected(const unexpected&) = default;
|
| 77 |
+
_LIBCUDACXX_HIDE_FROM_ABI unexpected(unexpected&&) = default;
|
| 78 |
+
|
| 79 |
+
_LIBCUDACXX_TEMPLATE(class _Error = _Err)
|
| 80 |
+
_LIBCUDACXX_REQUIRES( (!_LIBCUDACXX_TRAIT(is_same, remove_cvref_t<_Error>, unexpected) &&
|
| 81 |
+
!_LIBCUDACXX_TRAIT(is_same, remove_cvref_t<_Error>, in_place_t) &&
|
| 82 |
+
_LIBCUDACXX_TRAIT(is_constructible, _Err, _Error)))
|
| 83 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 84 |
+
constexpr explicit unexpected(_Error&& __error) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Error))
|
| 85 |
+
: __unex_(_CUDA_VSTD::forward<_Error>(__error)) {}
|
| 86 |
+
|
| 87 |
+
_LIBCUDACXX_TEMPLATE(class... _Args)
|
| 88 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, _Args...))
|
| 89 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 90 |
+
constexpr explicit unexpected(in_place_t, _Args&&... __args) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, _Args...))
|
| 91 |
+
: __unex_(_CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 92 |
+
|
| 93 |
+
_LIBCUDACXX_TEMPLATE(class _Up, class... _Args)
|
| 94 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_constructible, _Err, initializer_list<_Up>&, _Args...))
|
| 95 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 96 |
+
constexpr explicit unexpected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(
|
| 97 |
+
_LIBCUDACXX_TRAIT(is_nothrow_constructible, _Err, initializer_list<_Up>&, _Args...))
|
| 98 |
+
: __unex_(__il, _CUDA_VSTD::forward<_Args>(__args)...) {}
|
| 99 |
+
|
| 100 |
+
constexpr unexpected& operator=(const unexpected&) = default;
|
| 101 |
+
constexpr unexpected& operator=(unexpected&&) = default;
|
| 102 |
+
|
| 103 |
+
// [expected.un.obs]
|
| 104 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 105 |
+
constexpr const _Err& error() const& noexcept {
|
| 106 |
+
return __unex_;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 110 |
+
constexpr _Err& error() & noexcept {
|
| 111 |
+
return __unex_;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 115 |
+
constexpr const _Err&& error() const&& noexcept {
|
| 116 |
+
return _CUDA_VSTD::move(__unex_);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
_LIBCUDACXX_NODISCARD_ATTRIBUTE _LIBCUDACXX_INLINE_VISIBILITY
|
| 120 |
+
constexpr _Err&& error() && noexcept {
|
| 121 |
+
return _CUDA_VSTD::move(__unex_);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
// [expected.un.swap]
|
| 125 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 126 |
+
constexpr void swap(unexpected& __other) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err)) {
|
| 127 |
+
static_assert(_LIBCUDACXX_TRAIT(is_swappable, _Err), "E must be swappable");
|
| 128 |
+
using _CUDA_VSTD::swap;
|
| 129 |
+
swap(__unex_, __other.__unex_);
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
_LIBCUDACXX_TEMPLATE(class _Err2 = _Err)
|
| 133 |
+
_LIBCUDACXX_REQUIRES( _LIBCUDACXX_TRAIT(is_swappable, _Err2))
|
| 134 |
+
friend _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 135 |
+
void swap(unexpected& __lhs, unexpected& __rhs) noexcept(_LIBCUDACXX_TRAIT(is_nothrow_swappable, _Err2))
|
| 136 |
+
{
|
| 137 |
+
__lhs.swap(__rhs);
|
| 138 |
+
return;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
// [expected.un.eq]
|
| 142 |
+
template <class _UErr>
|
| 143 |
+
friend _LIBCUDACXX_INLINE_VISIBILITY constexpr
|
| 144 |
+
_LIBCUDACXX_NODISCARD_EXT bool operator==(const unexpected& __lhs, const unexpected<_UErr>& __rhs) noexcept(
|
| 145 |
+
noexcept(static_cast<bool>(__lhs.error() == __rhs.error()))) {
|
| 146 |
+
return __lhs.error() == __rhs.error();
|
| 147 |
+
}
|
| 148 |
+
#if _LIBCUDACXX_STD_VER < 20
|
| 149 |
+
template <class _UErr>
|
| 150 |
+
_LIBCUDACXX_INLINE_VISIBILITY
|
| 151 |
+
_LIBCUDACXX_NODISCARD_EXT friend constexpr bool operator!=(const unexpected& __lhs, const unexpected<_UErr>& __rhs) noexcept(
|
| 152 |
+
noexcept(static_cast<bool>(__lhs.error() != __rhs.error()))) {
|
| 153 |
+
return __lhs.error() != __rhs.error();
|
| 154 |
+
}
|
| 155 |
+
#endif
|
| 156 |
+
|
| 157 |
+
private:
|
| 158 |
+
_Err __unex_;
|
| 159 |
+
};
|
| 160 |
+
|
| 161 |
+
#if _LIBCUDACXX_STD_VER > 14 && !defined(_LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES)
|
| 162 |
+
template <class _Err>
|
| 163 |
+
unexpected(_Err) -> unexpected<_Err>;
|
| 164 |
+
#endif // _LIBCUDACXX_STD_VER > 14 && !defined(_LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES)
|
| 165 |
+
|
| 166 |
+
#endif // _LIBCUDACXX_STD_VER > 11
|
| 167 |
+
|
| 168 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 169 |
+
|
| 170 |
+
#endif // _LIBCUDACXX___EXPECTED_UNEXPECTED_H
|
cuda_toolkit/include/__functional/binary_function.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
//
|
| 8 |
+
//===----------------------------------------------------------------------===//
|
| 9 |
+
|
| 10 |
+
#ifndef _LIBCUDACXX___FUNCTIONAL_BINARY_FUNCTION_H
|
| 11 |
+
#define _LIBCUDACXX___FUNCTIONAL_BINARY_FUNCTION_H
|
| 12 |
+
|
| 13 |
+
#ifndef __cuda_std__
|
| 14 |
+
#include <__config>
|
| 15 |
+
#endif // __cuda_std__
|
| 16 |
+
|
| 17 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 18 |
+
# pragma GCC system_header
|
| 19 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 20 |
+
# pragma clang system_header
|
| 21 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 22 |
+
# pragma system_header
|
| 23 |
+
#endif // no system header
|
| 24 |
+
|
| 25 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 26 |
+
|
| 27 |
+
#if _LIBCUDACXX_STD_VER <= 14 || defined(_LIBCUDACXX_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
|
| 28 |
+
|
| 29 |
+
template <class _Arg1, class _Arg2, class _Result>
|
| 30 |
+
struct _LIBCUDACXX_TEMPLATE_VIS _LIBCUDACXX_DEPRECATED_IN_CXX11 binary_function
|
| 31 |
+
{
|
| 32 |
+
typedef _Arg1 first_argument_type;
|
| 33 |
+
typedef _Arg2 second_argument_type;
|
| 34 |
+
typedef _Result result_type;
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
#endif // _LIBCUDACXX_STD_VER <= 14 || defined(_LIBCUDACXX_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
|
| 38 |
+
|
| 39 |
+
template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base {
|
| 40 |
+
#if _LIBCUDACXX_STD_VER <= 17 || defined(_LIBCUDACXX_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
|
| 41 |
+
using first_argument_type _LIBCUDACXX_DEPRECATED_IN_CXX17 = _Arg1;
|
| 42 |
+
using second_argument_type _LIBCUDACXX_DEPRECATED_IN_CXX17 = _Arg2;
|
| 43 |
+
using result_type _LIBCUDACXX_DEPRECATED_IN_CXX17 = _Result;
|
| 44 |
+
#endif
|
| 45 |
+
};
|
| 46 |
+
|
| 47 |
+
#if _LIBCUDACXX_STD_VER <= 14 || defined(_LIBCUDACXX_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
|
| 48 |
+
_CCCL_DIAG_SUPPRESS_DEPRECATED_PUSH
|
| 49 |
+
template <class _Arg1, class _Arg2, class _Result>
|
| 50 |
+
using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
|
| 51 |
+
_CCCL_DIAG_SUPPRESS_DEPRECATED_POP
|
| 52 |
+
#else
|
| 53 |
+
template <class _Arg1, class _Arg2, class _Result>
|
| 54 |
+
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 58 |
+
|
| 59 |
+
#endif // _LIBCUDACXX___FUNCTIONAL_BINARY_FUNCTION_H
|
cuda_toolkit/include/__functional/binary_negate.h
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___FUNCTIONAL_BINARY_NEGATE_H
|
| 12 |
+
#define _LIBCUDACXX___FUNCTIONAL_BINARY_NEGATE_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#include <__config>
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#include "../__functional/binary_function.h"
|
| 19 |
+
|
| 20 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 21 |
+
# pragma GCC system_header
|
| 22 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 23 |
+
# pragma clang system_header
|
| 24 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 25 |
+
# pragma system_header
|
| 26 |
+
#endif // no system header
|
| 27 |
+
|
| 28 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 29 |
+
|
| 30 |
+
#if _LIBCUDACXX_STD_VER <= 17 || defined(_LIBCUDACXX_ENABLE_CXX20_REMOVED_NEGATORS)
|
| 31 |
+
|
| 32 |
+
template <class _Predicate>
|
| 33 |
+
class _LIBCUDACXX_TEMPLATE_VIS _LIBCUDACXX_DEPRECATED_IN_CXX17 binary_negate
|
| 34 |
+
: public __binary_function<typename _Predicate::first_argument_type,
|
| 35 |
+
typename _Predicate::second_argument_type,
|
| 36 |
+
bool>
|
| 37 |
+
{
|
| 38 |
+
_Predicate __pred_;
|
| 39 |
+
public:
|
| 40 |
+
_LIBCUDACXX_INLINE_VISIBILITY explicit _LIBCUDACXX_CONSTEXPR_AFTER_CXX11
|
| 41 |
+
binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
|
| 42 |
+
|
| 43 |
+
_LIBCUDACXX_DISABLE_EXEC_CHECK
|
| 44 |
+
_LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY
|
| 45 |
+
bool operator()(const typename _Predicate::first_argument_type& __x,
|
| 46 |
+
const typename _Predicate::second_argument_type& __y) const
|
| 47 |
+
{return !__pred_(__x, __y);}
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
template <class _Predicate>
|
| 51 |
+
_LIBCUDACXX_DEPRECATED_IN_CXX17 inline _LIBCUDACXX_CONSTEXPR_AFTER_CXX11 _LIBCUDACXX_INLINE_VISIBILITY
|
| 52 |
+
binary_negate<_Predicate>
|
| 53 |
+
not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);}
|
| 54 |
+
|
| 55 |
+
#endif // _LIBCUDACXX_STD_VER <= 17 || defined(_LIBCUDACXX_ENABLE_CXX20_REMOVED_NE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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___FUNCTIONAL_BIND_H
|
| 12 |
+
#define _LIBCUDACXX___FUNCTIONAL_BIND_H
|
| 13 |
+
|
| 14 |
+
// `cuda::std::bind` is not currently supported.
|
| 15 |
+
|
| 16 |
+
#ifndef __cuda_std__
|
| 17 |
+
|
| 18 |
+
#ifndef __cuda_std__
|
| 19 |
+
#include <__config>
|
| 20 |
+
#endif // __cuda_std__
|
| 21 |
+
|
| 22 |
+
#include "../__functional/invoke.h"
|
| 23 |
+
#include "../__functional/reference_wrapper.h"
|
| 24 |
+
#include "../__functional/weak_result_type.h"
|
| 25 |
+
#include "../__fwd/get.h"
|
| 26 |
+
#include "../__tuple_dir/tuple_element.h"
|
| 27 |
+
#include "../__tuple_dir/tuple_indices.h"
|
| 28 |
+
#include "../__tuple_dir/tuple_size.h"
|
| 29 |
+
#include "../__type_traits/conditional.h"
|
| 30 |
+
#include "../__type_traits/decay.h"
|
| 31 |
+
#include "../__type_traits/enable_if.h"
|
| 32 |
+
#include "../__type_traits/integral_constant.h"
|
| 33 |
+
#include "../__type_traits/is_constructible.h"
|
| 34 |
+
#include "../__type_traits/is_convertible.h"
|
| 35 |
+
#include "../__type_traits/is_same.h"
|
| 36 |
+
#include "../__type_traits/is_void.h"
|
| 37 |
+
#include "../__type_traits/remove_cvref.h"
|
| 38 |
+
#include "../__type_traits/remove_reference.h"
|
| 39 |
+
#include "../__utility/forward.h"
|
| 40 |
+
|
| 41 |
+
#include "../cstddef"
|
| 42 |
+
#include "../tuple"
|
| 43 |
+
|
| 44 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 45 |
+
# pragma GCC system_header
|
| 46 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 47 |
+
# pragma clang system_header
|
| 48 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 49 |
+
# pragma system_header
|
| 50 |
+
#endif // no system header
|
| 51 |
+
|
| 52 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 53 |
+
|
| 54 |
+
template<class _Tp>
|
| 55 |
+
struct is_bind_expression : _If<
|
| 56 |
+
_IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
|
| 57 |
+
false_type,
|
| 58 |
+
is_bind_expression<__remove_cvref_t<_Tp> >
|
| 59 |
+
> {};
|
| 60 |
+
|
| 61 |
+
#if _LIBCUDACXX_STD_VER > 14
|
| 62 |
+
template <class _Tp>
|
| 63 |
+
inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value;
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
template<class _Tp>
|
| 67 |
+
struct is_placeholder : _If<
|
| 68 |
+
_IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
|
| 69 |
+
integral_constant<int, 0>,
|
| 70 |
+
is_placeholder<__remove_cvref_t<_Tp> >
|
| 71 |
+
> {};
|
| 72 |
+
|
| 73 |
+
#if _LIBCUDACXX_STD_VER > 14
|
| 74 |
+
template <class _Tp>
|
| 75 |
+
inline constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value;
|
| 76 |
+
#endif
|
| 77 |
+
|
| 78 |
+
namespace placeholders
|
| 79 |
+
{
|
| 80 |
+
|
| 81 |
+
template <int _Np> struct __ph {};
|
| 82 |
+
|
| 83 |
+
#if defined(_LIBCUDACXX_BUILDING_LIBRARY)
|
| 84 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<1> _1;
|
| 85 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<2> _2;
|
| 86 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<3> _3;
|
| 87 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<4> _4;
|
| 88 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<5> _5;
|
| 89 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<6> _6;
|
| 90 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<7> _7;
|
| 91 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<8> _8;
|
| 92 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<9> _9;
|
| 93 |
+
_LIBCUDACXX_FUNC_VIS extern const __ph<10> _10;
|
| 94 |
+
#else
|
| 95 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<1> _1{};
|
| 96 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<2> _2{};
|
| 97 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<3> _3{};
|
| 98 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<4> _4{};
|
| 99 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<5> _5{};
|
| 100 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<6> _6{};
|
| 101 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<7> _7{};
|
| 102 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<8> _8{};
|
| 103 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<9> _9{};
|
| 104 |
+
/* _LIBCUDACXX_INLINE_VAR */ constexpr __ph<10> _10{};
|
| 105 |
+
#endif // defined(_LIBCUDACXX_BUILDING_LIBRARY)
|
| 106 |
+
|
| 107 |
+
} // namespace placeholders
|
| 108 |
+
|
| 109 |
+
template<int _Np>
|
| 110 |
+
struct is_placeholder<placeholders::__ph<_Np> >
|
| 111 |
+
: public integral_constant<int, _Np> {};
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
template <class _Tp, class _Uj>
|
| 115 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 116 |
+
_Tp&
|
| 117 |
+
__mu(reference_wrapper<_Tp> __t, _Uj&)
|
| 118 |
+
{
|
| 119 |
+
return __t.get();
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
template <class _Ti, class ..._Uj, size_t ..._Indx>
|
| 123 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 124 |
+
typename __invoke_of<_Ti&, _Uj...>::type
|
| 125 |
+
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
|
| 126 |
+
{
|
| 127 |
+
return __ti(_CUDA_VSTD::forward<_Uj>(_CUDA_VSTD::get<_Indx>(__uj))...);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
template <class _Ti, class ..._Uj>
|
| 131 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 132 |
+
__enable_if_t
|
| 133 |
+
<
|
| 134 |
+
is_bind_expression<_Ti>::value,
|
| 135 |
+
__invoke_of<_Ti&, _Uj...>
|
| 136 |
+
>
|
| 137 |
+
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
|
| 138 |
+
{
|
| 139 |
+
typedef __make_tuple_indices_t<sizeof...(_Uj)> __indices;
|
| 140 |
+
return _CUDA_VSTD::__mu_expand(__ti, __uj, __indices());
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
template <bool IsPh, class _Ti, class _Uj>
|
| 144 |
+
struct __mu_return2 {};
|
| 145 |
+
|
| 146 |
+
template <class _Ti, class _Uj>
|
| 147 |
+
struct __mu_return2<true, _Ti, _Uj>
|
| 148 |
+
{
|
| 149 |
+
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _Uj> type;
|
| 150 |
+
};
|
| 151 |
+
|
| 152 |
+
template <class _Ti, class _Uj>
|
| 153 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 154 |
+
__enable_if_t
|
| 155 |
+
<
|
| 156 |
+
0 < is_placeholder<_Ti>::value,
|
| 157 |
+
typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
|
| 158 |
+
>
|
| 159 |
+
__mu(_Ti&, _Uj& __uj)
|
| 160 |
+
{
|
| 161 |
+
const size_t _Indx = is_placeholder<_Ti>::value - 1;
|
| 162 |
+
return _CUDA_VSTD::forward<__tuple_element_t<_Indx, _Uj>>(_CUDA_VSTD::get<_Indx>(__uj));
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
template <class _Ti, class _Uj>
|
| 166 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 167 |
+
__enable_if_t
|
| 168 |
+
<
|
| 169 |
+
!is_bind_expression<_Ti>::value &&
|
| 170 |
+
is_placeholder<_Ti>::value == 0 &&
|
| 171 |
+
!__is_reference_wrapper<_Ti>::value,
|
| 172 |
+
_Ti&
|
| 173 |
+
>
|
| 174 |
+
__mu(_Ti& __ti, _Uj&)
|
| 175 |
+
{
|
| 176 |
+
return __ti;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh,
|
| 180 |
+
class _TupleUj>
|
| 181 |
+
struct __mu_return_impl;
|
| 182 |
+
|
| 183 |
+
template <bool _Invokable, class _Ti, class ..._Uj>
|
| 184 |
+
struct __mu_return_invokable // false
|
| 185 |
+
{
|
| 186 |
+
typedef __nat type;
|
| 187 |
+
};
|
| 188 |
+
|
| 189 |
+
template <class _Ti, class ..._Uj>
|
| 190 |
+
struct __mu_return_invokable<true, _Ti, _Uj...>
|
| 191 |
+
{
|
| 192 |
+
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
|
| 193 |
+
};
|
| 194 |
+
|
| 195 |
+
template <class _Ti, class ..._Uj>
|
| 196 |
+
struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
|
| 197 |
+
: public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...>
|
| 198 |
+
{
|
| 199 |
+
};
|
| 200 |
+
|
| 201 |
+
template <class _Ti, class _TupleUj>
|
| 202 |
+
struct __mu_return_impl<_Ti, false, false, true, _TupleUj>
|
| 203 |
+
{
|
| 204 |
+
typedef __tuple_element_t<is_placeholder<_Ti>::value - 1, _TupleUj>&& type;
|
| 205 |
+
};
|
| 206 |
+
|
| 207 |
+
template <class _Ti, class _TupleUj>
|
| 208 |
+
struct __mu_return_impl<_Ti, true, false, false, _TupleUj>
|
| 209 |
+
{
|
| 210 |
+
typedef typename _Ti::type& type;
|
| 211 |
+
};
|
| 212 |
+
|
| 213 |
+
template <class _Ti, class _TupleUj>
|
| 214 |
+
struct __mu_return_impl<_Ti, false, false, false, _TupleUj>
|
| 215 |
+
{
|
| 216 |
+
typedef _Ti& type;
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
template <class _Ti, class _TupleUj>
|
| 220 |
+
struct __mu_return
|
| 221 |
+
: public __mu_return_impl<_Ti,
|
| 222 |
+
__is_reference_wrapper<_Ti>::value,
|
| 223 |
+
is_bind_expression<_Ti>::value,
|
| 224 |
+
0 < is_placeholder<_Ti>::value &&
|
| 225 |
+
is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
|
| 226 |
+
_TupleUj>
|
| 227 |
+
{
|
| 228 |
+
};
|
| 229 |
+
|
| 230 |
+
template <class _Fp, class _BoundArgs, class _TupleUj>
|
| 231 |
+
struct __is_valid_bind_return
|
| 232 |
+
{
|
| 233 |
+
static const bool value = false;
|
| 234 |
+
};
|
| 235 |
+
|
| 236 |
+
template <class _Fp, class ..._BoundArgs, class _TupleUj>
|
| 237 |
+
struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj>
|
| 238 |
+
{
|
| 239 |
+
static const bool value = __invokable<_Fp,
|
| 240 |
+
typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
|
| 241 |
+
};
|
| 242 |
+
|
| 243 |
+
template <class _Fp, class ..._BoundArgs, class _TupleUj>
|
| 244 |
+
struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
|
| 245 |
+
{
|
| 246 |
+
static const bool value = __invokable<_Fp,
|
| 247 |
+
typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
|
| 248 |
+
};
|
| 249 |
+
|
| 250 |
+
template <class _Fp, class _BoundArgs, class _TupleUj,
|
| 251 |
+
bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
|
| 252 |
+
struct __bind_return;
|
| 253 |
+
|
| 254 |
+
template <class _Fp, class ..._BoundArgs, class _TupleUj>
|
| 255 |
+
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true>
|
| 256 |
+
{
|
| 257 |
+
typedef typename __invoke_of
|
| 258 |
+
<
|
| 259 |
+
_Fp&,
|
| 260 |
+
typename __mu_return
|
| 261 |
+
<
|
| 262 |
+
_BoundArgs,
|
| 263 |
+
_TupleUj
|
| 264 |
+
>::type...
|
| 265 |
+
>::type type;
|
| 266 |
+
};
|
| 267 |
+
|
| 268 |
+
template <class _Fp, class ..._BoundArgs, class _TupleUj>
|
| 269 |
+
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
|
| 270 |
+
{
|
| 271 |
+
typedef typename __invoke_of
|
| 272 |
+
<
|
| 273 |
+
_Fp&,
|
| 274 |
+
typename __mu_return
|
| 275 |
+
<
|
| 276 |
+
const _BoundArgs,
|
| 277 |
+
_TupleUj
|
| 278 |
+
>::type...
|
| 279 |
+
>::type type;
|
| 280 |
+
};
|
| 281 |
+
|
| 282 |
+
template <class _Fp, class _BoundArgs, class _TupleUj>
|
| 283 |
+
using __bind_return_t = typename __bind_return<_Fp, _BoundArgs, _TupleUj>::type;
|
| 284 |
+
|
| 285 |
+
template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
|
| 286 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY
|
| 287 |
+
__bind_return_t<_Fp, _BoundArgs, _Args>
|
| 288 |
+
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
|
| 289 |
+
_Args&& __args)
|
| 290 |
+
{
|
| 291 |
+
return _CUDA_VSTD::__invoke(__f, _CUDA_VSTD::__mu(_CUDA_VSTD::get<_Indx>(__bound_args), __args)...);
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
template<class _Fp, class ..._BoundArgs>
|
| 295 |
+
class __bind : public __weak_result_type<__decay_t<_Fp>>
|
| 296 |
+
{
|
| 297 |
+
protected:
|
| 298 |
+
typedef __decay_t<_Fp> _Fd;
|
| 299 |
+
typedef tuple<__decay_t<_BoundArgs>...> _Td;
|
| 300 |
+
private:
|
| 301 |
+
_Fd __f_;
|
| 302 |
+
_Td __bound_args_;
|
| 303 |
+
|
| 304 |
+
typedef __make_tuple_indices_t<sizeof...(_BoundArgs)> __indices;
|
| 305 |
+
public:
|
| 306 |
+
template <class _Gp, class ..._BA,
|
| 307 |
+
class = __enable_if_t
|
| 308 |
+
<
|
| 309 |
+
is_constructible<_Fd, _Gp>::value &&
|
| 310 |
+
!is_same<__libcpp_remove_reference_t<_Gp>,
|
| 311 |
+
__bind>::value
|
| 312 |
+
>>
|
| 313 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 314 |
+
explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
|
| 315 |
+
: __f_(_CUDA_VSTD::forward<_Gp>(__f)),
|
| 316 |
+
__bound_args_(_CUDA_VSTD::forward<_BA>(__bound_args)...) {}
|
| 317 |
+
|
| 318 |
+
template <class ..._Args>
|
| 319 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 320 |
+
__bind_return_t<_Fd, _Td, tuple<_Args&&...>>
|
| 321 |
+
operator()(_Args&& ...__args)
|
| 322 |
+
{
|
| 323 |
+
return _CUDA_VSTD::__apply_functor(__f_, __bound_args_, __indices(),
|
| 324 |
+
tuple<_Args&&...>(_CUDA_VSTD::forward<_Args>(__args)...));
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
template <class ..._Args>
|
| 328 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 329 |
+
__bind_return_t<const _Fd, const _Td, tuple<_Args&&...>>
|
| 330 |
+
operator()(_Args&& ...__args) const
|
| 331 |
+
{
|
| 332 |
+
return _CUDA_VSTD::__apply_functor(__f_, __bound_args_, __indices(),
|
| 333 |
+
tuple<_Args&&...>(_CUDA_VSTD::forward<_Args>(__args)...));
|
| 334 |
+
}
|
| 335 |
+
};
|
| 336 |
+
|
| 337 |
+
template<class _Fp, class ..._BoundArgs>
|
| 338 |
+
struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
|
| 339 |
+
|
| 340 |
+
template<class _Rp, class _Fp, class ..._BoundArgs>
|
| 341 |
+
class __bind_r
|
| 342 |
+
: public __bind<_Fp, _BoundArgs...>
|
| 343 |
+
{
|
| 344 |
+
typedef __bind<_Fp, _BoundArgs...> base;
|
| 345 |
+
typedef typename base::_Fd _Fd;
|
| 346 |
+
typedef typename base::_Td _Td;
|
| 347 |
+
public:
|
| 348 |
+
typedef _Rp result_type;
|
| 349 |
+
|
| 350 |
+
|
| 351 |
+
template <class _Gp, class ..._BA,
|
| 352 |
+
class = __enable_if_t
|
| 353 |
+
<
|
| 354 |
+
is_constructible<_Fd, _Gp>::value &&
|
| 355 |
+
!is_same<__libcpp_remove_reference_t<_Gp>,
|
| 356 |
+
__bind_r>::value
|
| 357 |
+
>>
|
| 358 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 359 |
+
explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
|
| 360 |
+
: base(_CUDA_VSTD::forward<_Gp>(__f),
|
| 361 |
+
_CUDA_VSTD::forward<_BA>(__bound_args)...) {}
|
| 362 |
+
|
| 363 |
+
template <class ..._Args>
|
| 364 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 365 |
+
__enable_if_t
|
| 366 |
+
<
|
| 367 |
+
is_convertible<__bind_return_t<_Fd, _Td, tuple<_Args&&...>>,
|
| 368 |
+
result_type>::value || is_void<_Rp>::value,
|
| 369 |
+
result_type
|
| 370 |
+
>
|
| 371 |
+
operator()(_Args&& ...__args)
|
| 372 |
+
{
|
| 373 |
+
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
|
| 374 |
+
return _Invoker::__call(static_cast<base&>(*this), _CUDA_VSTD::forward<_Args>(__args)...);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
template <class ..._Args>
|
| 378 |
+
_LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 379 |
+
__enable_if_t
|
| 380 |
+
<
|
| 381 |
+
is_convertible<__bind_return_t<const _Fd, const _Td, tuple<_Args&&...>>,
|
| 382 |
+
result_type>::value || is_void<_Rp>::value,
|
| 383 |
+
result_type
|
| 384 |
+
>
|
| 385 |
+
operator()(_Args&& ...__args) const
|
| 386 |
+
{
|
| 387 |
+
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
|
| 388 |
+
return _Invoker::__call(static_cast<base const&>(*this), _CUDA_VSTD::forward<_Args>(__args)...);
|
| 389 |
+
}
|
| 390 |
+
};
|
| 391 |
+
|
| 392 |
+
template<class _Rp, class _Fp, class ..._BoundArgs>
|
| 393 |
+
struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
|
| 394 |
+
|
| 395 |
+
template<class _Fp, class ..._BoundArgs>
|
| 396 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 397 |
+
__bind<_Fp, _BoundArgs...>
|
| 398 |
+
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
|
| 399 |
+
{
|
| 400 |
+
typedef __bind<_Fp, _BoundArgs...> type;
|
| 401 |
+
return type(_CUDA_VSTD::forward<_Fp>(__f), _CUDA_VSTD::forward<_BoundArgs>(__bound_args)...);
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
template<class _Rp, class _Fp, class ..._BoundArgs>
|
| 405 |
+
inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_CONSTEXPR_AFTER_CXX17
|
| 406 |
+
__bind_r<_Rp, _Fp, _BoundArgs...>
|
| 407 |
+
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
|
| 408 |
+
{
|
| 409 |
+
typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
|
| 410 |
+
return type(_CUDA_VSTD::forward<_Fp>(__f), _CUDA_VSTD::forward<_BoundArgs>(__bound_args)...);
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 414 |
+
|
| 415 |
+
#endif // __cuda_std__
|
| 416 |
+
|
| 417 |
+
#endif // _LIBCUDACXX___FUNCTIONAL_BIND_H
|
cuda_toolkit/include/__functional/bind_back.h
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// -*- C++ -*-
|
| 2 |
+
//===----------------------------------------------------------------------===//
|
| 3 |
+
//
|
| 4 |
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
| 5 |
+
// See https://llvm.org/LICENSE.txt for license information.
|
| 6 |
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
| 7 |
+
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
|
| 8 |
+
//
|
| 9 |
+
//===----------------------------------------------------------------------===//
|
| 10 |
+
|
| 11 |
+
#ifndef _LIBCUDACXX___FUNCTIONAL_BIND_BACK_H
|
| 12 |
+
#define _LIBCUDACXX___FUNCTIONAL_BIND_BACK_H
|
| 13 |
+
|
| 14 |
+
#ifndef __cuda_std__
|
| 15 |
+
#include <__config>
|
| 16 |
+
#endif // __cuda_std__
|
| 17 |
+
|
| 18 |
+
#include "../__functional/invoke.h"
|
| 19 |
+
#include "../__functional/perfect_forward.h"
|
| 20 |
+
#include "../__fwd/get.h"
|
| 21 |
+
#include "../__tuple_dir/tuple_size.h"
|
| 22 |
+
#include "../__type_traits/decay.h"
|
| 23 |
+
#include "../__type_traits/enable_if.h"
|
| 24 |
+
#include "../__type_traits/is_constructible.h"
|
| 25 |
+
#include "../__type_traits/is_move_constructible.h"
|
| 26 |
+
#include "../__utility/forward.h"
|
| 27 |
+
#include "../__utility/integer_sequence.h"
|
| 28 |
+
|
| 29 |
+
#include "../tuple"
|
| 30 |
+
|
| 31 |
+
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
|
| 32 |
+
# pragma GCC system_header
|
| 33 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
|
| 34 |
+
# pragma clang system_header
|
| 35 |
+
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
|
| 36 |
+
# pragma system_header
|
| 37 |
+
#endif // no system header
|
| 38 |
+
|
| 39 |
+
_LIBCUDACXX_BEGIN_NAMESPACE_STD
|
| 40 |
+
|
| 41 |
+
#if _LIBCUDACXX_STD_VER > 14
|
| 42 |
+
|
| 43 |
+
template <size_t _NBound, class = make_index_sequence<_NBound>>
|
| 44 |
+
struct __bind_back_op;
|
| 45 |
+
|
| 46 |
+
template <size_t _NBound, size_t ..._Ip>
|
| 47 |
+
struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
|
| 48 |
+
template <class _Fn, class _BoundArgs, class... _Args>
|
| 49 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 50 |
+
constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
|
| 51 |
+
noexcept(noexcept(_CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward<_Args>(__args)..., _CUDA_VSTD::get<_Ip>(_CUDA_VSTD::forward<_BoundArgs>(__bound_args))...)))
|
| 52 |
+
-> decltype( _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward<_Args>(__args)..., _CUDA_VSTD::get<_Ip>(_CUDA_VSTD::forward<_BoundArgs>(__bound_args))...))
|
| 53 |
+
{ return _CUDA_VSTD::invoke(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward<_Args>(__args)..., _CUDA_VSTD::get<_Ip>(_CUDA_VSTD::forward<_BoundArgs>(__bound_args))...); }
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
template <class _Fn, class _BoundArgs>
|
| 57 |
+
struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs> {
|
| 58 |
+
using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
template <class _Fn, class ..._Args, class = enable_if_t<
|
| 62 |
+
_And<
|
| 63 |
+
is_constructible<decay_t<_Fn>, _Fn>,
|
| 64 |
+
is_move_constructible<decay_t<_Fn>>,
|
| 65 |
+
is_constructible<decay_t<_Args>, _Args>...,
|
| 66 |
+
is_move_constructible<decay_t<_Args>>...
|
| 67 |
+
>::value
|
| 68 |
+
>>
|
| 69 |
+
_LIBCUDACXX_HIDE_FROM_ABI _LIBCUDACXX_INLINE_VISIBILITY
|
| 70 |
+
constexpr auto __bind_back(_Fn&& __f, _Args&&... __args)
|
| 71 |
+
noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Args>(__args)...))))
|
| 72 |
+
-> decltype( __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Args>(__args)...)))
|
| 73 |
+
{ return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_CUDA_VSTD::forward<_Fn>(__f), _CUDA_VSTD::forward_as_tuple(_CUDA_VSTD::forward<_Args>(__args)...)); }
|
| 74 |
+
|
| 75 |
+
#endif // _LIBCUDACXX_STD_VER > 14
|
| 76 |
+
|
| 77 |
+
_LIBCUDACXX_END_NAMESPACE_STD
|
| 78 |
+
|
| 79 |
+
#endif // _LIBCUDACXX___FUNCTIONAL_BIND_BACK_H
|