Skip to content

Commit 97c19f6

Browse files
griwesbrycelelbach
authored andcommitted
Revert "Extrema: Only use get_iterator_value for non-numeric types."
This reverts commit 2588854. Bug 2492864
1 parent f99185d commit 97c19f6

1 file changed

Lines changed: 5 additions & 35 deletions

File tree

thrust/system/detail/generic/extrema.inl

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -167,23 +167,13 @@ ForwardIterator min_element(thrust::execution_policy<DerivedPolicy> &exec,
167167

168168
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
169169
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
170-
171-
thrust::tuple<InputType, IndexType> initial;
172-
if (std::numeric_limits<InputType>::is_specialized)
173-
{
174-
initial = thrust::tuple<InputType, IndexType>(std::numeric_limits<InputType>::max(), -1);
175-
}
176-
else
177-
{
178-
initial = thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0);
179-
}
180-
170+
181171
thrust::tuple<InputType, IndexType> result =
182172
thrust::reduce
183173
(exec,
184174
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
185175
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
186-
initial,
176+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0),
187177
detail::min_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
188178

189179
return first + thrust::get<1>(result);
@@ -214,23 +204,13 @@ ForwardIterator max_element(thrust::execution_policy<DerivedPolicy> &exec,
214204

215205
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
216206
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
217-
218-
thrust::tuple<InputType, IndexType> initial;
219-
if (std::numeric_limits<InputType>::is_specialized)
220-
{
221-
initial = thrust::tuple<InputType, IndexType>(std::numeric_limits<InputType>::lowest(), -1);
222-
}
223-
else
224-
{
225-
initial = thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0);
226-
}
227207

228208
thrust::tuple<InputType, IndexType> result =
229209
thrust::reduce
230210
(exec,
231211
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
232212
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
233-
initial,
213+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec),first), 0),
234214
detail::max_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
235215

236216
return first + thrust::get<1>(result);
@@ -261,25 +241,15 @@ thrust::pair<ForwardIterator,ForwardIterator> minmax_element(thrust::execution_p
261241

262242
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
263243
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
264-
typedef thrust::tuple<InputType, IndexType> AccumulatorType;
265-
266-
thrust::tuple<AccumulatorType, AccumulatorType> initial;
267-
if (std::numeric_limits<InputType>::is_specialized)
268-
{
269-
initial = thrust::make_tuple(AccumulatorType(std::numeric_limits<InputType>::max(), -1), AccumulatorType(std::numeric_limits<InputType>::lowest(), -1));
270-
}
271-
else
272-
{
273-
initial = detail::duplicate_tuple<InputType, IndexType>()(thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0));
274-
}
275244

276245
thrust::tuple< thrust::tuple<InputType,IndexType>, thrust::tuple<InputType,IndexType> > result =
277246
thrust::transform_reduce
278247
(exec,
279248
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
280249
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
281250
detail::duplicate_tuple<InputType, IndexType>(),
282-
initial,
251+
detail::duplicate_tuple<InputType, IndexType>()(
252+
thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec),first), 0)),
283253
detail::minmax_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
284254

285255
return thrust::make_pair(first + thrust::get<1>(thrust::get<0>(result)), first + thrust::get<1>(thrust::get<1>(result)));

0 commit comments

Comments
 (0)