Skip to content

Commit 7215eb3

Browse files
committed
Address review comments
1 parent acd563c commit 7215eb3

21 files changed

+384
-432
lines changed

thrust/testing/constant_iterator.cu

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,20 @@ DECLARE_UNITTEST(TestConstantIteratorTraits);
3838

3939
void TestConstantIteratorConstructFromConvertibleSystem()
4040
{
41-
using namespace thrust;
41+
thrust::constant_iterator<int> default_system(13);
4242

43-
constant_iterator<int> default_system(13);
44-
45-
constant_iterator<int, use_default, host_system_tag> host_system = default_system;
43+
thrust::constant_iterator<int, thrust::use_default, thrust::host_system_tag> host_system = default_system;
4644
ASSERT_EQUAL(*default_system, *host_system);
4745

48-
constant_iterator<int, use_default, device_system_tag> device_system = default_system;
46+
thrust::constant_iterator<int, thrust::use_default, thrust::device_system_tag> device_system = default_system;
4947
ASSERT_EQUAL(*default_system, *device_system);
5048
}
5149
DECLARE_UNITTEST(TestConstantIteratorConstructFromConvertibleSystem);
5250

5351
void TestConstantIteratorIncrement()
5452
{
55-
using namespace thrust;
56-
57-
constant_iterator<int> lhs(0, 0);
58-
constant_iterator<int> rhs(0, 0);
53+
thrust::constant_iterator<int> lhs(0, 0);
54+
thrust::constant_iterator<int> rhs(0, 0);
5955

6056
ASSERT_EQUAL(0, lhs - rhs);
6157

@@ -87,16 +83,14 @@ void TestConstantIteratorIncrementBig()
8783
thrust::constant_iterator<long long int> begin(1);
8884
thrust::constant_iterator<long long int> end = begin + n;
8985

90-
ASSERT_EQUAL(::cuda::std::distance(begin, end), n);
86+
ASSERT_EQUAL(cuda::std::distance(begin, end), n);
9187
}
9288
DECLARE_UNITTEST(TestConstantIteratorIncrementBig);
9389

9490
void TestConstantIteratorComparison()
9591
{
96-
using namespace thrust;
97-
98-
constant_iterator<int> iter1(0);
99-
constant_iterator<int> iter2(0);
92+
thrust::constant_iterator<int> iter1(0);
93+
thrust::constant_iterator<int> iter2(0);
10094

10195
ASSERT_EQUAL(0, iter1 - iter2);
10296
ASSERT_EQUAL(true, iter1 == iter2);
@@ -121,37 +115,34 @@ DECLARE_UNITTEST(TestConstantIteratorComparison);
121115

122116
void TestMakeConstantIterator()
123117
{
124-
using namespace thrust;
125-
126118
// test one argument version
127-
constant_iterator<int> iter0 = make_constant_iterator<int>(13);
119+
thrust::constant_iterator<int> iter0 = thrust::make_constant_iterator<int>(13);
128120

129121
ASSERT_EQUAL(13, *iter0);
130122

131123
// test two argument version
132-
constant_iterator<int, ::cuda::std::intmax_t> iter1 = make_constant_iterator<int, ::cuda::std::intmax_t>(13, 7);
124+
thrust::constant_iterator<int, cuda::std::intmax_t> iter1 =
125+
thrust::make_constant_iterator<int, cuda::std::intmax_t>(13, 7);
133126

134127
ASSERT_EQUAL(13, *iter1);
135128
ASSERT_EQUAL(7, iter1 - iter0);
136129

137130
// ensure CTAD words
138-
constant_iterator deduced_iter{42};
139-
static_assert(::cuda::std::is_same_v<decltype(deduced_iter), constant_iterator<int>>);
131+
thrust::constant_iterator deduced_iter{42};
132+
static_assert(cuda::std::is_same_v<decltype(deduced_iter), thrust::constant_iterator<int>>);
140133
ASSERT_EQUAL(42, *deduced_iter);
141134
}
142135
DECLARE_UNITTEST(TestMakeConstantIterator);
143136

144137
template <typename Vector>
145138
void TestConstantIteratorCopy()
146139
{
147-
using namespace thrust;
148-
149140
using ValueType = typename Vector::value_type;
150-
using ConstIter = constant_iterator<ValueType>;
141+
using ConstIter = thrust::constant_iterator<ValueType>;
151142

152143
Vector result(4);
153144

154-
ConstIter first = make_constant_iterator<ValueType>(7);
145+
ConstIter first = thrust::make_constant_iterator<ValueType>(7);
155146
ConstIter last = first + result.size();
156147
thrust::copy(first, last, result.begin());
157148

@@ -163,23 +154,21 @@ DECLARE_VECTOR_UNITTEST(TestConstantIteratorCopy);
163154
template <typename Vector>
164155
void TestConstantIteratorTransform()
165156
{
166-
using namespace thrust;
167-
168157
using T = typename Vector::value_type;
169-
using ConstIter = constant_iterator<T>;
158+
using ConstIter = thrust::constant_iterator<T>;
170159

171160
Vector result(4);
172161

173-
ConstIter first1 = make_constant_iterator<T>(7);
162+
ConstIter first1 = thrust::make_constant_iterator<T>(7);
174163
ConstIter last1 = first1 + result.size();
175-
ConstIter first2 = make_constant_iterator<T>(3);
164+
ConstIter first2 = thrust::make_constant_iterator<T>(3);
176165

177-
thrust::transform(first1, last1, result.begin(), ::cuda::std::negate<T>());
166+
thrust::transform(first1, last1, result.begin(), cuda::std::negate<T>());
178167

179168
Vector ref(4, -7);
180169
ASSERT_EQUAL(ref, result);
181170

182-
thrust::transform(first1, last1, first2, result.begin(), ::cuda::std::plus<T>());
171+
thrust::transform(first1, last1, first2, result.begin(), cuda::std::plus<T>());
183172

184173
ref = Vector(4, 10);
185174
ASSERT_EQUAL(ref, result);
@@ -188,12 +177,10 @@ DECLARE_VECTOR_UNITTEST(TestConstantIteratorTransform);
188177

189178
void TestConstantIteratorReduce()
190179
{
191-
using namespace thrust;
192-
193180
using T = int;
194-
using ConstIter = constant_iterator<T>;
181+
using ConstIter = thrust::constant_iterator<T>;
195182

196-
ConstIter first = make_constant_iterator<T>(7);
183+
ConstIter first = thrust::make_constant_iterator<T>(7);
197184
ConstIter last = first + 4;
198185

199186
T sum = thrust::reduce(first, last);

thrust/testing/discard_iterator.cu

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <thrust/iterator/discard_iterator.h>
22

3+
#include <cuda/std/tuple>
34
#include <cuda/std/type_traits>
45

56
#include <unittest/unittest.h>
@@ -102,10 +103,8 @@ DECLARE_UNITTEST(TestMakeDiscardIterator);
102103

103104
void TestZippedDiscardIterator()
104105
{
105-
using namespace thrust;
106-
107-
using IteratorTuple1 = tuple<discard_iterator<>>;
108-
using ZipIterator1 = zip_iterator<IteratorTuple1>;
106+
using IteratorTuple1 = cuda::std::tuple<thrust::discard_iterator<>>;
107+
using ZipIterator1 = thrust::zip_iterator<IteratorTuple1>;
109108

110109
IteratorTuple1 t = cuda::std::tuple(thrust::make_discard_iterator());
111110

@@ -118,8 +117,8 @@ void TestZippedDiscardIterator()
118117

119118
ASSERT_EQUAL(10, cuda::std::get<0>(z_iter1_first.get_iterator_tuple()) - thrust::make_discard_iterator());
120119

121-
using IteratorTuple2 = tuple<int*, discard_iterator<>>;
122-
using ZipIterator2 = zip_iterator<IteratorTuple2>;
120+
using IteratorTuple2 = cuda::std::tuple<int*, thrust::discard_iterator<>>;
121+
using ZipIterator2 = thrust::zip_iterator<IteratorTuple2>;
123122

124123
ZipIterator2 z_iter_first = thrust::make_zip_iterator((int*) 0, thrust::make_discard_iterator());
125124
ZipIterator2 z_iter_last = z_iter_first + 10;

thrust/testing/pair_transform.cu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <thrust/host_vector.h>
22
#include <thrust/transform.h>
33

4-
#include <cuda/std/tuple>
54
#include <cuda/std/utility>
65

76
#include <unittest/unittest.h>

thrust/testing/tuple.cu

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -193,82 +193,82 @@ struct TestTupleGet
193193
host_vector<T> data = random_integers<T>(10);
194194

195195
tuple<T> t1(data[0]);
196-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t1));
196+
ASSERT_EQUAL(data[0], thrust::get<0>(t1));
197197

198198
tuple<T, T> t2(data[0], data[1]);
199-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t2));
200-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t2));
199+
ASSERT_EQUAL(data[0], thrust::get<0>(t2));
200+
ASSERT_EQUAL(data[1], thrust::get<1>(t2));
201201

