Itoyori  v0.0.1
serial.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ityr/common/util.hpp"
4 #include "ityr/ito/util.hpp"
6 
7 namespace ityr::ito {
8 
10 public:
11  template <typename T>
12  using thread_handler = T;
13 
15 
16  template <typename T, typename SchedLoopCallback, typename Fn, typename... Args>
17  T root_exec(SchedLoopCallback, Fn&& fn, Args&&... args) {
18  return invoke_fn<T>(std::forward<Fn>(fn), std::make_tuple(std::forward<Args>(args)...));
19  }
20 
21  template <typename T, typename OnDriftForkCallback, typename OnDriftDieCallback,
22  typename WorkHint, typename Fn, typename... Args>
24  OnDriftForkCallback, OnDriftDieCallback,
25  WorkHint, WorkHint, Fn&& fn, Args&&... args) {
26  th = invoke_fn<T>(std::forward<Fn>(fn), std::make_tuple(std::forward<Args>(args)...));
27  }
28 
29  template <typename T>
31  return std::move(th);
32  }
33 
34  template <typename SchedLoopCallback>
35  void sched_loop(SchedLoopCallback) {}
36 
37  template <typename PreSuspendCallback, typename PostSuspendCallback>
38  void poll(PreSuspendCallback&&, PostSuspendCallback&&) {}
39 
40  template <typename PreSuspendCallback, typename PostSuspendCallback>
41  void migrate_to(common::topology::rank_t, PreSuspendCallback&&, PostSuspendCallback&&) {}
42 
43  template <typename Fn>
44  void coll_exec(const Fn& fn) {
45  fn();
46  }
47 
48  bool is_executing_root() const {
49  return true;
50  }
51 
52  template <typename T>
53  static bool is_serialized(const thread_handler<T>&) {
54  return true;
55  }
56 
57  struct task_group_data {};
59  template <typename PreSuspendCallback, typename PostSuspendCallback>
60  void task_group_end(PreSuspendCallback&&, PostSuspendCallback&&) {}
61 
62  void dag_prof_begin() {}
63  void dag_prof_end() {}
64  void dag_prof_print() const {}
65 };
66 
67 }
Definition: serial.hpp:9
scheduler_serial()
Definition: serial.hpp:14
T thread_handler
Definition: serial.hpp:12
void dag_prof_end()
Definition: serial.hpp:63
void fork(thread_handler< T > &th, OnDriftForkCallback, OnDriftDieCallback, WorkHint, WorkHint, Fn &&fn, Args &&... args)
Definition: serial.hpp:23
void dag_prof_print() const
Definition: serial.hpp:64
T root_exec(SchedLoopCallback, Fn &&fn, Args &&... args)
Definition: serial.hpp:17
void coll_exec(const Fn &fn)
Definition: serial.hpp:44
void migrate_to(common::topology::rank_t, PreSuspendCallback &&, PostSuspendCallback &&)
Definition: serial.hpp:41
void task_group_end(PreSuspendCallback &&, PostSuspendCallback &&)
Definition: serial.hpp:60
void dag_prof_begin()
Definition: serial.hpp:62
void poll(PreSuspendCallback &&, PostSuspendCallback &&)
Definition: serial.hpp:38
void task_group_begin(task_group_data *)
Definition: serial.hpp:58
bool is_executing_root() const
Definition: serial.hpp:48
void sched_loop(SchedLoopCallback)
Definition: serial.hpp:35
static bool is_serialized(const thread_handler< T > &)
Definition: serial.hpp:53
T join(thread_handler< T > &th)
Definition: serial.hpp:30
int rank_t
Definition: topology.hpp:12
va_list args
Definition: util.hpp:76
Definition: aarch64.hpp:5
ForwardIteratorD move(const ExecutionPolicy &policy, ForwardIterator1 first1, ForwardIterator1 last1, ForwardIteratorD first_d)
Move a range to another.
Definition: parallel_loop.hpp:934