34 template <
typename T,
typename Container,
class BinaryCompare>
36 template <
typename T,
typename StorageT,
typename U,
typename StorageU,
class BinaryCompare>
42 template <
typename HandleType,
class BinaryCompare>
44 BinaryCompare binary_compare,
45 vtkm::cont::internal::radix::PSortTag)
49 auto portal = values.PrepareForInPlace(DeviceAdapterTagOpenMP(), token);
51 vtkm::Id2 range(0, values.GetNumberOfValues());
53 using IterType =
typename std::decay<decltype(iter)>::type;
56 Sorter sorter(iter, binary_compare);
57 sorter.Execute(range);
61 template <
typename T,
typename StorageT,
class BinaryCompare>
63 BinaryCompare binary_compare,
64 vtkm::cont::internal::radix::RadixSortTag)
66 auto c = vtkm::cont::internal::radix::get_std_compare(binary_compare, T{});
68 auto valuesPortal = values.
PrepareForInPlace(vtkm::cont::DeviceAdapterTagOpenMP{}, token);
69 radix::parallel_radix_sort(
70 valuesPortal.GetIteratorBegin(),
static_cast<std::size_t
>(values.
GetNumberOfValues()), c);
74 template <
typename T,
typename Container,
class BinaryCompare>
77 using namespace vtkm::cont::internal::radix;
78 using SortAlgorithmTag =
typename sort_tag_type<T, Container, BinaryCompare>::type;
84 template <
typename T,
typename StorageT,
typename U,
typename StorageU,
class BinaryCompare>
87 BinaryCompare binary_compare,
88 vtkm::cont::internal::radix::PSortTag)
91 constexpr
bool larger_than_64bits =
sizeof(U) >
sizeof(vtkm::Int64);
92 if (larger_than_64bits)
101 IndexType indexArray;
102 ValueType valuesScattered;
109 auto inputPortal = handle.PrepareForInput(DeviceAdapterTagOpenMP(), token);
111 indexArray.PrepareForOutput(keys.
GetNumberOfValues(), DeviceAdapterTagOpenMP(), token);
118 vtkm::cont::internal::KeyCompare<T, vtkm::Id, BinaryCompare>(binary_compare),
119 vtkm::cont::internal::radix::PSortTag());
124 auto valuesInPortal = values.
PrepareForInput(DeviceAdapterTagOpenMP(), token);
125 auto indexPortal = indexArray.PrepareForInput(DeviceAdapterTagOpenMP(), token);
126 auto valuesOutPortal =
127 valuesScattered.PrepareForOutput(size, DeviceAdapterTagOpenMP(), token);
131 firstprivate(valuesInPortal, indexPortal, valuesOutPortal)
136 valuesOutPortal.Set(i, valuesInPortal.Get(indexPortal.Get(i)));
143 auto inputPortal = valuesScattered.PrepareForInput(DeviceAdapterTagOpenMP(), token);
145 valuesScattered.GetNumberOfValues(), DeviceAdapterTagOpenMP(), token);
146 openmp::CopyHelper(inputPortal, outputPortal, 0, 0, size);
156 vtkm::cont::internal::KeyCompare<T, U, BinaryCompare>(binary_compare),
157 vtkm::cont::internal::radix::PSortTag{});
162 template <
typename T,
typename StorageT,
typename StorageU,
class BinaryCompare>
165 BinaryCompare binary_compare,
166 vtkm::cont::internal::radix::RadixSortTag)
168 using namespace vtkm::cont::internal::radix;
169 auto c = get_std_compare(binary_compare, T{});
171 auto keysPortal = keys.
PrepareForInPlace(vtkm::cont::DeviceAdapterTagOpenMP{}, token);
172 auto valuesPortal = values.
PrepareForInPlace(vtkm::cont::DeviceAdapterTagOpenMP{}, token);
173 radix::parallel_radix_sort_key_values(keysPortal.GetIteratorBegin(),
174 valuesPortal.GetIteratorBegin(),
178 template <
typename T,
typename StorageT,
typename U,
typename StorageU,
class BinaryCompare>
181 BinaryCompare binary_compare,
182 vtkm::cont::internal::radix::RadixSortTag)
189 IndexType indexArray;
190 ValueType valuesScattered;
196 auto inputPortal = handle.PrepareForInput(DeviceAdapterTagOpenMP(), token);
198 indexArray.PrepareForOutput(keys.
GetNumberOfValues(), DeviceAdapterTagOpenMP(), token);
203 if (valuesBytes >
static_cast<vtkm::Id>(vtkm::cont::internal::radix::MIN_BYTES_FOR_PARALLEL))
211 vtkm::cont::internal::KeyCompare<T, vtkm::Id, BinaryCompare>(binary_compare),
212 vtkm::cont::internal::radix::PSortTag());
218 auto valuesInPortal = values.
PrepareForInput(DeviceAdapterTagOpenMP(), token);
219 auto indexPortal = indexArray.PrepareForInput(DeviceAdapterTagOpenMP(), token);
220 auto valuesOutPortal = valuesScattered.PrepareForOutput(size, DeviceAdapterTagOpenMP(), token);
224 firstprivate(valuesInPortal, indexPortal, valuesOutPortal)
229 valuesOutPortal.Set(i, valuesInPortal.Get(indexPortal.Get(i)));
235 auto inputPortal = valuesScattered.PrepareForInput(DeviceAdapterTagOpenMP(), token);
237 values.
PrepareForOutput(valuesScattered.GetNumberOfValues(), DeviceAdapterTagOpenMP(), token);
238 openmp::CopyHelper(inputPortal, outputPortal, 0, 0, valuesScattered.GetNumberOfValues());
243 template <
typename T,
typename StorageT,
typename U,
typename StorageU,
class BinaryCompare>
246 BinaryCompare binary_compare)
248 using namespace vtkm::cont::internal::radix;
249 using SortAlgorithmTag =
250 typename sortbykey_tag_type<T, U, StorageT, StorageU, BinaryCompare>::type;