202202
tuple<T, T, T> t3 = make_tuple(data[0], data[1], data[2]);
203-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t3));
204-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t3));
205-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t3));
203+
ASSERT_EQUAL(data[0], thrust::get<0>(t3));
204+
ASSERT_EQUAL(data[1], thrust::get<1>(t3));
205+
ASSERT_EQUAL(data[2], thrust::get<2>(t3));
206206

207207
tuple<T, T, T, T> t4 = make_tuple(data[0], data[1], data[2], data[3]);
208-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t4));
209-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t4));
210-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t4));
211-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t4));
208+
ASSERT_EQUAL(data[0], thrust::get<0>(t4));
209+
ASSERT_EQUAL(data[1], thrust::get<1>(t4));
210+
ASSERT_EQUAL(data[2], thrust::get<2>(t4));
211+
ASSERT_EQUAL(data[3], thrust::get<3>(t4));
212212

213213
tuple<T, T, T, T, T> t5 = make_tuple(data[0], data[1], data[2], data[3], data[4]);
214-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t5));
215-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t5));
216-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t5));
217-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t5));
218-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t5));
214+
ASSERT_EQUAL(data[0], thrust::get<0>(t5));
215+
ASSERT_EQUAL(data[1], thrust::get<1>(t5));
216+
ASSERT_EQUAL(data[2], thrust::get<2>(t5));
217+
ASSERT_EQUAL(data[3], thrust::get<3>(t5));
218+
ASSERT_EQUAL(data[4], thrust::get<4>(t5));
219219

220220
tuple<T, T, T, T, T, T> t6 = make_tuple(data[0], data[1], data[2], data[3], data[4], data[5]);
221-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t6));
222-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t6));
223-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t6));
224-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t6));
225-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t6));
226-
ASSERT_EQUAL(data[5], cuda::std::get<5>(t6));
221+
ASSERT_EQUAL(data[0], thrust::get<0>(t6));
222+
ASSERT_EQUAL(data[1], thrust::get<1>(t6));
223+
ASSERT_EQUAL(data[2], thrust::get<2>(t6));
224+
ASSERT_EQUAL(data[3], thrust::get<3>(t6));
225+
ASSERT_EQUAL(data[4], thrust::get<4>(t6));
226+
ASSERT_EQUAL(data[5], thrust::get<5>(t6));
227227

228228
tuple<T, T, T, T, T, T, T> t7 = make_tuple(data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
229-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t7));
230-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t7));
231-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t7));
232-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t7));
233-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t7));
234-
ASSERT_EQUAL(data[5], cuda::std::get<5>(t7));
235-
ASSERT_EQUAL(data[6], cuda::std::get<6>(t7));
229+
ASSERT_EQUAL(data[0], thrust::get<0>(t7));
230+
ASSERT_EQUAL(data[1], thrust::get<1>(t7));
231+
ASSERT_EQUAL(data[2], thrust::get<2>(t7));
232+
ASSERT_EQUAL(data[3], thrust::get<3>(t7));
233+
ASSERT_EQUAL(data[4], thrust::get<4>(t7));
234+
ASSERT_EQUAL(data[5], thrust::get<5>(t7));
235+
ASSERT_EQUAL(data[6], thrust::get<6>(t7));
236236

237237
tuple<T, T, T, T, T, T, T, T> t8 =
238238
make_tuple(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
239-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t8));
240-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t8));
241-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t8));
242-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t8));
243-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t8));
244-
ASSERT_EQUAL(data[5], cuda::std::get<5>(t8));
245-
ASSERT_EQUAL(data[6], cuda::std::get<6>(t8));
246-
ASSERT_EQUAL(data[7], cuda::std::get<7>(t8));
239+
ASSERT_EQUAL(data[0], thrust::get<0>(t8));
240+
ASSERT_EQUAL(data[1], thrust::get<1>(t8));
241+
ASSERT_EQUAL(data[2], thrust::get<2>(t8));
242+
ASSERT_EQUAL(data[3], thrust::get<3>(t8));
243+
ASSERT_EQUAL(data[4], thrust::get<4>(t8));
244+
ASSERT_EQUAL(data[5], thrust::get<5>(t8));
245+
ASSERT_EQUAL(data[6], thrust::get<6>(t8));
246+
ASSERT_EQUAL(data[7], thrust::get<7>(t8));
247247

248248
tuple<T, T, T, T, T, T, T, T, T> t9 =
249249
make_tuple(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8]);
250-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t9));
251-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t9));
252-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t9));
253-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t9));
254-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t9));
255-
ASSERT_EQUAL(data[5], cuda::std::get<5>(t9));
256-
ASSERT_EQUAL(data[6], cuda::std::get<6>(t9));
257-
ASSERT_EQUAL(data[7], cuda::std::get<7>(t9));
258-
ASSERT_EQUAL(data[8], cuda::std::get<8>(t9));
250+
ASSERT_EQUAL(data[0], thrust::get<0>(t9));
251+
ASSERT_EQUAL(data[1], thrust::get<1>(t9));
252+
ASSERT_EQUAL(data[2], thrust::get<2>(t9));
253+
ASSERT_EQUAL(data[3], thrust::get<3>(t9));
254+
ASSERT_EQUAL(data[4], thrust::get<4>(t9));
255+
ASSERT_EQUAL(data[5], thrust::get<5>(t9));
256+
ASSERT_EQUAL(data[6], thrust::get<6>(t9));
257+
ASSERT_EQUAL(data[7], thrust::get<7>(t9));
258+
ASSERT_EQUAL(data[8], thrust::get<8>(t9));
259259

260260
tuple<T, T, T, T, T, T, T, T, T, T> t10 =
261261
make_tuple(data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9]);
262-
ASSERT_EQUAL(data[0], cuda::std::get<0>(t10));
263-
ASSERT_EQUAL(data[1], cuda::std::get<1>(t10));
264-
ASSERT_EQUAL(data[2], cuda::std::get<2>(t10));
265-
ASSERT_EQUAL(data[3], cuda::std::get<3>(t10));
266-
ASSERT_EQUAL(data[4], cuda::std::get<4>(t10));
267-
ASSERT_EQUAL(data[5], cuda::std::get<5>(t10));
268-
ASSERT_EQUAL(data[6], cuda::std::get<6>(t10));
269-
ASSERT_EQUAL(data[7], cuda::std::get<7>(t10));
270-
ASSERT_EQUAL(data[8], cuda::std::get<8>(t10));
271-
ASSERT_EQUAL(data[9], cuda::std::get<9>(t10));
262+
ASSERT_EQUAL(data[0], thrust::get<0>(t10));
263+
ASSERT_EQUAL(data[1], thrust::get<1>(t10));
264+
ASSERT_EQUAL(data[2], thrust::get<2>(t10));
265+
ASSERT_EQUAL(data[3], thrust::get<3>(t10));
266+
ASSERT_EQUAL(data[4], thrust::get<4>(t10));
267+
ASSERT_EQUAL(data[5], thrust::get<5>(t10));
268+
ASSERT_EQUAL(data[6], thrust::get<6>(t10));
269+
ASSERT_EQUAL(data[7], thrust::get<7>(t10));
270+
ASSERT_EQUAL(data[8], thrust::get<8>(t10));
271+
ASSERT_EQUAL(data[9], thrust::get<9>(t10));
272272
}
273273
};
274274
SimpleUnitTest<TestTupleGet, BuiltinNumericTypes> TestTupleGetInstance;
@@ -474,12 +474,12 @@ void TestTupleSwap()
474474
using ::cuda::std::swap;
475475
swap(t1, t2);
476476

