Skip to content

Commit 138f219

Browse files
committed
Drop more uses of thrust::pointer_traits
1 parent b8dd0af commit 138f219

20 files changed

+39
-63
lines changed

thrust/thrust/detail/allocator/allocator_system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
#endif // no system header
1919

2020
#include <thrust/detail/type_traits.h>
21-
#include <thrust/detail/type_traits/pointer_traits.h>
2221
#include <thrust/iterator/iterator_traits.h>
2322

2423
#include <cuda/std/__iterator/iterator_traits.h>
2524
#include <cuda/std/__memory/allocator_traits.h>
25+
#include <cuda/std/__memory/pointer_traits.h>
2626
#include <cuda/std/__type_traits/add_lvalue_reference.h>
2727
#include <cuda/std/__type_traits/conditional.h>
2828
#include <cuda/std/__type_traits/integral_constant.h>

thrust/thrust/detail/allocator/copy_construct_range.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <thrust/detail/allocator/allocator_system.h>
1717
#include <thrust/detail/copy.h>
1818
#include <thrust/detail/execution_policy.h>
19-
#include <thrust/detail/type_traits/pointer_traits.h>
2019
#include <thrust/for_each.h>
2120
#include <thrust/iterator/iterator_traits.h>
2221
#include <thrust/iterator/zip_iterator.h>
@@ -25,6 +24,7 @@
2524
#include <cuda/std/__iterator/advance.h>
2625
#include <cuda/std/__iterator/distance.h>
2726
#include <cuda/std/__memory/allocator_traits.h>
27+
#include <cuda/std/__memory/pointer_traits.h>
2828
#include <cuda/std/__type_traits/is_convertible.h>
2929
#include <cuda/std/__type_traits/is_trivially_copy_constructible.h>
3030
#include <cuda/std/tuple>
@@ -151,7 +151,8 @@ template <typename System, typename Allocator, typename InputIterator, typename
151151
_CCCL_HOST_DEVICE Pointer copy_construct_range(
152152
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result)
153153
{
154-
if constexpr (needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
154+
if constexpr (needs_copy_construct_via_allocator<Allocator,
155+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
155156
{
156157
return uninitialized_copy_with_allocator(a, from_system, allocator_system<Allocator>::get(a), first, last, result);
157158
}
@@ -166,7 +167,8 @@ template <typename System, typename Allocator, typename InputIterator, typename
166167
_CCCL_HOST_DEVICE Pointer copy_construct_range_n(
167168
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, Size n, Pointer result)
168169
{
169-
if constexpr (needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
170+
if constexpr (needs_copy_construct_via_allocator<Allocator,
171+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
170172
{
171173
return uninitialized_copy_with_allocator_n(a, from_system, allocator_system<Allocator>::get(a), first, n, result);
172174
}

thrust/thrust/detail/allocator/destroy_range.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
#include <thrust/detail/allocator/allocator_system.h>
1717
#include <thrust/detail/allocator/destroy_range.h>
18-
#include <thrust/detail/type_traits/pointer_traits.h>
1918
#include <thrust/for_each.h>
2019

2120
#include <cuda/std/__host_stdlib/memory>
2221
#include <cuda/std/__memory/allocator_traits.h>
22+
#include <cuda/std/__memory/pointer_traits.h>
2323

2424
THRUST_NAMESPACE_BEGIN
2525
namespace detail
@@ -65,7 +65,7 @@ template <typename Allocator, typename Pointer, typename Size>
6565
_CCCL_HOST_DEVICE void
6666
destroy_range([[maybe_unused]] Allocator& a, [[maybe_unused]] Pointer p, [[maybe_unused]] Size n) noexcept
6767
{
68-
using pe_t = typename pointer_element<Pointer>::type;
68+
using pe_t = typename ::cuda::std::pointer_traits<Pointer>::element_type;
6969

7070
// case 1: destroy via allocator
7171
if constexpr (has_effectful_member_destroy<Allocator, pe_t>)

thrust/thrust/detail/allocator/fill_construct_range.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
#include <thrust/detail/allocator/allocator_system.h>
1717
#include <thrust/detail/type_traits.h>
18-
#include <thrust/detail/type_traits/pointer_traits.h>
1918
#include <thrust/for_each.h>
2019
#include <thrust/uninitialized_fill.h>
2120

2221
#include <cuda/std/__host_stdlib/memory>
2322
#include <cuda/std/__memory/allocator_traits.h>
23+
#include <cuda/std/__memory/pointer_traits.h>
2424

2525
THRUST_NAMESPACE_BEGIN
2626
namespace detail
@@ -53,7 +53,7 @@ struct construct2_via_allocator
5353
template <typename Allocator, typename Pointer, typename Size, typename T>
5454
_CCCL_HOST_DEVICE void fill_construct_range(Allocator& a, Pointer p, Size n, const T& value)
5555
{
56-
if constexpr (has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>)
56+
if constexpr (has_effectful_member_construct2<Allocator, typename ::cuda::std::pointer_traits<Pointer>::element_type, T>)
5757
{
5858
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct2_via_allocator<Allocator, T>{a, value});
5959
}

thrust/thrust/detail/allocator/malloc_allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
#include <thrust/detail/allocator/tagged_allocator.h>
1818
#include <thrust/detail/malloc_and_free.h>
1919
#include <thrust/detail/raw_pointer_cast.h>
20-
#include <thrust/detail/type_traits/pointer_traits.h>
2120
#include <thrust/system/detail/bad_alloc.h>
2221
#include <thrust/system/detail/generic/select_system.h>
2322

23+
#include <cuda/std/__memory/pointer_traits.h>
24+
2425
THRUST_NAMESPACE_BEGIN
2526
namespace detail
2627
{

thrust/thrust/detail/allocator/tagged_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#endif // no system header
1515

1616
#include <thrust/detail/allocator/tagged_allocator.h>
17-
#include <thrust/detail/type_traits/pointer_traits.h>
1817
#include <thrust/iterator/iterator_traits.h>
1918

2019
#include <cuda/std/__memory/pointer_traits.h>

thrust/thrust/detail/allocator/value_initialize_range.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515

1616
#include <thrust/detail/allocator/allocator_system.h>
1717
#include <thrust/detail/type_traits.h>
18-
#include <thrust/detail/type_traits/pointer_traits.h>
1918
#include <thrust/for_each.h>
2019
#include <thrust/uninitialized_fill.h>
2120

2221
#include <cuda/std/__memory/allocator_traits.h>
22+
#include <cuda/std/__memory/pointer_traits.h>
2323

2424
THRUST_NAMESPACE_BEGIN
2525
namespace detail
@@ -52,13 +52,15 @@ inline constexpr bool needs_default_construct_via_allocator<std::allocator<U>, T
5252
template <typename Allocator, typename Pointer, typename Size>
5353
_CCCL_HOST_DEVICE void value_initialize_range(Allocator& a, Pointer p, Size n)
5454
{
55-
if constexpr (needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
55+
if constexpr (needs_default_construct_via_allocator<Allocator,
56+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
5657
{
5758
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct1_via_allocator<Allocator>{a});
5859
}
5960
else
6061
{
61-
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, typename pointer_element<Pointer>::type());
62+
thrust::uninitialized_fill_n(
63+
allocator_system<Allocator>::get(a), p, n, typename ::cuda::std::pointer_traits<Pointer>::element_type());
6264
}
6365
}
6466
} // namespace detail

thrust/thrust/detail/execute_with_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include <thrust/detail/execute_with_allocator_fwd.h>
1717
#include <thrust/detail/raw_pointer_cast.h>
18-
#include <thrust/detail/type_traits/pointer_traits.h>
1918

2019
#include <cuda/__cmath/ceil_div.h>
2120
#include <cuda/std/__memory/allocator_traits.h>

thrust/thrust/detail/get_iterator_value.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# pragma system_header
1414
#endif // no system header
1515

16-
#include <thrust/detail/type_traits/pointer_traits.h>
1716
#include <thrust/execution_policy.h>
1817
#include <thrust/iterator/iterator_traits.h>
1918
#include <thrust/system/detail/generic/memory.h> // for get_value()

thrust/thrust/detail/raw_pointer_cast.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
# pragma system_header
1414
#endif // no system header
1515

16-
#include <thrust/detail/type_traits/pointer_traits.h>
17-
1816
#include <cuda/std/__memory/pointer_traits.h>
1917

2018
THRUST_NAMESPACE_BEGIN
@@ -28,15 +26,15 @@ _CCCL_HOST_DEVICE auto raw_pointer_cast(Pointer ptr)
2826
template <typename ToPointer, typename FromPointer>
2927
_CCCL_HOST_DEVICE ToPointer reinterpret_pointer_cast(FromPointer ptr)
3028
{
31-
using to_element = typename thrust::detail::pointer_element<ToPointer>::type;
32-
return ToPointer(reinterpret_cast<to_element*>(thrust::raw_pointer_cast(ptr)));
29+
using to_element = typename ::cuda::std::pointer_traits<ToPointer>::element_type;
30+
return ToPointer(reinterpret_cast<to_element*>(::cuda::std::to_address(ptr)));
3331
}
3432

3533
template <typename ToPointer, typename FromPointer>
3634
_CCCL_HOST_DEVICE ToPointer static_pointer_cast(FromPointer ptr)
3735
{
38-
using to_element = typename thrust::detail::pointer_element<ToPointer>::type;
39-
return ToPointer(static_cast<to_element*>(thrust::raw_pointer_cast(ptr)));
36+
using to_element = typename ::cuda::std::pointer_traits<ToPointer>::element_type;
37+
return ToPointer(static_cast<to_element*>(::cuda::std::to_address(ptr)));
4038
}
4139

4240
THRUST_NAMESPACE_END

0 commit comments

Comments
 (0)