Extrema: Only use `get_iterator_value` for non-numeric types.
Bug
Bug
git-commit
git-author Francisco Facioni
VDVS:
Jobs:
[git-p4: depot-paths = "//sw/gpgpu/thrust/": change = 24262205]
MODIFY
thrust/system/detail/generic/extrema.inl
thrust/system/detail/generic/extrema.inl
@@ -168,12 +168,22 @@ ForwardIterator min_element(thrust::execution_policy<DerivedPolicy> &exec,
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
+ thrust::tuple<InputType, IndexType> initial;
+ if (std::numeric_limits<InputType>::is_specialized)
+ {
+ initial = thrust::tuple<InputType, IndexType>(std::numeric_limits<InputType>::max(), -1);
+ }
+ else
+ {
+ initial = thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0);
+ }
+
thrust::tuple<InputType, IndexType> result =
thrust::reduce
(exec,
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
- thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0),
+ initial,
detail::min_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
return first + thrust::get<1>(result);
@@ -205,12 +215,22 @@ ForwardIterator max_element(thrust::execution_policy<DerivedPolicy> &exec,
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
+ thrust::tuple<InputType, IndexType> initial;
+ if (std::numeric_limits<InputType>::is_specialized)
+ {
+ initial = thrust::tuple<InputType, IndexType>(std::numeric_limits<InputType>::lowest(), -1);
+ }
+ else
+ {
+ initial = thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0);
+ }
+
thrust::tuple<InputType, IndexType> result =
thrust::reduce
(exec,
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
- thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec),first), 0),
+ initial,
detail::max_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
return first + thrust::get<1>(result);
@@ -241,6 +261,17 @@ thrust::pair<ForwardIterator,ForwardIterator> minmax_element(thrust::execution_p
typedef typename thrust::iterator_traits<ForwardIterator>::value_type InputType;
typedef typename thrust::iterator_traits<ForwardIterator>::difference_type IndexType;
+ typedef thrust::tuple<InputType, IndexType> AccumulatorType;
+
+ thrust::tuple<AccumulatorType, AccumulatorType> initial;
+ if (std::numeric_limits<InputType>::is_specialized)
+ {
+ initial = thrust::make_tuple(AccumulatorType(std::numeric_limits<InputType>::max(), -1), AccumulatorType(std::numeric_limits<InputType>::lowest(), -1));
+ }
+ else
+ {
+ initial = detail::duplicate_tuple<InputType, IndexType>()(thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec), first), 0));
+ }
thrust::tuple< thrust::tuple<InputType,IndexType>, thrust::tuple<InputType,IndexType> > result =
thrust::transform_reduce
@@ -248,8 +279,7 @@ thrust::pair<ForwardIterator,ForwardIterator> minmax_element(thrust::execution_p
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))),
thrust::make_zip_iterator(thrust::make_tuple(first, thrust::counting_iterator<IndexType>(0))) + (last - first),
detail::duplicate_tuple<InputType, IndexType>(),
- detail::duplicate_tuple<InputType, IndexType>()(
- thrust::tuple<InputType, IndexType>(thrust::detail::get_iterator_value(derived_cast(exec),first), 0)),
+ initial,
detail::minmax_element_reduction<InputType, IndexType, BinaryPredicate>(comp));
return thrust::make_pair(first + thrust::get<1>(thrust::get<0>(result)), first + thrust::get<1>(thrust::get<1>(result)));

Extrema: Only use `get_iterator_value` for non-numeric types.
Bug 2157884
Bug 1865408
git-commit 01a347ec2287f47b80c3b04e44f507463c2e8c8b
git-author Francisco Facioni <fran6co@gmail.com>
VDVS: http://ausdvs.nvidia.com/Build_Results?virtualId=1000169423&which_page=current_build

Jobs: 1865408-2006 2157884-2006
[git-p4: depot-paths = "//sw/gpgpu/thrust/": change = 24262205]