Skip to content

Commit 30aa182

Browse files
committed
Remove unused thrust alignment utilities
1 parent e1329ca commit 30aa182

File tree

5 files changed

+20
-112
lines changed

5 files changed

+20
-112
lines changed

thrust/testing/allocator_aware_policies.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <thrust/system/omp/detail/execution_policy.h>
44
#include <thrust/system/tbb/detail/execution_policy.h>
55

6-
#include <cuda/__cccl_config>
6+
#include <cuda/std/cstddef>
77

88
#include <unittest/unittest.h>
99

@@ -63,7 +63,7 @@ struct TestAllocatorAttachment
6363
(::cuda::std::is_same<T,
6464
typename PolicyInfo::template apply_base_second<
6565
thrust::detail::execute_with_allocator,
66-
thrust::mr::allocator<thrust::detail::max_align_t, ExpectedResource>>::type>::value),
66+
thrust::mr::allocator<cuda::std::max_align_t, ExpectedResource>>::type>::value),
6767
true);
6868
}
6969

thrust/testing/catch2_test_alignment.cu

Lines changed: 13 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -92,81 +92,24 @@ TEST_CASE("alignof", "[alignment]")
9292
STATIC_REQUIRE(alignof(alignof_mock_6) == sizeof(int));
9393
}
9494

95-
TEST_CASE("alignment_of", "[alignment]")
96-
{
97-
STATIC_REQUIRE(thrust::detail::alignment_of<bool>::value == sizeof(bool));
98-
STATIC_REQUIRE(thrust::detail::alignment_of<signed char>::value == sizeof(signed char));
99-
STATIC_REQUIRE(thrust::detail::alignment_of<unsigned char>::value == sizeof(unsigned char));
100-
STATIC_REQUIRE(thrust::detail::alignment_of<char>::value == sizeof(char));
101-
STATIC_REQUIRE(thrust::detail::alignment_of<short int>::value == sizeof(short int));
102-
STATIC_REQUIRE(thrust::detail::alignment_of<unsigned short int>::value == sizeof(unsigned short int));
103-
STATIC_REQUIRE(thrust::detail::alignment_of<int>::value == sizeof(int));
104-
STATIC_REQUIRE(thrust::detail::alignment_of<unsigned int>::value == sizeof(unsigned int));
105-
STATIC_REQUIRE(thrust::detail::alignment_of<long int>::value == sizeof(long int));
106-
STATIC_REQUIRE(thrust::detail::alignment_of<unsigned long int>::value == sizeof(unsigned long int));
107-
STATIC_REQUIRE(thrust::detail::alignment_of<long long int>::value == sizeof(long long int));
108-
STATIC_REQUIRE(thrust::detail::alignment_of<unsigned long long int>::value == sizeof(unsigned long long int));
109-
STATIC_REQUIRE(thrust::detail::alignment_of<float>::value == sizeof(float));
110-
STATIC_REQUIRE(thrust::detail::alignment_of<double>::value == sizeof(double));
111-
STATIC_REQUIRE(thrust::detail::alignment_of<long double>::value == sizeof(long double));
112-
113-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_0>::value == sizeof(char));
114-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_1>::value == sizeof(int));
115-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_2>::value == sizeof(int));
116-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_3>::value == sizeof(int));
117-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_4>::value == sizeof(int));
118-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_5>::value == sizeof(int));
119-
STATIC_REQUIRE(thrust::detail::alignment_of<alignof_mock_6>::value == sizeof(int));
120-
}
121-
122-
template <std::size_t Align>
123-
void test_aligned_type_instantiation()
124-
{
125-
using type = typename thrust::detail::aligned_type<Align>::type;
126-
STATIC_REQUIRE(sizeof(type) >= 1lu);
127-
STATIC_REQUIRE(alignof(type) == Align);
128-
STATIC_REQUIRE(thrust::detail::alignment_of<type>::value == Align);
129-
}
130-
131-
TEST_CASE("aligned_type", "[alignment]")
95+
TEST_CASE("aligned_reinterpret_cast", "[alignment]")
13296
{
133-
test_aligned_type_instantiation<1>();
134-
test_aligned_type_instantiation<2>();
135-
test_aligned_type_instantiation<4>();
136-
test_aligned_type_instantiation<8>();
137-
test_aligned_type_instantiation<16>();
138-
test_aligned_type_instantiation<32>();
139-
test_aligned_type_instantiation<64>();
140-
test_aligned_type_instantiation<128>();
141-
}
97+
struct alignas(128) T1
98+
{
99+
char data_[128];
100+
};
142101

143-
TEST_CASE("max_align_t", "[alignment]")
144-
{
145-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(bool));
146-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(signed char));
147-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(unsigned char));
148-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(char));
149-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(short int));
150-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(unsigned short int));
151-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(int));
152-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(unsigned int));
153-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(long int));
154-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(unsigned long int));
155-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(long long int));
156-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(unsigned long long int));
157-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(float));
158-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(double));
159-
STATIC_REQUIRE(alignof(thrust::detail::max_align_t) >= alignof(long double));
160-
}
102+
struct alignas(512) T2
103+
{
104+
char data_[512];
105+
};
161106

