|
| 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) 2026 NVIDIA CORPORATION & AFFILIATES. |
| 7 | +// |
| 8 | +// Kokkos v. 4.0 |
| 9 | +// Copyright (2022) National Technology & Engineering |
| 10 | +// Solutions of Sandia, LLC (NTESS). |
| 11 | +// |
| 12 | +// Under the terms of Contract DE-NA0003525 with NTESS, |
| 13 | +// the U.S. Government retains certain rights in this software. |
| 14 | +// |
| 15 | +//===----------------------------------------------------------------------===// |
| 16 | + |
| 17 | +#ifndef _CUDA_STD___FWD_EXTENTS_H |
| 18 | +#define _CUDA_STD___FWD_EXTENTS_H |
| 19 | + |
| 20 | +#include <cuda/std/detail/__config> |
| 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 <cuda/std/__cstddef/types.h> |
| 31 | +#include <cuda/std/__fwd/span.h> |
| 32 | + |
| 33 | +#include <cuda/std/__cccl/prologue.h> |
| 34 | + |
| 35 | +_CCCL_BEGIN_NAMESPACE_CUDA_STD |
| 36 | + |
| 37 | +template <class _IndexType, size_t... _Extents> |
| 38 | +class extents; |
| 39 | + |
| 40 | +template <class _Tp> |
| 41 | +inline constexpr bool __is_cuda_std_extents_v = false; |
| 42 | +template <class _IndexType, size_t... _Extents> |
| 43 | +inline constexpr bool __is_cuda_std_extents_v<extents<_IndexType, _Extents...>> = true; |
| 44 | + |
| 45 | +// Recursive helper classes to implement dextents alias for extents |
| 46 | +template <class _IndexType, size_t _Rank, class _Extents = extents<_IndexType>> |
| 47 | +struct __make_dextents; |
| 48 | + |
| 49 | +template <class _IndexType, size_t _Rank, class _Extents = extents<_IndexType>> |
| 50 | +using __make_dextents_t = typename __make_dextents<_IndexType, _Rank, _Extents>::type; |
| 51 | + |
| 52 | +template <class _IndexType, size_t _Rank, size_t... _ExtentsPack> |
| 53 | +struct __make_dextents<_IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> |
| 54 | +{ |
| 55 | + using type = __make_dextents_t<_IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>; |
| 56 | +}; |
| 57 | + |
| 58 | +template <class _IndexType, size_t... _ExtentsPack> |
| 59 | +struct __make_dextents<_IndexType, 0, extents<_IndexType, _ExtentsPack...>> |
| 60 | +{ |
| 61 | + using type = extents<_IndexType, _ExtentsPack...>; |
| 62 | +}; |
| 63 | + |
| 64 | +// [mdspan.extents.dextents], alias template |
| 65 | +template <class _IndexType, size_t _Rank> |
| 66 | +using dextents = __make_dextents_t<_IndexType, _Rank>; |
| 67 | + |
| 68 | +template <size_t _Rank, class _IndexType = size_t> |
| 69 | +using dims = dextents<_IndexType, _Rank>; |
| 70 | + |
| 71 | +_CCCL_END_NAMESPACE_CUDA_STD |
| 72 | + |
| 73 | +#include <cuda/std/__cccl/epilogue.h> |
| 74 | + |
| 75 | +#endif // _CUDA_STD___FWD_MDSPAN_H |
0 commit comments