Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Use constexpr if in case it's available
Browse files Browse the repository at this point in the history
  • Loading branch information
gevtushenko committed Oct 15, 2021
1 parent e53cb3c commit ce4c107
Showing 1 changed file with 39 additions and 34 deletions.
73 changes: 39 additions & 34 deletions thrust/system/cuda/detail/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <thrust/detail/alignment.h>
#include <thrust/type_traits/is_contiguous_iterator.h>


THRUST_NAMESPACE_BEGIN
namespace cuda_cub {

Expand All @@ -72,59 +73,63 @@ namespace __merge_sort {
{
(void)items;

cudaError_t status = cudaSuccess;

if (keys_count == 0)
{
return cudaSuccess;
return status;
}

if (STABLE::value)
THRUST_IF_CONSTEXPR(STABLE::value)
{
if (SORT_ITEMS::value)
THRUST_IF_CONSTEXPR(SORT_ITEMS::value)
{
return cub::DeviceMergeSort::StableSortPairs(d_temp_storage,
temp_storage_bytes,
keys,
items,
keys_count,
compare_op,
stream,
debug_sync);
status = cub::DeviceMergeSort::StableSortPairs(d_temp_storage,
temp_storage_bytes,
keys,
items,
keys_count,
compare_op,
stream,
debug_sync);
}
else
{
return cub::DeviceMergeSort::StableSortKeys(d_temp_storage,
temp_storage_bytes,
keys,
keys_count,
compare_op,
stream,
debug_sync);
status = cub::DeviceMergeSort::StableSortKeys(d_temp_storage,
temp_storage_bytes,
keys,
keys_count,
compare_op,
stream,
debug_sync);
}
}
else
{
if (SORT_ITEMS::value)
THRUST_IF_CONSTEXPR(SORT_ITEMS::value)
{
return cub::DeviceMergeSort::SortPairs(d_temp_storage,
temp_storage_bytes,
keys,
items,
keys_count,
compare_op,
stream,
debug_sync);
status = cub::DeviceMergeSort::SortPairs(d_temp_storage,
temp_storage_bytes,
keys,
items,
keys_count,
compare_op,
stream,
debug_sync);
}
else
{
return cub::DeviceMergeSort::SortKeys(d_temp_storage,
temp_storage_bytes,
keys,
keys_count,
compare_op,
stream,
debug_sync);
status = cub::DeviceMergeSort::SortKeys(d_temp_storage,
temp_storage_bytes,
keys,
keys_count,
compare_op,
stream,
debug_sync);
}
}

return status;
}

template <typename SORT_ITEMS,
Expand Down

0 comments on commit ce4c107

Please sign in to comment.