Skip to content

Commit 7a66920

Browse files
committed
use cuda::std::in_range
1 parent 2b9c42d commit 7a66920

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

libcudacxx/include/cuda/__mdspan/layout_stride_relaxed.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <cuda/__fwd/mdspan.h>
2626
#include <cuda/__numeric/add_overflow.h>
2727
#include <cuda/__numeric/mul_overflow.h>
28-
#include <cuda/__numeric/overflow_cast.h>
2928
#include <cuda/std/__concepts/concept_macros.h>
3029
#include <cuda/std/__cstddef/types.h>
3130
#include <cuda/std/__mdspan/concepts.h>
@@ -132,7 +131,7 @@ class _CCCL_DECLSPEC_EMPTY_BASES layout_stride_relaxed::mapping
132131
{
133132
for (rank_type __d = 0; __d < __rank_; ++__d)
134133
{
135-
_CCCL_ASSERT(!::cuda::overflow_cast<offset_type>(__other.stride(__d)),
134+
_CCCL_ASSERT(::cuda::std::in_range<offset_type>(__other.stride(__d)),
136135
"layout_stride_relaxed::mapping: stride is out of range");
137136
__init_strides[__d] = static_cast<offset_type>(__other.stride(__d));
138137
}
@@ -274,15 +273,15 @@ class _CCCL_DECLSPEC_EMPTY_BASES layout_stride_relaxed::mapping
274273
return index_type{0};
275274
}
276275
const auto __stride_val = strides().stride(__r);
277-
_CCCL_ASSERT(!::cuda::overflow_cast<index_type>(::cuda::uabs(__stride_val)),
276+
_CCCL_ASSERT(::cuda::std::in_range<index_type>(::cuda::uabs(__stride_val)),
278277
"layout_stride_relaxed::mapping: stride is out of range");
279278
if (__stride_val < 0)
280279
{
281-
_CCCL_ASSERT(!::cuda::overflow_cast<offset_type>(__ext - 1),
280+
_CCCL_ASSERT(::cuda::std::in_range<offset_type>(__ext - 1),
282281
"layout_stride_relaxed::mapping: extent - 1 is not representable as offset_type");
283282
const auto __min_extent = static_cast<offset_type>(__ext - 1);
284283
const auto __abs_stride_u = ::cuda::uabs(__stride_val);
285-
_CCCL_ASSERT(!::cuda::overflow_cast<offset_type>(__abs_stride_u),
284+
_CCCL_ASSERT(::cuda::std::in_range<offset_type>(__abs_stride_u),
286285
"layout_stride_relaxed::mapping: absolute stride is not representable as offset_type");
287286
const auto __abs_stride = static_cast<offset_type>(__abs_stride_u);
288287
_CCCL_ASSERT(!::cuda::mul_overflow(__min_extent, __abs_stride)
@@ -310,7 +309,7 @@ class _CCCL_DECLSPEC_EMPTY_BASES layout_stride_relaxed::mapping
310309
{
311310
if constexpr (::cuda::std::__cccl_is_integer_v<_Index>)
312311
{
313-
return ::cuda::std::cmp_greater_equal(__index, index_type{0}) && !::cuda::overflow_cast<index_type>(__index);
312+
return ::cuda::std::cmp_greater_equal(__index, index_type{0}) && ::cuda::std::in_range<index_type>(__index);
314313
}
315314
else
316315
{

libcudacxx/include/cuda/__mdspan/strides.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#endif // no system header
2323

2424
#include <cuda/__fwd/mdspan.h>
25-
#include <cuda/__numeric/overflow_cast.h>
2625
#include <cuda/std/__concepts/concept_macros.h>
2726
#include <cuda/std/__cstddef/types.h>
2827
#include <cuda/std/__mdspan/extents.h>
@@ -67,7 +66,7 @@ class strides
6766
[[nodiscard]] _CCCL_API static constexpr bool __is_representable_as(_From... __values) noexcept
6867
{
6968
return (
70-
(!::cuda::overflow_cast<offset_type>(__values) || static_cast<::cuda::std::ptrdiff_t>(__values) == dynamic_stride)
69+
(::cuda::std::in_range<offset_type>(__values) || static_cast<::cuda::std::ptrdiff_t>(__values) == dynamic_stride)
7170
&& ...);
7271
}
7372

0 commit comments

Comments
 (0)