70 template <
typename CompareLambda,
typename InputIterator,
typename OutputIterator>
72 OutputIterator output_iter,
const CompareLambda& compare_lambda)
76 switch (exec_policy) {
77#if defined(ARCANE_COMPILING_CUDA)
79 size_t temp_storage_size = 0;
80 cudaStream_t stream = impl::CudaUtils::toNativeStream(&queue);
82 ARCANE_CHECK_CUDA(::cub::DeviceMergeSort::SortKeysCopy(
nullptr, temp_storage_size,
83 input_iter, output_iter, nb_item,
84 compare_lambda, stream));
86 s.m_algo_storage.allocate(temp_storage_size);
87 ARCANE_CHECK_CUDA(::cub::DeviceMergeSort::SortKeysCopy(s.m_algo_storage.address(), temp_storage_size,
88 input_iter, output_iter, nb_item,
89 compare_lambda, stream));
92#if defined(ARCANE_COMPILING_HIP)
94 size_t temp_storage_size = 0;
95 hipStream_t stream = impl::HipUtils::toNativeStream(&queue);
97 ARCANE_CHECK_HIP(rocprim::merge_sort(
nullptr, temp_storage_size, input_iter, output_iter,
98 nb_item, compare_lambda, stream));
100 s.m_algo_storage.allocate(temp_storage_size);
102 ARCANE_CHECK_HIP(rocprim::merge_sort(s.m_algo_storage.address(), temp_storage_size, input_iter, output_iter,
103 nb_item, compare_lambda, stream));
111 auto output_iter_begin = output_iter;
112 for (
Int32 i = 0; i < nb_item; ++i) {
113 *output_iter = *input_iter;
117 std::sort(output_iter_begin, output_iter, compare_lambda);