Commit 7ee30848 authored by Robert Maynard's avatar Robert Maynard
Browse files

Update the name of the binary functor for Sort.

parent 604289c1
......@@ -434,11 +434,11 @@ private:
SortPortal(values, ::thrust::less<ValueType>());
}
template<class ValuesPortal, class Compare>
template<class ValuesPortal, class BinaryCompare>
VTKM_CONT_EXPORT static void SortPortal(const ValuesPortal &values,
Compare comp)
BinaryCompare binary_compare)
{
vtkm::exec::cuda::internal::WrappedBinaryOperator<bool,Compare> bop(comp);
vtkm::exec::cuda::internal::WrappedBinaryOperator<bool,BinaryCompare> bop(binary_compare);
::thrust::sort(thrust::cuda::par,
IteratorBegin(values),
IteratorEnd(values),
......@@ -454,17 +454,17 @@ private:
SortByKeyPortal(keys,values,::thrust::less<ValueType>());
}
template<class KeysPortal, class ValuesPortal, class Compare>
template<class KeysPortal, class ValuesPortal, class BinaryCompare>
VTKM_CONT_EXPORT static void SortByKeyPortal(const KeysPortal &keys,
const ValuesPortal &values,
Compare comp)
BinaryCompare binary_compare)
{
vtkm::exec::cuda::internal::WrappedBinaryOperator<bool,Compare> bop(comp);
vtkm::exec::cuda::internal::WrappedBinaryOperator<bool,BinaryCompare> bop(binary_compare);
::thrust::sort_by_key(thrust::cuda::par,
IteratorBegin(keys),
IteratorEnd(keys),
IteratorBegin(values),
comp);
bop);
}
template<class ValueIterator,
......@@ -884,12 +884,12 @@ public:
SortPortal(values.PrepareForInPlace(DeviceAdapterTag()));
}
template<typename T, class Storage, class Compare>
template<typename T, class Storage, class BinaryCompare>
VTKM_CONT_EXPORT static void Sort(
vtkm::cont::ArrayHandle<T,Storage>& values,
Compare comp)
BinaryCompare binary_compare)
{
SortPortal(values.PrepareForInPlace(DeviceAdapterTag()),comp);
SortPortal(values.PrepareForInPlace(DeviceAdapterTag()),binary_compare);
}
template<typename T, typename U,
......@@ -904,15 +904,15 @@ public:
template<typename T, typename U,
class StorageT, class StorageU,
class Compare>
class BinaryCompare>
VTKM_CONT_EXPORT static void SortByKey(
vtkm::cont::ArrayHandle<T,StorageT>& keys,
vtkm::cont::ArrayHandle<U,StorageU>& values,
Compare comp)
BinaryCompare binary_compare)
{
SortByKeyPortal(keys.PrepareForInPlace(DeviceAdapterTag()),
values.PrepareForInPlace(DeviceAdapterTag()),
comp);
binary_compare);
}
......
......@@ -853,16 +853,16 @@ public:
//--------------------------------------------------------------------------
// Sort
private:
template<typename PortalType, typename CompareType>
template<typename PortalType, typename BinaryCompare>
struct BitonicSortMergeKernel : vtkm::exec::FunctorBase
{
PortalType Portal;
CompareType Compare;
BinaryCompare Compare;
vtkm::Id GroupSize;
VTKM_CONT_EXPORT
BitonicSortMergeKernel(const PortalType &portal,
const CompareType &compare,
const BinaryCompare &compare,
vtkm::Id groupSize)
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
......@@ -891,16 +891,16 @@ private:
}
};
template<typename PortalType, typename CompareType>
template<typename PortalType, typename BinaryCompare>
struct BitonicSortCrossoverKernel : vtkm::exec::FunctorBase
{
PortalType Portal;
CompareType Compare;
BinaryCompare Compare;
vtkm::Id GroupSize;
VTKM_CONT_EXPORT
BitonicSortCrossoverKernel(const PortalType &portal,
const CompareType &compare,
const BinaryCompare &compare,
vtkm::Id groupSize)
: Portal(portal), Compare(compare), GroupSize(groupSize) { }
......@@ -941,10 +941,10 @@ private:
};
public:
template<typename T, class Storage, class CompareType>
template<typename T, class Storage, class BinaryCompare>
VTKM_CONT_EXPORT static void Sort(
vtkm::cont::ArrayHandle<T,Storage> &values,
CompareType compare)
BinaryCompare binary_compare)
{
typedef typename vtkm::cont::ArrayHandle<T,Storage> ArrayType;
typedef typename ArrayType::template ExecutionTypes<DeviceAdapterTag>
......@@ -959,18 +959,18 @@ public:
while (numThreads < numValues) { numThreads *= 2; }
numThreads /= 2;
typedef BitonicSortMergeKernel<PortalType,CompareType> MergeKernel;
typedef BitonicSortCrossoverKernel<PortalType,CompareType> CrossoverKernel;
typedef BitonicSortMergeKernel<PortalType,BinaryCompare> MergeKernel;
typedef BitonicSortCrossoverKernel<PortalType,BinaryCompare> CrossoverKernel;
for (vtkm::Id crossoverSize = 1;
crossoverSize < numValues;
crossoverSize *= 2)
{
DerivedAlgorithm::Schedule(CrossoverKernel(portal,compare,crossoverSize),
DerivedAlgorithm::Schedule(CrossoverKernel(portal,binary_compare,crossoverSize),
numThreads);
for (vtkm::Id mergeSize = crossoverSize/2; mergeSize > 0; mergeSize /= 2)
{
DerivedAlgorithm::Schedule(MergeKernel(portal,compare,mergeSize),
DerivedAlgorithm::Schedule(MergeKernel(portal,binary_compare,mergeSize),
numThreads);
}
}
......@@ -986,11 +986,11 @@ public:
//--------------------------------------------------------------------------
// Sort by Key
protected:
template<typename T, typename U, class Compare=DefaultCompareFunctor>
template<typename T, typename U, class BinaryCompare=DefaultCompareFunctor>
struct KeyCompare
{
KeyCompare(): CompareFunctor() {}
explicit KeyCompare(Compare c): CompareFunctor(c) {}
explicit KeyCompare(BinaryCompare c): CompareFunctor(c) {}
VTKM_EXEC_EXPORT
bool operator()(const vtkm::Pair<T,U>& a, const vtkm::Pair<T,U>& b) const
......@@ -998,7 +998,7 @@ protected:
return CompareFunctor(a.first,b.first);
}
private:
Compare CompareFunctor;
BinaryCompare CompareFunctor;
};
public:
......@@ -1020,11 +1020,11 @@ public:
DerivedAlgorithm::Sort(zipHandle,KeyCompare<T,U>());
}
template<typename T, typename U, class StorageT, class StorageU, class Compare>
template<typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
VTKM_CONT_EXPORT static void SortByKey(
vtkm::cont::ArrayHandle<T,StorageT> &keys,
vtkm::cont::ArrayHandle<U,StorageU> &values,
Compare comp)
BinaryCompare binary_compare)
{
//combine the keys and values into a ZipArrayHandle
//we than need to specify a custom compare function wrapper
......@@ -1036,7 +1036,7 @@ public:
ZipHandleType zipHandle =
vtkm::cont::make_ArrayHandleZip(keys,values);
DerivedAlgorithm::Sort(zipHandle,KeyCompare<T,U,Compare>(comp));
DerivedAlgorithm::Sort(zipHandle,KeyCompare<T,U,BinaryCompare>(binary_compare));
}
//--------------------------------------------------------------------------
......
//============================================================================
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
......@@ -333,11 +333,11 @@ private:
private:
/// Reorder the value array along with the sorting algorithm
template<typename T, typename U, class StorageT, class StorageU, class Compare>
template<typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
VTKM_CONT_EXPORT static void SortByKeyDirect(
vtkm::cont::ArrayHandle<T,StorageT> &keys,
vtkm::cont::ArrayHandle<U,StorageU> &values,
Compare comp)
BinaryCompare binary_compare)
{
//combine the keys and values into a ZipArrayHandle
//we than need to specify a custom compare function wrapper
......@@ -349,7 +349,7 @@ private:
ZipHandleType zipHandle =
vtkm::cont::make_ArrayHandleZip(keys,values);
Sort(zipHandle,KeyCompare<T,U,Compare>(comp));
Sort(zipHandle,KeyCompare<T,U,BinaryCompare>(binary_compare));
}
public:
......@@ -361,13 +361,13 @@ public:
SortByKey(keys, values, std::less<T>());
}
template<typename T, typename U, class StorageT, class StorageU, class Less>
template<typename T, typename U, class StorageT, class StorageU, class BinaryCompare>
VTKM_CONT_EXPORT static void SortByKey(
vtkm::cont::ArrayHandle<T,StorageT> &keys,
vtkm::cont::ArrayHandle<U,StorageU> &values,
const Less &less)
const BinaryCompare &binary_compare)
{
internal::WrappedBinaryOperator<bool, Less > wrappedCompare( less );
internal::WrappedBinaryOperator<bool, BinaryCompare > wrappedCompare( binary_compare );
if (sizeof(U) > sizeof(vtkm::Id))
{
/// More efficient sort:
......@@ -395,9 +395,9 @@ public:
Sort(values, std::less<T>());
}
template<typename T, class Storage, class Compare>
template<typename T, class Storage, class BinaryCompare>
VTKM_CONT_EXPORT static void Sort(vtkm::cont::ArrayHandle<T,Storage>& values,
Compare comp)
BinaryCompare binary_compare)
{
typedef typename vtkm::cont::ArrayHandle<T,Storage>
::template ExecutionTypes<Device>::Portal PortalType;
......@@ -406,7 +406,7 @@ public:
vtkm::cont::ArrayPortalToIterators<PortalType> iterators(arrayPortal);
internal::WrappedBinaryOperator<bool,Compare> wrappedCompare(comp);
internal::WrappedBinaryOperator<bool,BinaryCompare> wrappedCompare(binary_compare);
std::sort(iterators.GetBegin(), iterators.GetEnd(), wrappedCompare);
}
......
......@@ -507,9 +507,9 @@ public:
Sort(values, lessOp );
}
template<typename T, class Container, class Compare>
template<typename T, class Container, class BinaryCompare>
VTKM_CONT_EXPORT static void Sort(
vtkm::cont::ArrayHandle<T,Container> &values, Compare comp)
vtkm::cont::ArrayHandle<T,Container> &values, BinaryCompare binary_compare)
{
typedef typename vtkm::cont::ArrayHandle<T,Container>::template
ExecutionTypes<vtkm::cont::DeviceAdapterTagTBB>::Portal PortalType;
......@@ -519,7 +519,7 @@ public:
typedef vtkm::cont::ArrayPortalToIterators<PortalType> IteratorsType;
IteratorsType iterators(arrayPortal);
internal::WrappedBinaryOperator<bool,Compare> wrappedCompare(comp);
internal::WrappedBinaryOperator<bool,BinaryCompare> wrappedCompare(binary_compare);
::tbb::parallel_sort(iterators.GetBegin(),
iterators.GetEnd(),
wrappedCompare);
......
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