477-
ASSERT_EQUAL(x, cuda::std::get<0>(t1));
478-
ASSERT_EQUAL(y, cuda::std::get<1>(t1));
479-
ASSERT_EQUAL(z, cuda::std::get<2>(t1));
480-
ASSERT_EQUAL(a, cuda::std::get<0>(t2));
481-
ASSERT_EQUAL(b, cuda::std::get<1>(t2));
482-
ASSERT_EQUAL(c, cuda::std::get<2>(t2));
477+
ASSERT_EQUAL(x, thrust::get<0>(t1));
478+
ASSERT_EQUAL(y, thrust::get<1>(t1));
479+
ASSERT_EQUAL(z, thrust::get<2>(t1));
480+
ASSERT_EQUAL(a, thrust::get<0>(t2));
481+
ASSERT_EQUAL(b, thrust::get<1>(t2));
482+
ASSERT_EQUAL(c, thrust::get<2>(t2));
483483

484484
using swappable_tuple = thrust::tuple<user_swappable, user_swappable, user_swappable, user_swappable>;
485485

thrust/testing/tuple_reduce.cu

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,23 @@ struct TestTupleReduce
3232
{
3333
void operator()(const size_t n)
3434
{
35-
using namespace thrust;
36-
37-
host_vector<T> h_t1 = random_integers<T>(n);
38-
host_vector<T> h_t2 = random_integers<T>(n);
35+
thrust::host_vector<T> h_t1 = random_integers<T>(n);
36+
thrust::host_vector<T> h_t2 = random_integers<T>(n);
3937

4038
// zip up the data
41-
host_vector<tuple<T, T>> h_tuples(n);
39+
thrust::host_vector<cuda::std::tuple<T, T>> h_tuples(n);
4240
thrust::transform(h_t1.begin(), h_t1.end(), h_t2.begin(), h_tuples.begin(), MakeTupleFunctor());
4341

4442
// copy to device
45-
device_vector<tuple<T, T>> d_tuples = h_tuples;
43+
thrust::device_vector<cuda::std::tuple<T, T>> d_tuples = h_tuples;
4644

47-
tuple<T, T> zero(0, 0);
45+
cuda::std::tuple<T, T> zero(0, 0);
4846

4947
// sum on host
50-
tuple<T, T> h_result = thrust::reduce(h_tuples.begin(), h_tuples.end(), zero, SumTupleFunctor());
48+
cuda::std::tuple<T, T> h_result = thrust::reduce(h_tuples.begin(), h_tuples.end(), zero, SumTupleFunctor());
5149

5250
// sum on device
53-
tuple<T, T> d_result = thrust::reduce(d_tuples.begin(), d_tuples.end(), zero, SumTupleFunctor());
51+
cuda::std::tuple<T, T> d_result = thrust::reduce(d_tuples.begin(), d_tuples.end(), zero, SumTupleFunctor());
5452

5553
ASSERT_EQUAL_QUIET(h_result, d_result);
5654
}

0 commit comments

Comments
 (0)