Skip to content

Commit 7880d6c

Browse files
authored
Isolate cuda::std::extent forward declarations (#7936)
1 parent 7ec55fc commit 7880d6c

File tree

3 files changed

+76
-38
lines changed

3 files changed

+76
-38
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

libcudacxx/include/cuda/std/__fwd/mdspan.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# pragma system_header
2929
#endif // no system header
3030

31-
#include <cuda/std/__cstddef/types.h>
31+
#include <cuda/std/__fwd/extents.h>
3232
#include <cuda/std/__type_traits/void_t.h>
3333

3434
#include <cuda/std/__cccl/prologue.h>
@@ -107,14 +107,6 @@ inline constexpr bool __is_cuda_std_layout_left_or_right_mapping_v =
107107
// template<>
108108
// inline constexpr bool __is_cuda_std_layout_left_mapping_v<layout_left_padded> = true;
109109

110-
template <class _IndexType, size_t... _Extents>
111-
class extents;
112-
113-
template <class _Tp>
114-
inline constexpr bool __is_cuda_std_extents_v = false;
115-
template <class _IndexType, size_t... _Extents>
116-
inline constexpr bool __is_cuda_std_extents_v<extents<_IndexType, _Extents...>> = true;
117-
118110
_CCCL_END_NAMESPACE_CUDA_STD
119111

120112
#include <cuda/std/__cccl/epilogue.h>

libcudacxx/include/cuda/std/__mdspan/extents.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -609,35 +609,6 @@ class extents : private __mdspan_detail::__maybe_static_array<_IndexType, size_t
609609
#endif // _CCCL_STD_VER <= 2017
610610
};
611611

612-
// Recursive helper classes to implement dextents alias for extents
613-
namespace __mdspan_detail
614-
{
615-
template <class _IndexType, size_t _Rank, class _Extents = extents<_IndexType>>
616-
struct __make_dextents;
617-
618-
template <class _IndexType, size_t _Rank, class _Extents = extents<_IndexType>>
619-
using __make_dextents_t = typename __make_dextents<_IndexType, _Rank, _Extents>::type;
620-
621-
template <class _IndexType, size_t _Rank, size_t... _ExtentsPack>
622-
struct __make_dextents<_IndexType, _Rank, extents<_IndexType, _ExtentsPack...>>
623-
{
624-
using type = __make_dextents_t<_IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>;
625-
};
626-
627-
template <class _IndexType, size_t... _ExtentsPack>
628-
struct __make_dextents<_IndexType, 0, extents<_IndexType, _ExtentsPack...>>
629-
{
630-
using type = extents<_IndexType, _ExtentsPack...>;
631-
};
632-
} // end namespace __mdspan_detail
633-
634-
// [mdspan.extents.dextents], alias template
635-
template <class _IndexType, size_t _Rank>
636-
using dextents = __mdspan_detail::__make_dextents_t<_IndexType, _Rank>;
637-
638-
template <size_t _Rank, class _IndexType = size_t>
639-
using dims = dextents<_IndexType, _Rank>;
640-
641612
// nvcc cannot handle type conversions without this workaround
642613
struct __to_dynamic_extent
643614
{

0 commit comments

Comments
 (0)