Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions examples/benchmark/static_thread_pool_bulk_enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,42 @@
#include "./common.hpp"
#include <exec/static_thread_pool.hpp>

#if !STDEXEC_NO_STDCPP_RANGES()
# include <exec/sequence/ignore_all_values.hpp>
# include <ranges>
#include <exec/sequence/ignore_all_values.hpp>
#include <ranges>

struct RunThread
{
void operator()(exec::static_thread_pool& pool,
std::size_t total_scheds,
std::size_t tid,
std::barrier<>& barrier,
# ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
#ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
std::span<char> buffer,
# endif
#endif
std::atomic<bool>& stop,
exec::numa_policy numa)
{
int numa_node = numa.thread_index_to_node(tid);
numa.bind_to_node(numa_node);
void(numa.bind_to_node(numa_node));
while (true)
{
barrier.arrive_and_wait();
if (stop.load())
{
break;
}
# ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
#ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
pmr::monotonic_buffer_resource rsrc{buffer.data(), buffer.size()};
pmr::polymorphic_allocator<char> alloc{&rsrc};
auto env = stdexec::prop{stdexec::get_allocator, alloc};
auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism());
auto iterate = exec::schedule_all(pool, std::views::iota(start, end))
| exec::ignore_all_values() | stdexec::write_env(env);
# else
#else
auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism());
auto iterate = exec::schedule_all(pool, std::views::iota(start, end))
| exec::ignore_all_values();
# endif
#endif
stdexec::sync_wait(iterate);
barrier.arrive_and_wait();
}
Expand All @@ -74,6 +73,3 @@ auto main(int argc, char** argv) -> int
exec::numa_policy numa{my_numa_distribution{}};
my_main<exec::static_thread_pool, RunThread>(argc, argv, std::move(numa));
}
#else
int main() {}
#endif
20 changes: 8 additions & 12 deletions examples/benchmark/static_thread_pool_bulk_enqueue_nested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@
#include "./common.hpp"
#include <exec/static_thread_pool.hpp>

#if !STDEXEC_NO_STDCPP_RANGES()
# include <exec/sequence/ignore_all_values.hpp>
# include <ranges>
#include <exec/sequence/ignore_all_values.hpp>
#include <ranges>

struct RunThread
{
void operator()(exec::static_thread_pool& pool,
std::size_t total_scheds,
std::size_t tid,
std::barrier<>& barrier,
# ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
#ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
std::span<char> buffer,
# endif
#endif
std::atomic<bool>& stop,
exec::numa_policy numa)
{
int numa_node = numa.thread_index_to_node(tid);
numa.bind_to_node(numa_node);
void(numa.bind_to_node(numa_node));
auto scheduler = pool.get_scheduler_on_thread(tid);
while (true)
{
Expand All @@ -43,17 +42,17 @@ struct RunThread
{
break;
}
# ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
#ifndef STDEXEC_NO_MONOTONIC_BUFFER_RESOURCE
pmr::monotonic_buffer_resource rsrc{buffer.data(), buffer.size()};
pmr::polymorphic_allocator<char> alloc{&rsrc};
auto env = stdexec::prop{stdexec::get_allocator, alloc};
auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism());
auto iterate = exec::iterate(std::views::iota(start, end)) | exec::ignore_all_values()
| stdexec::write_env(env);
# else
#else
auto [start, end] = exec::_pool_::even_share(total_scheds, tid, pool.available_parallelism());
auto iterate = exec::iterate(std::views::iota(start, end)) | exec::ignore_all_values();
# endif
#endif
stdexec::sync_wait(stdexec::starts_on(scheduler, iterate));
barrier.arrive_and_wait();
}
Expand All @@ -64,6 +63,3 @@ auto main(int argc, char** argv) -> int
{
my_main<exec::static_thread_pool, RunThread>(argc, argv);
}
#else
int main() {}
#endif
1 change: 1 addition & 0 deletions examples/sudoku.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ void partial_solve(stdexec::parallel_scheduler sch,
{
if (1 << (potential - 1) & board.get()[first_potential_set].potential_set)
{
// NOLINTNEXTLINE(bugprone-unhandled-exception-at-new)
std::unique_ptr<board_element[]> new_board(new board_element[BOARD_SIZE]);
copy_board(board.get(), new_board.get());
new_board.get()[first_potential_set].solved_element = potential;
Expand Down
40 changes: 18 additions & 22 deletions include/exec/sequence/iterate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,24 @@

#include "../../stdexec/__detail/__config.hpp"

#if !STDEXEC_NO_STDCPP_RANGES()

# include "../../stdexec/__detail/__concepts.hpp"
# include "../../stdexec/__detail/__connect.hpp"
# include "../../stdexec/__detail/__env.hpp"
# include "../../stdexec/__detail/__execution_fwd.hpp"
# include "../../stdexec/__detail/__operation_states.hpp"
# include "../../stdexec/__detail/__optional.hpp"
# include "../../stdexec/__detail/__receivers.hpp"
# include "../../stdexec/__detail/__schedulers.hpp"
# include "../../stdexec/__detail/__sender_concepts.hpp"

# include "../detail/basic_sequence.hpp"
# include "../sender_for.hpp"
# include "../sequence.hpp"
# include "../sequence_senders.hpp"
# include "../trampoline_scheduler.hpp"

# include <exception>
# include <ranges>
#include "../../stdexec/__detail/__concepts.hpp"
#include "../../stdexec/__detail/__connect.hpp"
#include "../../stdexec/__detail/__env.hpp"
#include "../../stdexec/__detail/__execution_fwd.hpp"
#include "../../stdexec/__detail/__operation_states.hpp"
#include "../../stdexec/__detail/__optional.hpp"
#include "../../stdexec/__detail/__receivers.hpp"
#include "../../stdexec/__detail/__schedulers.hpp"
#include "../../stdexec/__detail/__sender_concepts.hpp"

#include "../detail/basic_sequence.hpp"
#include "../sender_for.hpp"
#include "../sequence.hpp"
#include "../sequence_senders.hpp"
#include "../trampoline_scheduler.hpp"

#include <exception>
#include <ranges>

namespace experimental::execution
{
Expand Down Expand Up @@ -250,5 +248,3 @@ namespace experimental::execution
} // namespace experimental::execution

namespace exec = experimental::execution;

#endif // !STDEXEC_NO_STDCPP_RANGES()
27 changes: 4 additions & 23 deletions include/exec/static_thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,11 @@ namespace experimental::execution
return std::make_pair(static_cast<Shape>(begin), static_cast<Shape>(end));
}

#if !STDEXEC_NO_STDCPP_RANGES()
namespace schedule_all_
{
template <class Range>
class sequence;
} // namespace schedule_all_
#endif

struct task_base
{
Expand Down Expand Up @@ -267,7 +265,6 @@ namespace experimental::execution
_static_thread_pool& pool_;
};

#if !STDEXEC_NO_STDCPP_RANGES()
struct _transform_iterate
{
template <class Range>
Expand All @@ -278,7 +275,6 @@ namespace experimental::execution

_static_thread_pool& pool_;
};
#endif

static auto _hardware_concurrency() noexcept -> unsigned int
{
Expand Down Expand Up @@ -316,7 +312,6 @@ namespace experimental::execution
}
}

#if !STDEXEC_NO_STDCPP_RANGES()
template <sender_for<exec::iterate_t> Sender, class Env>
constexpr auto
transform_sender(STDEXEC::set_value_t, Sender&& sndr, Env const & env) const noexcept
Expand All @@ -340,7 +335,6 @@ namespace experimental::execution
STDEXEC::_WITH_ENVIRONMENT_(Env)>();
}
}
#endif
};

public:
Expand Down Expand Up @@ -765,8 +759,7 @@ namespace experimental::execution
.thread_index = index});
}

// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
std::sort(thread_index_by_numa_node_.begin(), thread_index_by_numa_node_.end());
std::ranges::sort(thread_index_by_numa_node_);
std::vector<workstealing_victim> victims{};
for (auto& state: thread_states_)
{
Expand Down Expand Up @@ -842,15 +835,12 @@ namespace experimental::execution
inline auto _static_thread_pool::num_threads(int numa) const noexcept -> std::size_t
{
thread_index_by_numa_node key{.numa_node = numa, .thread_index = 0};
// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
auto it = std::lower_bound(thread_index_by_numa_node_.begin(),
thread_index_by_numa_node_.end(),
key);
auto it = std::ranges::lower_bound(thread_index_by_numa_node_, key);
if (it == thread_index_by_numa_node_.end())
{
return 0;
}
auto it_end = std::upper_bound(it, thread_index_by_numa_node_.end(), key);
auto it_end = std::ranges::upper_bound(it, thread_index_by_numa_node_.end(), key);
return static_cast<std::size_t>(std::distance(it, it_end));
}

Expand All @@ -876,10 +866,7 @@ namespace experimental::execution
-> std::size_t
{
thread_index_by_numa_node key{.numa_node = node_index, .thread_index = 0};
// NOLINTNEXTLINE(modernize-use-ranges) we still support platforms without the std::ranges algorithms
auto it = std::lower_bound(thread_index_by_numa_node_.begin(),
thread_index_by_numa_node_.end(),
key);
auto it = std::ranges::lower_bound(thread_index_by_numa_node_, key);
STDEXEC_ASSERT(it != thread_index_by_numa_node_.end());
std::advance(it, thread_index);
return it->thread_index;
Expand Down Expand Up @@ -1578,7 +1565,6 @@ namespace experimental::execution
{}
};

#if !STDEXEC_NO_STDCPP_RANGES()
namespace schedule_all_
{
template <class Rcvr>
Expand Down Expand Up @@ -1832,14 +1818,11 @@ namespace experimental::execution
} // namespace schedule_all_

struct schedule_all_t;
#endif
} // namespace _pool_

struct static_thread_pool : private _pool_::_static_thread_pool
{
#if !STDEXEC_NO_STDCPP_RANGES()
friend struct _pool_::schedule_all_t;
#endif
using task_base = _pool_::task_base;

static_thread_pool() = default;
Expand Down Expand Up @@ -1872,7 +1855,6 @@ namespace experimental::execution
using _pool_::_static_thread_pool::params;
};

#if !STDEXEC_NO_STDCPP_RANGES()
namespace _pool_
{
struct schedule_all_t
Expand All @@ -1887,7 +1869,6 @@ namespace experimental::execution
} // namespace _pool_

inline constexpr _pool_::schedule_all_t schedule_all{};
#endif

} // namespace experimental::execution

Expand Down
5 changes: 3 additions & 2 deletions include/nvexec/stream/algorithm_base.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

#pragma once

#include "../../stdexec/__detail/__ranges.hpp"
#include "../../stdexec/execution.hpp"

#include <cstddef>
#include <ranges>

#include <cuda/std/type_traits>

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

template <class Sender, class Receiver, class InitT, class Fun, class DerivedReceiver>
struct receiver : public stream_receiver_base
Expand Down
9 changes: 0 additions & 9 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,6 @@ namespace STDEXEC
# define STDEXEC_TSAN() 0
#endif

// Before clang-16, clang did not like libstdc++'s ranges implementation
#if __has_include(<ranges>) && \
(defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L) && \
(!STDEXEC_CLANG() || STDEXEC_CLANG_VERSION >= 1600 || defined(_LIBCPP_VERSION))
# define STDEXEC_NO_STDCPP_RANGES() 0
#else
# define STDEXEC_NO_STDCPP_RANGES() 1
#endif

#if __has_include(<memory_resource>) && \
(defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L)
# define STDEXEC_NO_STDCPP_MEMORY_RESOURCE() 0
Expand Down
8 changes: 6 additions & 2 deletions include/stdexec/__detail/__deprecations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include "__execution_fwd.hpp"
#include "__ranges.hpp" // IWYU pragma: keep

#include "__prologue.hpp"

Expand All @@ -27,8 +28,8 @@ namespace STDEXEC
inline constexpr __execute_may_block_caller_t const & execute_may_block_caller =
__execute_may_block_caller;

using empty_env [[deprecated(
"STDEXEC::empty_env is now spelled " STDEXEC_PP_STRINGIZE(STDEXEC) "::env<>")]] = env<>;
using empty_env
[[deprecated("empty_env is now spelled " STDEXEC_PP_STRINGIZE(STDEXEC) "::env<>")]] = env<>;

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

[[deprecated]]
inline constexpr exec::__execute_t const & execute = exec::__execute;

namespace [[deprecated("Use std::ranges directly")]] ranges
{}
} // namespace STDEXEC

#include "__epilogue.hpp"
Loading
Loading