41 inline void init(MPI_Comm comm = MPI_COMM_WORLD) {
49 template <
typename Fn,
typename... Args>
54 template <
typename SchedLoopCallback,
typename Fn,
typename... Args>
58 return w.root_exec(cb, std::forward<Fn>(fn), std::forward<Args>(
args)...);
68 return w.sched().is_executing_root();
71 template <
typename Fn,
typename... Args>
76 return w.coll_exec(fn,
args...);
79 template <
typename PreSuspendCallback,
typename PostSuspendCallback>
81 PreSuspendCallback&& pre_suspend_cb,
82 PostSuspendCallback&& post_suspend_cb) {
86 w.sched().migrate_to(target_rank,
87 std::forward<PreSuspendCallback>(pre_suspend_cb),
88 std::forward<PostSuspendCallback>(post_suspend_cb));
95 template <
typename PreSuspendCallback,
typename PostSuspendCallback>
96 inline void poll(PreSuspendCallback&& pre_suspend_cb,
97 PostSuspendCallback&& post_suspend_cb) {
99 w.sched().poll(std::forward<PreSuspendCallback>(pre_suspend_cb),
100 std::forward<PostSuspendCallback>(post_suspend_cb));
108 w.sched().task_group_begin(tgdata);
111 template <
typename PreSuspendCallback,
typename PostSuspendCallback>
113 PostSuspendCallback&& post_suspend_cb) {
116 w.sched().task_group_end(std::forward<PreSuspendCallback>(pre_suspend_cb),
117 std::forward<PostSuspendCallback>(post_suspend_cb));
123 w.sched().dag_prof_begin();
129 w.sched().dag_prof_end();
135 w.sched().dag_prof_print();
138 ITYR_TEST_CASE(
"[ityr::ito] fib") {
141 std::function<int(
int)> fib = [&](
int n) ->
int {
145 thread<int> th([=]{
return fib(n - 1); });
158 ITYR_TEST_CASE(
"[ityr::ito] load balancing") {
164 std::function<void(
int)> lb = [&](
int n) {
195 ITYR_TEST_CASE(
"[ityr::ito] move semantics") {
198 common::move_only_t mo1(2);
200 common::move_only_t mo2(3 + mo1.value());
202 thread<common::move_only_t> th([](common::move_only_t mo2) {
203 common::move_only_t mo3(4 + mo2.value());
207 common::move_only_t ret = th.join();
215 ITYR_TEST_CASE(
"[ityr::ito] nested root/coll_exec()") {
254 ITYR_TEST_CASE(
"[ityr::ito] migrate_to") {
258 for (
int i = 0; i < 10; i++) {
Definition: mpi_util.hpp:430
Definition: prof_events.hpp:124
static auto & get()
Definition: util.hpp:180
static void init(Args &&... args)
Definition: util.hpp:190
static void fini()
Definition: util.hpp:194
ito(MPI_Comm comm)
Definition: ito.hpp:21
Definition: prof_events.hpp:220
#define ITYR_CHECK(cond)
Definition: util.hpp:48
rank_t n_ranks()
Definition: topology.hpp:208
int rank_t
Definition: topology.hpp:12
MPI_Comm mpicomm()
Definition: topology.hpp:206
rank_t my_rank()
Definition: topology.hpp:207
va_list args
Definition: util.hpp:76
T mpi_reduce_value(const T &value, int root_rank, MPI_Comm comm, MPI_Op op=MPI_SUM)
Definition: mpi_util.hpp:170
void mpi_barrier(MPI_Comm comm)
Definition: mpi_util.hpp:42
Definition: aarch64.hpp:5
void fini()
Definition: ito.hpp:45
void migrate_to(common::topology::rank_t target_rank, PreSuspendCallback &&pre_suspend_cb, PostSuspendCallback &&post_suspend_cb)
Definition: ito.hpp:80
auto root_exec(Fn &&fn, Args &&... args)
Definition: ito.hpp:50
void task_group_begin(task_group_data *tgdata)
Definition: ito.hpp:105
void dag_prof_print()
Definition: ito.hpp:132
auto coll_exec(const Fn &fn, const Args &... args)
Definition: ito.hpp:72
void init(MPI_Comm comm=MPI_COMM_WORLD)
Definition: ito.hpp:41
bool is_root()
Definition: ito.hpp:66
void poll(PreSuspendCallback &&pre_suspend_cb, PostSuspendCallback &&post_suspend_cb)
Definition: ito.hpp:96
bool is_spmd()
Definition: ito.hpp:61
void dag_prof_begin()
Definition: ito.hpp:120
constexpr with_callback_t with_callback
Definition: thread.hpp:11
void task_group_end(PreSuspendCallback &&pre_suspend_cb, PostSuspendCallback &&post_suspend_cb)
Definition: ito.hpp:112
void dag_prof_end()
Definition: ito.hpp:126
scheduler::task_group_data task_group_data
Definition: ito.hpp:103
rank_t my_rank()
Return the rank of the process running the current thread.
Definition: ityr.hpp:99
ForwardIteratorD move(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Move a range to another.
Definition: parallel_loop.hpp:934
Definition: options.hpp:153
Definition: options.hpp:80
Definition: thread.hpp:10