14 template <
typename SchedLoopCallback,
typename Fn,
typename... Args>
19 using retval_t = std::invoke_result_t<Fn, Args...>;
20 if constexpr (std::is_void_v<retval_t>) {
22 sched_.root_exec<
no_retval_t>(cb, std::forward<Fn>(fn), std::forward<Args>(
args)...);
24 common::profiler::switch_phase<prof_phase_spmd, prof_phase_sched_loop>();
25 sched_.sched_loop(cb);
26 common::profiler::switch_phase<prof_phase_sched_loop, prof_phase_spmd>();
36 retval = sched_.root_exec<retval_t>(cb, std::forward<Fn>(fn), std::forward<Args>(
args)...);
38 common::profiler::switch_phase<prof_phase_spmd, prof_phase_sched_loop>();
39 sched_.sched_loop(cb);
40 common::profiler::switch_phase<prof_phase_sched_loop, prof_phase_spmd>();
51 template <
typename Fn,
typename... Args>
55 using retval_t = std::invoke_result_t<Fn, Args...>;
58 std::conditional_t<std::is_void_v<retval_t>,
no_retval_t, retval_t> retv;
60 auto coll_task_fn = [=, &retv]() {
62 auto prev_coll_master = coll_master_;
63 coll_master_ = next_master;
64 if constexpr (std::is_void_v<retval_t>) {
68 auto&& ret = fn(
args...);
70 retv = std::forward<decltype(ret)>(ret);
73 coll_master_ = prev_coll_master;
77 sched_.coll_exec(coll_task_fn);
79 if constexpr (!std::is_void_v<retval_t>) {
worker()
Definition: worker.hpp:11
bool is_spmd() const
Definition: worker.hpp:84
auto root_exec(SchedLoopCallback cb, Fn &&fn, Args &&... args)
Definition: worker.hpp:15
auto coll_exec(const Fn &fn, const Args &... args)
Definition: worker.hpp:52
scheduler & sched()
Definition: worker.hpp:86
#define ITYR_CHECK(cond)
Definition: util.hpp:48
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_bcast_value(const T &value, int root_rank, MPI_Comm comm)
Definition: mpi_util.hpp:145
void mpi_barrier(MPI_Comm comm)
Definition: mpi_util.hpp:42
ITYR_CONCAT(scheduler_, ITYR_ITO_SCHEDULER) scheduler
Definition: scheduler.hpp:11