Commit 3f60ebbd authored by Robert Maynard's avatar Robert Maynard
Browse files

Merge branch 'improve_tbb_sort_and_reduce_performance' into 'master'

Correct tbb to properly sort all arrrays in parallel.

See merge request !42
parents 9ef7fa9b 6279b8ed
......@@ -500,33 +500,9 @@ public:
VTKM_CONT_EXPORT static void Sort(
vtkm::cont::ArrayHandle<T,Container> &values)
{
typedef typename vtkm::cont::ArrayHandle<T,Container>::template
ExecutionTypes<vtkm::cont::DeviceAdapterTagTBB>::Portal PortalType;
PortalType arrayPortal = values.PrepareForInPlace(
vtkm::cont::DeviceAdapterTagTBB());
typedef vtkm::cont::ArrayPortalToIterators<PortalType> IteratorsType;
IteratorsType iterators(arrayPortal);
::tbb::parallel_sort(iterators.GetBegin(), iterators.GetEnd());
}
template<typename T, typename U>
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandleZip<T,U>& values)
{
typedef typename vtkm::cont::ArrayHandleZip<T,U>::template
ExecutionTypes<vtkm::cont::DeviceAdapterTagTBB>::Portal PortalType;
PortalType arrayPortal = values.PrepareForInPlace(
vtkm::cont::DeviceAdapterTagTBB());
typedef vtkm::cont::ArrayPortalToIterators<PortalType> IteratorsType;
IteratorsType iterators(arrayPortal);
//this is required to get sort to work with zip handles
typedef vtkm::cont::internal::ArrayHandleZipTraits< T, U > ZipTraits;
typedef std::less< typename ZipTraits::ValueType > LessOp;
internal::WrappedBinaryOperator<bool, LessOp> wrappedCompare( (LessOp()) );
std::sort(iterators.GetBegin(), iterators.GetEnd());
std::less< T > lessOp;
Sort(values, lessOp );
}
template<typename T, class Container, class Compare>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment