Merge topic 'scanbykey'

65910f13 put return value back to ScanInclusivePortal
da1c8993 Merge branch 'scanbykey' of gitlab.kitware.com:ollielo/vtk-m into scanbykey
16b61d86 Make ScanInclusiveByKey and ScanInclusiveByKey void functions.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !829
This commit is contained in:
Li-Ta Lo 2017-07-11 14:58:30 +00:00 committed by Kitware Robot
commit 36d585825a

@ -513,14 +513,13 @@ private:
}
template <typename KeysPortal, typename ValuesPortal, typename OutputPortal>
VTKM_CONT static typename ValuesPortal::ValueType ScanInclusiveByKeyPortal(
const KeysPortal& keys,
VTKM_CONT static void ScanInclusiveByKeyPortal(const KeysPortal& keys,
const ValuesPortal& values,
const OutputPortal& output)
{
using KeyType = typename KeysPortal::ValueType;
typedef typename OutputPortal::ValueType ValueType;
return ScanInclusiveByKeyPortal(
ScanInclusiveByKeyPortal(
keys, values, output, ::thrust::equal_to<KeyType>(), ::thrust::plus<ValueType>());
}
@ -529,8 +528,7 @@ private:
typename OutputPortal,
typename BinaryPredicate,
typename AssociativeOperator>
VTKM_CONT static typename ValuesPortal::ValueType ScanInclusiveByKeyPortal(
const KeysPortal& keys,
VTKM_CONT static void ScanInclusiveByKeyPortal(const KeysPortal& keys,
const ValuesPortal& values,
const OutputPortal& output,
BinaryPredicate binary_predicate,
@ -546,22 +544,18 @@ private:
typedef typename detail::IteratorTraits<OutputPortal>::IteratorType IteratorType;
try
{
IteratorType end = ::thrust::inclusive_scan_by_key(thrust::cuda::par,
::thrust::inclusive_scan_by_key(thrust::cuda::par,
IteratorBegin(keys),
IteratorEnd(keys),
IteratorBegin(values),
IteratorBegin(output),
bpred,
bop);
return *(end - 1);
}
catch (...)
{
throwAsVTKmException();
return typename ValuesPortal::ValueType();
}
//return the value at the last index in the array, as that is the sum
}
template <typename KeysPortal, typename ValuesPortal, typename OutputPortal>
@ -602,7 +596,7 @@ private:
typedef typename detail::IteratorTraits<OutputPortal>::IteratorType IteratorType;
try
{
IteratorType end = ::thrust::exclusive_scan_by_key(thrust::cuda::par,
::thrust::exclusive_scan_by_key(thrust::cuda::par,
IteratorBegin(keys),
IteratorEnd(keys),
IteratorBegin(values),
@ -610,15 +604,11 @@ private:
initValue,
bpred,
bop);
return;
}
catch (...)
{
throwAsVTKmException();
return;
}
//return the value at the last index in the array, as that is the sum
}
template <class ValuesPortal>
@ -1031,7 +1021,7 @@ public:
}
template <typename T, typename U, typename KIn, typename VIn, typename VOut>
VTKM_CONT static T ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
const vtkm::cont::ArrayHandle<U, VIn>& values,
vtkm::cont::ArrayHandle<U, VOut>& output)
{
@ -1039,7 +1029,6 @@ public:
if (numberOfValues <= 0)
{
output.PrepareForOutput(0, DeviceAdapterTag());
return vtkm::TypeTraits<T>::ZeroInitialization();
}
//We need call PrepareForInput on the input argument before invoking a
@ -1048,7 +1037,7 @@ public:
//use case breaks.
keys.PrepareForInput(DeviceAdapterTag());
values.PrepareForInput(DeviceAdapterTag());
return ScanInclusiveByKeyPortal(keys.PrepareForInput(DeviceAdapterTag()),
ScanInclusiveByKeyPortal(keys.PrepareForInput(DeviceAdapterTag()),
values.PrepareForInput(DeviceAdapterTag()),
output.PrepareForOutput(numberOfValues, DeviceAdapterTag()));
}
@ -1059,7 +1048,7 @@ public:
typename VIn,
typename VOut,
typename BinaryFunctor>
VTKM_CONT static T ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
VTKM_CONT static void ScanInclusiveByKey(const vtkm::cont::ArrayHandle<T, KIn>& keys,
const vtkm::cont::ArrayHandle<U, VIn>& values,
vtkm::cont::ArrayHandle<U, VOut>& output,
BinaryFunctor binary_functor)
@ -1068,7 +1057,6 @@ public:
if (numberOfValues <= 0)
{
output.PrepareForOutput(0, DeviceAdapterTag());
return vtkm::TypeTraits<T>::ZeroInitialization();
}
//We need call PrepareForInput on the input argument before invoking a
@ -1077,7 +1065,7 @@ public:
//use case breaks.
keys.PrepareForInput(DeviceAdapterTag());
values.PrepareForInput(DeviceAdapterTag());
return ScanInclusiveByKeyPortal(keys.PrepareForInput(DeviceAdapterTag()),
ScanInclusiveByKeyPortal(keys.PrepareForInput(DeviceAdapterTag()),
values.PrepareForInput(DeviceAdapterTag()),
output.PrepareForOutput(numberOfValues, DeviceAdapterTag()),
::thrust::equal_to<T>(),