Skip to content

Commit 3fbd348

Browse files
committed
Drop more uses of thrust::pointer_traits
1 parent 178352b commit 3fbd348

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
@@ -31,11 +31,11 @@
3131
#endif // no system header
3232

3333
#include <thrust/detail/type_traits.h>
34-
#include <thrust/detail/type_traits/pointer_traits.h>
3534
#include <thrust/iterator/iterator_traits.h>
3635

3736
#include <cuda/std/__iterator/iterator_traits.h>
3837
#include <cuda/std/__memory/allocator_traits.h>
38+
#include <cuda/std/__memory/pointer_traits.h>
3939
#include <cuda/std/__type_traits/add_lvalue_reference.h>
4040
#include <cuda/std/__type_traits/conditional.h>
4141
#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
@@ -29,7 +29,6 @@
2929
#include <thrust/detail/allocator/allocator_system.h>
3030
#include <thrust/detail/copy.h>
3131
#include <thrust/detail/execution_policy.h>
32-
#include <thrust/detail/type_traits/pointer_traits.h>
3332
#include <thrust/for_each.h>
3433
#include <thrust/iterator/iterator_traits.h>
3534
#include <thrust/iterator/zip_iterator.h>
@@ -38,6 +37,7 @@
3837
#include <cuda/std/__iterator/advance.h>
3938
#include <cuda/std/__iterator/distance.h>
4039
#include <cuda/std/__memory/allocator_traits.h>
40+
#include <cuda/std/__memory/pointer_traits.h>
4141
#include <cuda/std/__type_traits/is_convertible.h>
4242
#include <cuda/std/__type_traits/is_trivially_copy_constructible.h>
4343
#include <cuda/std/tuple>
@@ -164,7 +164,8 @@ template <typename System, typename Allocator, typename InputIterator, typename
164164
_CCCL_HOST_DEVICE Pointer copy_construct_range(
165165
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, InputIterator last, Pointer result)
166166
{
167-
if constexpr (needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
167+
if constexpr (needs_copy_construct_via_allocator<Allocator,
168+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
168169
{
169170
return uninitialized_copy_with_allocator(a, from_system, allocator_system<Allocator>::get(a), first, last, result);
170171
}
@@ -179,7 +180,8 @@ template <typename System, typename Allocator, typename InputIterator, typename
179180
_CCCL_HOST_DEVICE Pointer copy_construct_range_n(
180181
thrust::execution_policy<System>& from_system, Allocator& a, InputIterator first, Size n, Pointer result)
181182
{
182-
if constexpr (needs_copy_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
183+
if constexpr (needs_copy_construct_via_allocator<Allocator,
184+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
183185
{
184186
return uninitialized_copy_with_allocator_n(a, from_system, allocator_system<Allocator>::get(a), first, n, result);
185187
}

thrust/thrust/detail/allocator/destroy_range.h

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

2929
#include <thrust/detail/allocator/allocator_system.h>
3030
#include <thrust/detail/allocator/destroy_range.h>
31-
#include <thrust/detail/type_traits/pointer_traits.h>
3231
#include <thrust/for_each.h>
3332

3433
#include <cuda/std/__host_stdlib/memory>
3534
#include <cuda/std/__memory/allocator_traits.h>
35+
#include <cuda/std/__memory/pointer_traits.h>
3636

3737
THRUST_NAMESPACE_BEGIN
3838
namespace detail
@@ -78,7 +78,7 @@ template <typename Allocator, typename Pointer, typename Size>
7878
_CCCL_HOST_DEVICE void
7979
destroy_range([[maybe_unused]] Allocator& a, [[maybe_unused]] Pointer p, [[maybe_unused]] Size n) noexcept
8080
{
81-
using pe_t = typename pointer_element<Pointer>::type;
81+
using pe_t = typename ::cuda::std::pointer_traits<Pointer>::element_type;
8282

8383
// case 1: destroy via allocator
8484
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
@@ -28,12 +28,12 @@
2828

2929
#include <thrust/detail/allocator/allocator_system.h>
3030
#include <thrust/detail/type_traits.h>
31-
#include <thrust/detail/type_traits/pointer_traits.h>
3231
#include <thrust/for_each.h>
3332
#include <thrust/uninitialized_fill.h>
3433

3534
#include <cuda/std/__host_stdlib/memory>
3635
#include <cuda/std/__memory/allocator_traits.h>
36+
#include <cuda/std/__memory/pointer_traits.h>
3737

3838
THRUST_NAMESPACE_BEGIN
3939
namespace detail
@@ -66,7 +66,7 @@ struct construct2_via_allocator
6666
template <typename Allocator, typename Pointer, typename Size, typename T>
6767
_CCCL_HOST_DEVICE void fill_construct_range(Allocator& a, Pointer p, Size n, const T& value)
6868
{
69-
if constexpr (has_effectful_member_construct2<Allocator, typename pointer_element<Pointer>::type, T>)
69+
if constexpr (has_effectful_member_construct2<Allocator, typename ::cuda::std::pointer_traits<Pointer>::element_type, T>)
7070
{
7171
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct2_via_allocator<Allocator, T>{a, value});
7272
}

thrust/thrust/detail/allocator/malloc_allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
#include <thrust/detail/allocator/tagged_allocator.h>
3131
#include <thrust/detail/malloc_and_free.h>
3232
#include <thrust/detail/raw_pointer_cast.h>
33-
#include <thrust/detail/type_traits/pointer_traits.h>
3433
#include <thrust/system/detail/bad_alloc.h>
3534
#include <thrust/system/detail/generic/select_system.h>
3635

36+
#include <cuda/std/__memory/pointer_traits.h>
37+
3738
THRUST_NAMESPACE_BEGIN
3839
namespace detail
3940
{

thrust/thrust/detail/allocator/tagged_allocator.h

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

2929
#include <thrust/detail/allocator/tagged_allocator.h>
30-
#include <thrust/detail/type_traits/pointer_traits.h>
3130
#include <thrust/iterator/iterator_traits.h>
3231

3332
#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
@@ -28,11 +28,11 @@
2828

2929
#include <thrust/detail/allocator/allocator_system.h>
3030
#include <thrust/detail/type_traits.h>
31-
#include <thrust/detail/type_traits/pointer_traits.h>
3231
#include <thrust/for_each.h>
3332
#include <thrust/uninitialized_fill.h>
3433

3534
#include <cuda/std/__memory/allocator_traits.h>
35+
#include <cuda/std/__memory/pointer_traits.h>
3636

3737
THRUST_NAMESPACE_BEGIN
3838
namespace detail
@@ -65,13 +65,15 @@ inline constexpr bool needs_default_construct_via_allocator<std::allocator<U>, T
6565
template <typename Allocator, typename Pointer, typename Size>
6666
_CCCL_HOST_DEVICE void value_initialize_range(Allocator& a, Pointer p, Size n)
6767
{
68-
if constexpr (needs_default_construct_via_allocator<Allocator, typename pointer_element<Pointer>::type>)
68+
if constexpr (needs_default_construct_via_allocator<Allocator,
69+
typename ::cuda::std::pointer_traits<Pointer>::element_type>)
6970
{
7071
thrust::for_each_n(allocator_system<Allocator>::get(a), p, n, construct1_via_allocator<Allocator>{a});
7172
}
7273
else
7374
{
74-
thrust::uninitialized_fill_n(allocator_system<Allocator>::get(a), p, n, typename pointer_element<Pointer>::type());
75+
thrust::uninitialized_fill_n(
76+
allocator_system<Allocator>::get(a), p, n, typename ::cuda::std::pointer_traits<Pointer>::element_type());
7577
}
7678
}
7779
} // namespace detail

thrust/thrust/detail/execute_with_allocator.h

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

2929
#include <thrust/detail/execute_with_allocator_fwd.h>
3030
#include <thrust/detail/raw_pointer_cast.h>
31-
#include <thrust/detail/type_traits/pointer_traits.h>
3231

3332
#include <cuda/__cmath/ceil_div.h>
3433
#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
@@ -25,7 +25,6 @@
2525
# pragma system_header
2626
#endif // no system header
2727

28-
#include <thrust/detail/type_traits/pointer_traits.h>
2928
#include <thrust/execution_policy.h>
3029
#include <thrust/iterator/iterator_traits.h>
3130
#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
@@ -26,8 +26,6 @@
2626
# pragma system_header
2727
#endif // no system header
2828

29-
#include <thrust/detail/type_traits/pointer_traits.h>
30-
3129
#include <cuda/std/__memory/pointer_traits.h>
3230

3331
THRUST_NAMESPACE_BEGIN
@@ -41,15 +39,15 @@ _CCCL_HOST_DEVICE auto raw_pointer_cast(Pointer ptr)
4139
template <typename ToPointer, typename FromPointer>
4240
_CCCL_HOST_DEVICE ToPointer reinterpret_pointer_cast(FromPointer ptr)
4341
{
44-
using to_element = typename thrust::detail::pointer_element<ToPointer>::type;
45-
return ToPointer(reinterpret_cast<to_element*>(thrust::raw_pointer_cast(ptr)));
42+
using to_element = typename ::cuda::std::pointer_traits<ToPointer>::element_type;
43+
return ToPointer(reinterpret_cast<to_element*>(::cuda::std::to_address(ptr)));
4644
}
4745

4846
template <typename ToPointer, typename FromPointer>
4947
_CCCL_HOST_DEVICE ToPointer static_pointer_cast(FromPointer ptr)
5048
{
51-
using to_element = typename thrust::detail::pointer_element<ToPointer>::type;
52-
return ToPointer(static_cast<to_element*>(thrust::raw_pointer_cast(ptr)));
49+
using to_element = typename ::cuda::std::pointer_traits<ToPointer>::element_type;
50+
return ToPointer(static_cast<to_element*>(::cuda::std::to_address(ptr)));
5351
}
5452

5553
THRUST_NAMESPACE_END

0 commit comments

Comments
 (0)