162-
TEST_CASE("aligned_reinterpret_cast", "[alignment]")
163-
{
164-
thrust::detail::aligned_type<1>* a1 = 0;
165-
thrust::detail::aligned_type<2>* a2 = 0;
107+
T1* a1 = 0;
108+
T2* a2 = 0;
166109

167110
// Cast to type with stricter (larger) alignment requirement.
168-
a2 = thrust::detail::aligned_reinterpret_cast<thrust::detail::aligned_type<2>*>(a1);
111+
a2 = thrust::detail::aligned_reinterpret_cast<T2*>(a1);
169112

170113
// Cast to type with less strict (smaller) alignment requirement.
171-
a1 = thrust::detail::aligned_reinterpret_cast<thrust::detail::aligned_type<1>*>(a2);
114+
a1 = thrust::detail::aligned_reinterpret_cast<T1*>(a2);
172115
}

thrust/thrust/detail/alignment.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,9 @@
1616
# pragma system_header
1717
#endif // no system header
1818

19-
#include <cuda/__cmath/ceil_div.h>
20-
#include <cuda/std/__type_traits/alignment_of.h>
21-
#include <cuda/std/cstddef> // For `std::size_t` and `std::max_align_t`.
22-
2319
THRUST_NAMESPACE_BEGIN
2420
namespace detail
2521
{
26-
/// \p alignment_of provides the member constant `value` which is equal to the
27-
/// alignment requirement of the type `T`, as if obtained by a C++11 `alignof`
28-
/// expression.
29-
///
30-
/// It is an implementation of C++11's \p std::alignment_of.
31-
template <typename T>
32-
using alignment_of = ::cuda::std::alignment_of<T>;
33-
34-
/// \p aligned_type provides the nested type `type`, which is a trivial
35-
/// type whose alignment requirement is a divisor of `Align`.
36-
///
37-
/// The behavior is undefined if `Align` is not a power of 2.
38-
template <::cuda::std::size_t Align>
39-
struct aligned_type
40-
{
41-
struct alignas(Align) type
42-
{};
43-
};
44-
45-
/// \p max_align_t is a trivial type whose alignment requirement is at least as
46-
/// strict (as large) as that of every scalar type.
47-
///
48-
/// It is an implementation of C++11's \p std::max_align_t.
49-
using max_align_t = ::cuda::std::max_align_t;
50-
5122
/// \p aligned_reinterpret_cast `reinterpret_cast`s \p u of type \p U to `void*`
5223
/// and then `reinterpret_cast`s the result to \p T. The indirection through
5324
/// `void*` suppresses compiler warnings when the alignment requirement of \p *u
@@ -59,10 +30,5 @@ _CCCL_HOST_DEVICE T aligned_reinterpret_cast(U u)
5930
{
6031
return reinterpret_cast<T>(reinterpret_cast<void*>(u));
6132
}
62-
63-
_CCCL_HOST_DEVICE inline ::cuda::std::size_t aligned_storage_size(::cuda::std::size_t n, ::cuda::std::size_t align)
64-
{
65-
return ::cuda::ceil_div(n, align) * align;
66-
}
6733
} // end namespace detail
6834
THRUST_NAMESPACE_END

thrust/thrust/detail/allocator_aware_execution_policy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <thrust/detail/alignment.h>
1616
#include <thrust/detail/execute_with_allocator_fwd.h>
1717

18+
#include <cuda/std/__cstddef/types.h>
1819
#include <cuda/std/__type_traits/enable_if.h>
1920
#include <cuda/std/__type_traits/is_reference.h>
2021
#include <cuda/std/__utility/move.h>
@@ -35,9 +36,8 @@ struct allocator_aware_execution_policy
3536
template <typename MemoryResource>
3637
struct execute_with_memory_resource_type
3738
{
38-
using type =
39-
thrust::detail::execute_with_allocator<thrust::mr::allocator<thrust::detail::max_align_t, MemoryResource>,
40-
ExecutionPolicyCRTPBase>;
39+
using type = thrust::detail::execute_with_allocator<thrust::mr::allocator<::cuda::std::max_align_t, MemoryResource>,
40+
ExecutionPolicyCRTPBase>;
4141
};
4242

4343
template <typename Allocator>

thrust/thrust/detail/config/memory_resource.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@
1313
# pragma system_header
1414
#endif // no system header
1515

16-
#include <thrust/detail/alignment.h>
17-
16+
#include <cuda/std/__cstddef/types.h>
1817
#include <cuda/std/cstddef>
1918

20-
#define THRUST_MR_DEFAULT_ALIGNMENT alignof(THRUST_NS_QUALIFIER::detail::max_align_t)
19+
#define THRUST_MR_DEFAULT_ALIGNMENT alignof(::cuda::std::max_align_t)
2120

2221
#if __has_include(<memory_resource>)
2322
# define THRUST_MR_STD_MR_HEADER <memory_resource>

0 commit comments

Comments
 (0)