Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up the cuda::std::span implementation with minimal c++14 range support #3211

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <cuda/std/__concepts/totally_ordered.h>
#include <cuda/std/__utility/forward.h>

#if _CCCL_STD_VER >= 2017
#if _CCCL_STD_VER >= 2014

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES
_LIBCUDACXX_BEGIN_NAMESPACE_RANGES_ABI
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ concept indirectly_copyable_storable =
// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle
// (both iter_swap and indirectly_swappable require indirectly_readable).

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [iterator.concept.readable]
template <class _In>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ using iter_difference_t =
incrementable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::difference_type;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [incrementable.traits]
template <class, class = void>
Expand Down Expand Up @@ -150,7 +150,7 @@ using iter_difference_t =
incrementable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::difference_type;

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ template <class _Iter1, class _Iter2, class _BinaryPred, class _Proj1 = identity
concept indirectly_comparable =
indirect_binary_predicate<_BinaryPred, projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

// clang-format off

Expand All @@ -50,7 +50,7 @@ _CCCL_CONCEPT indirectly_comparable =

// clang-format on

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/iter_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
_CCCL_DIAG_PUSH
_CCCL_DIAG_SUPPRESS_CLANG("-Wvoid-ptr-dereference")

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

// [iterator.cust.move]

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/iter_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <cuda/std/__utility/forward.h>
#include <cuda/std/__utility/move.h>

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

// [iter.cust.swap]

Expand Down Expand Up @@ -158,6 +158,6 @@ _CCCL_INLINE_VAR constexpr bool __noexcept_swappable<_I1, _I2, enable_if_t<indir

_LIBCUDACXX_END_NAMESPACE_STD

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

#endif // _LIBCUDACXX___ITERATOR_ITER_SWAP_H
11 changes: 5 additions & 6 deletions libcudacxx/include/cuda/std/__iterator/iterator_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <cuda/std/__type_traits/add_const.h>
#include <cuda/std/__type_traits/integral_constant.h>
#include <cuda/std/__type_traits/is_convertible.h>
#include <cuda/std/__type_traits/is_pointer.h>
#include <cuda/std/__type_traits/is_primary_template.h>
#include <cuda/std/__type_traits/remove_cv.h>
#include <cuda/std/__type_traits/void_t.h>
Expand Down Expand Up @@ -93,7 +92,7 @@ using iter_reference_t = decltype(*declval<_Tp&>());
template <class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

template <class _Tp>
using __with_reference = _Tp&;
Expand All @@ -119,10 +118,10 @@ using iter_reference_t = enable_if_t<__dereferenceable<_Tp>, decltype(*declval<_

template <class, class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;
#else // ^^^ _CCCL_STD_VER > 2014 ^^^ / vvv _CCCL_STD_VER <= 2014 vvv
#else // ^^^ _CCCL_STD_VER >= 2014 ^^^ / vvv _CCCL_STD_VER < 2014 vvv
template <class>
struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits;
#endif // _CCCL_STD_VER <= 2014
#endif // _CCCL_STD_VER < 2014

#if _CCCL_COMPILER(NVRTC)

Expand Down Expand Up @@ -530,7 +529,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits : __iterator_traits<_Ip>
using __primary_template = iterator_traits;
};

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^ / vvv _CCCL_STD_VER > 2014 vvv
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^ / vvv _CCCL_STD_VER > 2014 vvv

// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
// from `[iterator.cpp17]`. To avoid confusion between the two, the exposition-only concepts have been banished to
Expand Down Expand Up @@ -860,7 +859,7 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT iterator_traits<_Tp*>
typedef _Tp* pointer;
typedef typename add_lvalue_reference<_Tp>::type reference;
typedef random_access_iterator_tag iterator_category;
#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014
typedef contiguous_iterator_tag iterator_concept;
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/mergeable.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ concept mergeable =
&& indirectly_copyable<_Input1, _Output> && indirectly_copyable<_Input2, _Output>
&& indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Input1, class _Input2, class _Output, class _Comp, class _Proj1, class _Proj2>
_CCCL_CONCEPT_FRAGMENT(
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/permutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ template <class _Iterator>
concept permutable = forward_iterator<_Iterator> && indirectly_movable_storable<_Iterator, _Iterator>
&& indirectly_swappable<_Iterator, _Iterator>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Iterator>
_CCCL_CONCEPT_FRAGMENT(__permutable_,
Expand All @@ -43,7 +43,7 @@ _CCCL_CONCEPT_FRAGMENT(__permutable_,
template <class _Iterator>
_CCCL_CONCEPT permutable = _CCCL_FRAGMENT(__permutable_, _Iterator);

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/projected.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

template <class _It, class _Proj, class = void>
struct __projected_impl
Expand All @@ -54,7 +54,7 @@ _CCCL_TEMPLATE(class _It, class _Proj)
_CCCL_REQUIRES(indirectly_readable<_It> _CCCL_AND indirectly_regular_unary_invocable<_Proj, _It>)
using projected = typename __projected_impl<_It, _Proj>::__type;

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/readable_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ using iter_value_t =
indirectly_readable_traits<remove_cvref_t<_Ip>>,
iterator_traits<remove_cvref_t<_Ip>>>::value_type;

#elif _CCCL_STD_VER > 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^
#elif _CCCL_STD_VER >= 2014 // ^^^ !_CCCL_NO_CONCEPTS ^^^

// [readable.traits]
template <class, class = void>
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__iterator/sortable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD
template <class _Iter, class _Comp = _CUDA_VRANGES::less, class _Proj = identity>
concept sortable = permutable<_Iter> && indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>;

#elif _CCCL_STD_VER > 2014
#elif _CCCL_STD_VER >= 2014

template <class _Iter, class _Comp, class _Proj>
_CCCL_CONCEPT_FRAGMENT(
Expand All @@ -44,7 +44,7 @@ _CCCL_CONCEPT_FRAGMENT(
template <class _Iter, class _Comp = _CUDA_VRANGES::less, class _Proj = identity>
_CCCL_CONCEPT sortable = _CCCL_FRAGMENT(__sortable_, _Iter, _Comp, _Proj);

#endif // _CCCL_STD_VER > 2014
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER > 2014 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

template <class _Tp>
_CCCL_CONCEPT __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>;
Expand Down Expand Up @@ -279,7 +279,7 @@ inline namespace __cpo
{
_CCCL_GLOBAL_CONSTANT auto cend = __cend::__fn{};
} // namespace __cpo
#endif // _CCCL_STD_VER > 2014 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

# if !defined(_CCCL_NO_CONCEPTS)

Expand Down Expand Up @@ -302,7 +302,7 @@ template <class _Range, class _Tp>
_CCCL_CONCEPT __container_compatible_range = _CCCL_FRAGMENT(__container_compatible_range_, _Range, _Tp);
# endif // _CCCL_NO_CONCEPTS

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/dangling.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

struct dangling
{
Expand All @@ -47,7 +47,7 @@ using borrowed_iterator_t = enable_if_t<range<_Rp>, _If<borrowed_range<_Rp>, ite

// borrowed_subrange_t defined in <__ranges/subrange.h>

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

// [range.prim.data]

Expand Down Expand Up @@ -128,7 +128,7 @@ inline namespace __cpo
_CCCL_GLOBAL_CONSTANT auto cdata = __cdata::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# pragma system_header
#endif // no system header

#if _CCCL_STD_VER > 2014
#if _CCCL_STD_VER >= 2014

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/enable_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017
#if _CCCL_STD_VER >= 2014

struct view_base
{};
Expand Down Expand Up @@ -74,7 +74,7 @@ _CCCL_INLINE_VAR constexpr bool
true;
# endif // _CCCL_NO_CONCEPTS

#endif // _CCCL_STD_VER >= 2017
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
15 changes: 4 additions & 11 deletions libcudacxx/include/cuda/std/__ranges/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

_LIBCUDACXX_BEGIN_NAMESPACE_RANGES

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

template <class>
_CCCL_INLINE_VAR constexpr bool disable_sized_range = false;
Expand Down Expand Up @@ -182,15 +182,8 @@ struct __fn
noexcept(noexcept(_CUDA_VRANGES::size(__t)))
{
using _Signed = make_signed_t<decltype(_CUDA_VRANGES::size(__t))>;
if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed))
{
return static_cast<ptrdiff_t>(_CUDA_VRANGES::size(__t));
}
else
{
return static_cast<_Signed>(_CUDA_VRANGES::size(__t));
}
_CCCL_UNREACHABLE();
using _Result = conditional_t<(sizeof(ptrdiff_t) > sizeof(_Signed)), ptrdiff_t, _Signed>;
return static_cast<_Result>(_CUDA_VRANGES::size(__t));
}
};
_LIBCUDACXX_END_NAMESPACE_CPO
Expand All @@ -200,7 +193,7 @@ inline namespace __cpo
_CCCL_GLOBAL_CONSTANT auto ssize = __ssize::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
6 changes: 3 additions & 3 deletions libcudacxx/include/cuda/std/__ranges/views.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
# pragma system_header
#endif // no system header

#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#if _CCCL_STD_VER >= 2014

_LIBCUDACXX_BEGIN_NAMESPACE_VIEWS

_LIBCUDACXX_END_NAMESPACE_VIEWS

_LIBCUDACXX_BEGIN_NAMESPACE_STD

namespace views = ranges::views;
namespace views = ranges::views; // NOLINT: misc-unused-alias-decls

_LIBCUDACXX_END_NAMESPACE_STD

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC2017)
#endif // _CCCL_STD_VER >= 2014

#endif // _LIBCUDACXX___RANGES_VIEWS
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <cuda/std/__type_traits/void_t.h>
#include <cuda/std/__utility/declval.h>

_CCCL_NV_DIAG_SUPPRESS(1384) // warning: pointer converted to bool

_LIBCUDACXX_BEGIN_NAMESPACE_STD

// common_reference
Expand Down Expand Up @@ -253,4 +255,6 @@ struct common_reference

_LIBCUDACXX_END_NAMESPACE_STD

_CCCL_NV_DIAG_DEFAULT(1384)

#endif // _LIBCUDACXX___TYPE_TRAITS_COMMON_REFERENCE_H
Loading
Loading