Skip to content

Commit b2a4131

Browse files
committed
use range algorithms where appropriate
1 parent 84149a9 commit b2a4131

4 files changed

Lines changed: 24 additions & 23 deletions

File tree

include/exec/static_thread_pool.hpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,8 +759,7 @@ namespace experimental::execution
759759
.thread_index = index});
760760
}
761761

762-
// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
763-
std::sort(thread_index_by_numa_node_.begin(), thread_index_by_numa_node_.end());
762+
std::ranges::sort(thread_index_by_numa_node_);
764763
std::vector<workstealing_victim> victims{};
765764
for (auto& state: thread_states_)
766765
{
@@ -836,15 +835,12 @@ namespace experimental::execution
836835
inline auto _static_thread_pool::num_threads(int numa) const noexcept -> std::size_t
837836
{
838837
thread_index_by_numa_node key{.numa_node = numa, .thread_index = 0};
839-
// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
840-
auto it = std::lower_bound(thread_index_by_numa_node_.begin(),
841-
thread_index_by_numa_node_.end(),
842-
key);
838+
auto it = std::ranges::lower_bound(thread_index_by_numa_node_, key);
843839
if (it == thread_index_by_numa_node_.end())
844840
{
845841
return 0;
846842
}
847-
auto it_end = std::upper_bound(it, thread_index_by_numa_node_.end(), key);
843+
auto it_end = std::ranges::upper_bound(it, thread_index_by_numa_node_.end(), key);
848844
return static_cast<std::size_t>(std::distance(it, it_end));
849845
}
850846

@@ -870,10 +866,7 @@ namespace experimental::execution
870866
-> std::size_t
871867
{
872868
thread_index_by_numa_node key{.numa_node = node_index, .thread_index = 0};
873-
// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
874-
auto it = std::lower_bound(thread_index_by_numa_node_.begin(),
875-
thread_index_by_numa_node_.end(),
876-
key);
869+
auto it = std::ranges::lower_bound(thread_index_by_numa_node_, key);
877870
STDEXEC_ASSERT(it != thread_index_by_numa_node_.end());
878871
std::advance(it, thread_index);
879872
return it->thread_index;

include/nvexec/stream/algorithm_base.cuh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
#pragma once
2020

21-
#include "../../stdexec/__detail/__ranges.hpp"
2221
#include "../../stdexec/execution.hpp"
22+
2323
#include <cstddef>
24+
#include <ranges>
2425

2526
#include <cuda/std/type_traits>
2627

@@ -32,7 +33,7 @@ namespace nv::execution::_strm::__algo_range_init_fun
3233
{
3334
template <class Range, class InitT, class Fun>
3435
using binary_invoke_result_t = ::cuda::std::decay_t<
35-
::cuda::std::invoke_result_t<Fun, STDEXEC::ranges::range_reference_t<Range>, InitT>>;
36+
::cuda::std::invoke_result_t<Fun, std::ranges::range_reference_t<Range>, InitT>>;
3637

3738
template <class Sender, class Receiver, class InitT, class Fun, class DerivedReceiver>
3839
struct receiver : public stream_receiver_base

include/stdexec/__detail/__deprecations.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#pragma once
1717

1818
#include "__execution_fwd.hpp"
19+
#include "__ranges.hpp" // IWYU pragma: keep
1920

2021
#include "__prologue.hpp"
2122

@@ -27,8 +28,8 @@ namespace STDEXEC
2728
inline constexpr __execute_may_block_caller_t const & execute_may_block_caller =
2829
__execute_may_block_caller;
2930

30-
using empty_env [[deprecated(
31-
"STDEXEC::empty_env is now spelled " STDEXEC_PP_STRINGIZE(STDEXEC) "::env<>")]] = env<>;
31+
using empty_env
32+
[[deprecated("empty_env is now spelled " STDEXEC_PP_STRINGIZE(STDEXEC) "::env<>")]] = env<>;
3233

3334
using dependent_completions [[deprecated("use dependent_sender_error instead of "
3435
"dependent_completions")]] = dependent_sender_error;
@@ -86,6 +87,9 @@ namespace STDEXEC
8687

8788
[[deprecated]]
8889
inline constexpr exec::__execute_t const & execute = exec::__execute;
90+
91+
namespace [[deprecated("Use std::ranges directly")]] ranges
92+
{}
8993
} // namespace STDEXEC
9094

9195
#include "__epilogue.hpp"

include/stdexec/__detail/__ranges.hpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@
2121

2222
#include "__prologue.hpp"
2323

24-
namespace STDEXEC::ranges
24+
namespace STDEXEC
2525
{
26-
using std::ranges::begin;
27-
using std::ranges::end;
26+
namespace [[deprecated("use std::ranges directly")]] ranges
27+
{
28+
using std::ranges::begin;
29+
using std::ranges::end;
2830

29-
using std::ranges::range_value_t;
30-
using std::ranges::range_reference_t;
31-
using std::ranges::iterator_t;
32-
using std::ranges::sentinel_t;
33-
} // namespace STDEXEC::ranges
31+
using std::ranges::range_value_t;
32+
using std::ranges::range_reference_t;
33+
using std::ranges::iterator_t;
34+
using std::ranges::sentinel_t;
35+
} // namespace ranges
36+
} // namespace STDEXEC
3437

3538
#include "__epilogue.hpp"

0 commit comments

Comments
 (0)