Skip to content

Commit 9255c20

Browse files
bernhardmgrubergevtushenko
authored andcommitted
Avoid ::result_type for partial sums in TBB reduce_by_key (NVIDIA#1998)
This allows us to get rid of partial_sum_type, which still uses the C++11-deprecated function object API ::result_type. Co-authored-by: Georgii Evtushenko <[email protected]>
1 parent 17fa3bb commit 9255c20

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

thrust/thrust/system/tbb/detail/reduce_by_key.inl

+6-13
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,12 @@ inline L divide_ri(const L x, const R y)
6363
template <typename InputIterator, typename BinaryFunction, typename SFINAE = void>
6464
struct partial_sum_type
6565
{
66-
using type = typename thrust::iterator_value<InputIterator>::type;
67-
};
68-
69-
template <typename InputIterator, typename BinaryFunction>
70-
struct partial_sum_type<InputIterator, BinaryFunction, ::cuda::std::void_t<typename BinaryFunction::result_type>>
71-
{
72-
using type = typename BinaryFunction::result_type;
66+
using type = thrust::iterator_value_t<InputIterator>;
7367
};
7468

7569
template <typename InputIterator1, typename InputIterator2, typename BinaryPredicate, typename BinaryFunction>
7670
thrust::pair<InputIterator1,
77-
thrust::pair<typename thrust::iterator_value<InputIterator1>::type,
71+
thrust::pair<thrust::iterator_value_t<InputIterator1>,
7872
typename partial_sum_type<InputIterator2, BinaryFunction>::type>>
7973
reduce_last_segment_backward(
8074
InputIterator1 keys_first,
@@ -90,7 +84,7 @@ reduce_last_segment_backward(
9084
thrust::reverse_iterator<InputIterator1> keys_last_r(keys_first);
9185
thrust::reverse_iterator<InputIterator2> values_first_r(values_first + n);
9286

93-
typename thrust::iterator_value<InputIterator1>::type result_key = *keys_first_r;
87+
thrust::iterator_value_t<InputIterator1> result_key = *keys_first_r;
9488
typename partial_sum_type<InputIterator2, BinaryFunction>::type result_value = *values_first_r;
9589

9690
// consume the entirety of the first key's sequence
@@ -111,7 +105,7 @@ template <typename InputIterator1,
111105
typename BinaryFunction>
112106
thrust::tuple<OutputIterator1,
113107
OutputIterator2,
114-
typename thrust::iterator_value<InputIterator1>::type,
108+
thrust::iterator_value_t<InputIterator1>,
115109
typename partial_sum_type<InputIterator2, BinaryFunction>::type>
116110
reduce_by_key_with_carry(
117111
InputIterator1 keys_first,
@@ -124,8 +118,7 @@ reduce_by_key_with_carry(
124118
{
125119
// first, consume the last sequence to produce the carry
126120
// XXX is there an elegant way to pose this such that we don't need to default construct carry?
127-
thrust::pair<typename thrust::iterator_value<InputIterator1>::type,
128-
typename partial_sum_type<InputIterator2, BinaryFunction>::type>
121+
thrust::pair<thrust::iterator_value_t<InputIterator1>, typename partial_sum_type<InputIterator2, BinaryFunction>::type>
129122
carry;
130123

131124
thrust::tie(keys_last, carry) =
@@ -215,7 +208,7 @@ struct serial_reduce_by_key_body
215208
Iterator6 my_carry_result = carry_result + interval_idx;
216209

217210
// consume the rest of the interval with reduce_by_key
218-
using key_type = typename thrust::iterator_value<Iterator1>::type;
211+
using key_type = thrust::iterator_value_t<Iterator1>;
219212
using value_type = typename partial_sum_type<Iterator2, BinaryFunction>::type;
220213

221214
// XXX is there a way to pose this so that we don't require default construction of carry?

0 commit comments

Comments
 (0)