func.h
Go to the documentation of this file.
1 #ifndef TTG_FUNC_H
2 #define TTG_FUNC_H
3 
4 #include "ttg/fwd.h"
5 
6 #include "ttg/edge.h"
7 #include "ttg/impl_selector.h"
8 #include "ttg/terminal.h"
9 #include "ttg/traverse.h"
10 #include "ttg/tt.h"
11 
12 namespace ttg {
13 
14  namespace detail {
20  template <ttg::Runtime Runtime>
22  template <typename Value>
23  inline constexpr decltype(auto) operator()(Value &&value) const {
24  return std::forward<Value>(value);
25  }
26  };
27 
28  template <typename keyT, typename valueT>
29  inline auto get_out_terminal(size_t i, const char *func) {
30 #ifndef NDEBUG
31  auto *base_terminal_ptr = TTBase::get_outputs_tls_ptr()->at(i);
32  auto *terminal_ptr = dynamic_cast<Out<std::decay_t<keyT>, std::decay_t<valueT>> *>(base_terminal_ptr);
33  if (terminal_ptr == nullptr) {
34  std::stringstream ss;
35  ss << func
36  << ": invalid type of ith output terminal, most likely due to mismatch between its type "
37  "and the type of key/value; make sure that the arguments to "
38  << func
39  << "() match the types encoded in the output "
40  "terminals, or pass the output terminal tuple to the task function explicitly";
41  throw std::runtime_error(ss.str());
42  }
43 #else
44  auto *base_terminal_ptr = TTBase::get_outputs_tls_ptr()->operator[](i);
45  auto *terminal_ptr = static_cast<Out<std::decay_t<keyT>, std::decay_t<valueT>> *>(base_terminal_ptr);
46 #endif
47  return terminal_ptr;
48  }
49 
50  template <typename keyT>
51  inline auto get_out_base_terminal(size_t i, const char *func) {
52 #ifndef NDEBUG
53  auto *base_terminal_ptr = TTBase::get_outputs_tls_ptr()->at(i);
54  auto *terminal_ptr = dynamic_cast<OutTerminalBase<std::decay_t<keyT>> *>(base_terminal_ptr);
55  if (terminal_ptr == nullptr) {
56  std::stringstream ss;
57  ss << func
58  << ": invalid type of ith output terminal, most likely due to mismatch between its type "
59  "and the type of key; make sure that the arguments to "
60  << func
61  << "() match the types encoded in the output "
62  "terminals, or pass the output terminal tuple to the task function explicitly";
63  throw std::runtime_error(ss.str());
64  }
65 #else
66  auto *base_terminal_ptr = TTBase::get_outputs_tls_ptr()->operator[](i);
67  auto *terminal_ptr = static_cast<OutTerminalBase<std::decay_t<keyT>> *>(base_terminal_ptr);
68 #endif
69  return terminal_ptr;
70  }
71 
72  } // namespace detail
73 
78  template <typename... TTBasePtrs>
79  inline std::enable_if_t<(std::is_convertible_v<decltype(*(std::declval<TTBasePtrs>())), TTBase &> && ...), bool>
80  make_graph_executable(TTBasePtrs &&...tts) {
81  auto traverse = ttg::make_traverse([](auto &&x) { std::forward<decltype(x)>(x)->make_executable(); });
82  auto ret = traverse(std::forward<TTBasePtrs>(tts)...);
83  // make sure everyone has traversed the TT
84  auto world = [&](auto&& tt0, auto&&... tts) { return tt0->get_world(); }(std::forward<TTBasePtrs>(tts)...);
86  return ret;
87  }
88 
92  template <typename keyT, typename valueT>
94  out->connect(in);
95  }
96 
98  inline void connect(ttg::TerminalBase *out, ttg::TerminalBase *in) { out->connect(in); }
99 
106  template <std::size_t outindex, std::size_t inindex, typename producer_tt_ptr, typename successor_tt_ptr>
107  inline void connect(producer_tt_ptr &p, successor_tt_ptr &c) {
108  connect(p->template out<outindex>(), c->template in<inindex>());
109  }
110 
116  template <std::size_t outindex, std::size_t inindex, typename producer_tt_ptr, typename successor_tt_ptr>
117  inline void connect(producer_tt_ptr *p, successor_tt_ptr *c) {
118  connect(p->template out<outindex>(), c->template in<inindex>());
119  }
120 
126  inline void connect(size_t outindex, size_t inindex, TTBase *producer, TTBase *consumer) {
127  connect(producer->out(outindex), consumer->in(inindex));
128  }
129 
136  template <typename keyT, typename... valuesT>
137  inline auto fuse(const Edge<keyT, valuesT> &...args) {
138  using valueT = std::tuple_element_t<0, std::tuple<valuesT...>>; // grab first type
139  return Edge<keyT, valueT>(args...); // This will force all valuesT to be the same
140  }
141 
146  template <typename... inedgesT>
147  inline auto edges(inedgesT &&...args) {
148  return std::make_tuple(std::forward<inedgesT>(args)...);
149  }
150 
151  // clang-format off
156  // clang-format on
157  template <typename keyT, typename valueT, typename output_terminalT, ttg::Runtime Runtime = ttg::ttg_runtime>
158  inline void send(const keyT &key, valueT &&value, ttg::Out<keyT, valueT> &t) {
160  t.send(key, copy_handler(std::forward<valueT>(value)));
161  }
162 
163  // clang-format off
167  // clang-format on
168  template <typename keyT>
169  inline void sendk(const keyT &key, ttg::Out<keyT, void> &t) {
170  t.sendk(key);
171  }
172 
173  // clang-format off
177  // clang-format on
178  template <typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
179  inline void sendv(valueT &&value, ttg::Out<void, valueT> &t) {
181  t.sendv(copy_handler(std::forward<valueT>(value)));
182  }
183 
184  // clang-format off
187  // clang-format on
188  inline void send(ttg::Out<void, void> &t) { t.send(); }
189 
190  // clang-format off
196  // clang-format on
197  template <size_t i, typename keyT, typename valueT, typename... out_keysT, typename... out_valuesT,
199  inline std::enable_if_t<meta::is_none_void_v<keyT, std::decay_t<valueT>>, void> send(
200  const keyT &key, valueT &&value, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
202  std::get<i>(t).send(key, copy_handler(std::forward<valueT>(value)));
203  }
204 
205  // clang-format off
210  // clang-format on
211  template <typename keyT, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
212  inline std::enable_if_t<meta::is_none_void_v<keyT, std::decay_t<valueT>>, void> send(size_t i, const keyT &key,
213  valueT &&value) {
214  // to avoid mixups due to value being a terminal tuple
215  static_assert(!meta::is_output_terminal_v<std::decay_t<valueT>> && !meta::is_output_terminal_tuple_v<std::decay_t<valueT>>, "ttg::send(i, key, x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. sendk<i>(key, x)?");
217  auto *terminal_ptr = detail::get_out_terminal<keyT, valueT>(i, "ttg::send(i, key, value)");
218  terminal_ptr->send(key, copy_handler(std::forward<valueT>(value)));
219  }
220 
221  // clang-format off
227  // clang-format on
228  template <size_t i, typename keyT, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
229  inline std::enable_if_t<meta::is_none_void_v<keyT, std::decay_t<valueT>>, void> send(const keyT &key,
230  valueT &&value) {
231  // to avoid mixups due to value being a terminal tuple
232  static_assert(!meta::is_output_terminal_v<std::decay_t<valueT>> && !meta::is_output_terminal_tuple_v<std::decay_t<valueT>>, "ttg::send<i>(key, x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. sendk<i>(key, x)?");
233  send(i, key, std::forward<valueT>(value));
234  }
235 
236  // clang-format off
241  // clang-format on
242  template <size_t i, typename keyT, typename... out_keysT, typename... out_valuesT>
243  inline std::enable_if_t<!meta::is_void_v<keyT>, void> sendk(const keyT &key,
244  std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
245  std::get<i>(t).sendk(key);
246  }
247 
248  // clang-format off
252  // clang-format on
253  template <typename keyT>
254  inline std::enable_if_t<!meta::is_void_v<keyT>, void> sendk(std::size_t i, const keyT &key) {
255  // to avoid mixups due to key being a terminal tuple
256  static_assert(!meta::is_output_terminal_v<std::decay_t<keyT>> && !meta::is_output_terminal_tuple_v<std::decay_t<keyT>>, "ttg::sendk(i, x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. send<i>(x)?");
257  auto *terminal_ptr = detail::get_out_terminal<keyT, void>(i, "ttg::sendk(i, key)");
258  terminal_ptr->sendk(key);
259  }
260 
261  // clang-format off
266  // clang-format on
267  template <size_t i, typename keyT>
268  inline std::enable_if_t<!meta::is_void_v<keyT>, void> sendk(const keyT &key) {
269  // to avoid mixups due to key being a terminal tuple
270  static_assert(!meta::is_output_terminal_v<std::decay_t<keyT>> && !meta::is_output_terminal_tuple_v<std::decay_t<keyT>>, "ttg::sendk<i>(x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. send<i>(x)?");
271  sendk(i, key);
272  }
273 
274  // clang-format off
279  // clang-format on
280  template <size_t i, typename valueT, typename... out_keysT, typename... out_valuesT,
282  inline std::enable_if_t<!meta::is_void_v<std::decay_t<valueT>>, void> sendv(
283  valueT &&value, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
285  std::get<i>(t).sendv(copy_handler(std::forward<valueT>(value)));
286  }
287 
288  // clang-format off
292  // clang-format on
293  template <typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
294  inline std::enable_if_t<!meta::is_void_v<std::decay_t<valueT>>, void> sendv(std::size_t i, valueT &&value) {
295  // to avoid mixups due to key being a terminal tuple
296  static_assert(!meta::is_output_terminal_v<std::decay_t<valueT>> && !meta::is_output_terminal_tuple_v<std::decay_t<valueT>>, "ttg::sendv(i, x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. send<i>(x)?");
298  auto *terminal_ptr = detail::get_out_terminal<void, valueT>(i, "ttg::sendv(i, value)");
299  terminal_ptr->sendv(copy_handler(std::forward<valueT>(value)));
300  }
301 
302  // clang-format off
307  // clang-format on
308  template <size_t i, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
309  inline std::enable_if_t<!meta::is_void_v<std::decay_t<valueT>>, void> sendv(valueT &&value) {
310  // to avoid mixups due to key being a terminal tuple
311  static_assert(!meta::is_output_terminal_v<std::decay_t<valueT>> && !meta::is_output_terminal_tuple_v<std::decay_t<valueT>>, "ttg::sendv<i>(x) - invalid invocation, x cannot be a terminal or a tuple of terminals; did you mean to call another version of send, e.g. send<i>(x)?");
312  sendv(i, std::forward<valueT>(value));
313  }
314 
315  // clang-format off
319  // clang-format on
320  template <size_t i, typename... out_keysT, typename... out_valuesT>
321  inline void send(std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
322  std::get<i>(t).send();
323  }
324 
325  // clang-format off
328  // clang-format on
329  inline void send(std::size_t i) {
330  auto *terminal_ptr = detail::get_out_terminal<void, void>(i, "ttg::send(i)");
331  terminal_ptr->send();
332  }
333 
334  // clang-format off
338  // clang-format on
339  template <size_t i>
340  inline void send() {
341  send(i);
342  }
343 
344  namespace detail {
345  template <size_t KeyId, size_t i, size_t... I, typename... RangesT, typename valueT, typename... out_keysT,
346  typename... out_valuesT>
347  inline void broadcast(const std::tuple<RangesT...> &keylists, valueT &&value,
348  std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
349  if constexpr (ttg::meta::is_iterable_v<std::tuple_element_t<KeyId, std::tuple<RangesT...>>>) {
350  if (std::distance(std::begin(std::get<KeyId>(keylists)), std::end(std::get<KeyId>(keylists))) > 0) {
351  std::get<i>(t).broadcast(std::get<KeyId>(keylists), value);
352  }
353  } else {
354  std::get<i>(t).broadcast(std::get<KeyId>(keylists), value);
355  }
356  if constexpr (sizeof...(I) > 0) {
357  detail::broadcast<KeyId + 1, I...>(keylists, value, t);
358  }
359  }
360 
361  template <size_t KeyId, size_t i, size_t... I, typename... RangesT, typename valueT>
362  inline void broadcast(const std::tuple<RangesT...> &keylists, valueT &&value) {
363  if constexpr (ttg::meta::is_iterable_v<std::tuple_element_t<KeyId, std::tuple<RangesT...>>>) {
364  if (std::distance(std::begin(std::get<KeyId>(keylists)), std::end(std::get<KeyId>(keylists))) > 0) {
365  using key_t = decltype(*std::begin(std::get<KeyId>(keylists)));
366  auto *terminal_ptr = detail::get_out_terminal<key_t, valueT>(i, "ttg::broadcast(keylists, value)");
367  terminal_ptr->broadcast(std::get<KeyId>(keylists), value);
368  }
369  } else {
370  using key_t = decltype(std::get<KeyId>(keylists));
371  auto *terminal_ptr = detail::get_out_terminal<key_t, valueT>(i, "ttg::broadcast(keylists, value)");
372  terminal_ptr->broadcast(std::get<KeyId>(keylists), value);
373  }
374  if constexpr (sizeof...(I) > 0) {
375  detail::broadcast<KeyId + 1, I...>(keylists, value);
376  }
377  }
378 
379  template <size_t KeyId, size_t i, size_t... I, typename... RangesT, typename... out_keysT, typename... out_valuesT>
380  inline void broadcast(const std::tuple<RangesT...> &keylists, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
381  if constexpr (ttg::meta::is_iterable_v<std::tuple_element_t<KeyId, std::tuple<RangesT...>>>) {
382  if (std::distance(std::begin(std::get<KeyId>(keylists)), std::end(std::get<KeyId>(keylists))) > 0) {
383  std::get<i>(t).broadcast(std::get<KeyId>(keylists));
384  }
385  } else {
386  std::get<i>(t).broadcast(std::get<KeyId>(keylists));
387  }
388  if constexpr (sizeof...(I) > 0) {
389  detail::broadcast<KeyId + 1, I...>(keylists, t);
390  }
391  }
392 
393  template <size_t KeyId, size_t i, size_t... I, typename... RangesT>
394  inline void broadcast(const std::tuple<RangesT...> &keylists) {
395  if constexpr (ttg::meta::is_iterable_v<std::tuple_element_t<KeyId, std::tuple<RangesT...>>>) {
396  if (std::distance(std::begin(std::get<KeyId>(keylists)), std::end(std::get<KeyId>(keylists))) > 0) {
397  using key_t = decltype(*std::begin(std::get<KeyId>(keylists)));
398  auto *terminal_ptr = detail::get_out_terminal<key_t, void>(i, "ttg::broadcast(keylists)");
399  terminal_ptr->broadcast(std::get<KeyId>(keylists));
400  }
401  } else {
402  using key_t = decltype(std::get<KeyId>(keylists));
403  auto *terminal_ptr = detail::get_out_terminal<key_t, void>(i, "ttg::broadcast(keylists)");
404  terminal_ptr->broadcast(std::get<KeyId>(keylists));
405  }
406  if constexpr (sizeof...(I) > 0) {
407  detail::broadcast<KeyId + 1, I...>(keylists);
408  }
409  }
410  } // namespace detail
411 
412  template <size_t i, typename rangeT, typename valueT, typename... out_keysT, typename... out_valuesT,
414  inline void broadcast(const rangeT &keylist, valueT &&value, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
416  std::get<i>(t).broadcast(keylist, copy_handler(std::forward<valueT>(value)));
417  }
418 
419  template <typename rangeT, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
420  inline void broadcast(std::size_t i, const rangeT &keylist, valueT &&value) {
422  using key_t = decltype(*std::begin(keylist));
423  auto *terminal_ptr = detail::get_out_terminal<key_t, valueT>(i, "ttg::broadcast(keylist, value)");
424  terminal_ptr->broadcast(keylist, copy_handler(std::forward<valueT>(value)));
425  }
426 
427  template <size_t i, typename rangeT, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
428  inline void broadcast(const rangeT &keylist, valueT &&value) {
429  broadcast(i, keylist, std::forward<valueT>(value));
430  }
431 
432  template <size_t i, size_t... I, typename... RangesT, typename valueT, typename... out_keysT, typename... out_valuesT,
434  inline void broadcast(const std::tuple<RangesT...> &keylists, valueT &&value,
435  std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
436  static_assert(sizeof...(I) + 1 == sizeof...(RangesT),
437  "Number of selected output terminals must match the number of keylists!");
439  detail::broadcast<0, i, I...>(keylists, copy_handler(std::forward<valueT>(value)), t);
440  }
441 
442  template <size_t i, size_t... I, typename... RangesT, typename valueT, ttg::Runtime Runtime = ttg::ttg_runtime>
443  inline void broadcast(const std::tuple<RangesT...> &keylists, valueT &&value) {
444  static_assert(sizeof...(I) + 1 == sizeof...(RangesT),
445  "Number of selected output terminals must match the number of keylists!");
447  detail::broadcast<0, i, I...>(keylists, copy_handler(std::forward<valueT>(value)));
448  }
449 
450  template <size_t i, typename rangeT, typename... out_keysT, typename... out_valuesT,
452  inline void broadcastk(const rangeT &keylist, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
453  std::get<i>(t).broadcast(keylist);
454  }
455 
456  template <typename rangeT, ttg::Runtime Runtime = ttg::ttg_runtime>
457  inline void broadcastk(std::size_t i, const rangeT &keylist) {
458  using key_t = decltype(*std::begin(keylist));
459  auto *terminal_ptr = detail::get_out_terminal<key_t, void>(i, "ttg::broadcastk(keylist)");
460  terminal_ptr->broadcast(keylist);
461  }
462 
463  template <size_t i, typename rangeT, ttg::Runtime Runtime = ttg::ttg_runtime>
464  inline void broadcastk(const rangeT &keylist) {
465  broadcastk(i, keylist);
466  }
467 
468  template <size_t i, size_t... I, typename... RangesT, typename... out_keysT, typename... out_valuesT,
470  inline void broadcastk(const std::tuple<RangesT...> &keylists, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
471  static_assert(sizeof...(I) + 1 == sizeof...(RangesT),
472  "Number of selected output terminals must match the number of keylists!");
473  detail::broadcast<0, i, I...>(keylists, t);
474  }
475 
476  template <size_t i, size_t... I, typename... RangesT, ttg::Runtime Runtime = ttg::ttg_runtime>
477  inline void broadcastk(const std::tuple<RangesT...> &keylists) {
478  static_assert(sizeof...(I) + 1 == sizeof...(RangesT),
479  "Number of selected output terminals must match the number of keylists!");
480  detail::broadcast<0, i, I...>(keylists);
481  }
482 
483  template <typename keyT, typename out_valueT>
484  inline std::enable_if_t<!meta::is_void_v<keyT>, void> set_size(const keyT &key, const std::size_t size,
486  t.set_size(key, size);
487  }
488 
493  template <size_t i, typename keyT, typename... out_keysT, typename... out_valuesT>
494  inline std::enable_if_t<!meta::is_void_v<keyT>, void> set_size(const keyT &key, const std::size_t size,
495  std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
496  std::get<i>(t).set_size(key, size);
497  }
498 
499  template <typename keyT>
500  inline std::enable_if_t<!meta::is_void_v<keyT>, void> set_size(std::size_t i, const keyT &key,
501  const std::size_t size) {
502  auto *terminal_ptr = detail::get_out_base_terminal<keyT>(i, "ttg::set_size(i, key, size)");
503  terminal_ptr->set_size(size);
504  }
505 
506  template <size_t i, typename keyT>
507  inline std::enable_if_t<!meta::is_void_v<keyT>, void> set_size(const keyT &key, const std::size_t size) {
508  set_size(i, key, size);
509  }
510 
514  template <typename out_keyT, typename out_valueT>
515  inline void set_size(const std::size_t size, ttg::Out<out_keyT, out_valueT> &t) {
516  t.set_size(size);
517  }
518 
523  template <size_t i, typename... out_keysT, typename... out_valuesT>
524  inline void set_size(const std::size_t size, std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
525  std::get<i>(t).set_size(size);
526  }
527 
528  inline void set_size(std::size_t i, const std::size_t size) {
529  auto *terminal_ptr = detail::get_out_base_terminal<void>(i, "ttg::set_size(i, size)");
530  terminal_ptr->set_size(size);
531  }
532 
533  template <std::size_t i>
534  inline void set_size(const std::size_t size) {
535  set_size(i, size);
536  }
537 
542  template <typename keyT, typename out_keyT, typename out_valueT>
543  inline std::enable_if_t<!meta::is_void_v<keyT>, void> finalize(const keyT &key, ttg::Out<out_keyT, out_valueT> &t) {
544  t.finalize(key);
545  }
546 
551  template <size_t i, typename keyT, typename... out_keysT, typename... out_valuesT>
552  inline std::enable_if_t<!meta::is_void_v<keyT>, void> finalize(const keyT &key,
553  std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
554  std::get<i>(t).finalize(key);
555  }
556 
557  template <typename keyT>
558  inline std::enable_if_t<!meta::is_void_v<keyT>, void> finalize(std::size_t i, const keyT &key) {
559  auto *terminal_ptr = detail::get_out_base_terminal<keyT>(i, "ttg::finalize(i, key)");
560  terminal_ptr->finalize(key);
561  }
562 
563  template <std::size_t i, typename keyT>
564  inline std::enable_if_t<!meta::is_void_v<keyT>, void> finalize(const keyT &key) {
565  finalize(i, key);
566  }
567 
570  template <typename out_keyT, typename out_valueT>
572  t.finalize();
573  }
574 
578  template <size_t i, typename... out_keysT, typename... out_valuesT>
579  inline void finalize(std::tuple<ttg::Out<out_keysT, out_valuesT>...> &t) {
580  std::get<i>(t).finalize();
581  }
582 
583  inline void finalize(std::size_t i) {
584  auto *terminal_ptr = detail::get_out_base_terminal<void>(i, "ttg::finalize(i)");
585  terminal_ptr->finalize();
586  }
587 
588  template <std::size_t i>
589  inline void finalize() {
590  finalize(i);
591  }
592 
593 } // namespace ttg
594 
595 #endif // TTG_FUNC_H
Edge is used to connect In and Out terminals.
Definition: edge.h:25
void connect(TerminalBase *in) override
Definition: terminal.h:449
std::enable_if_t< meta::is_void_v< Key > &&!meta::is_void_v< Value >, void > sendv(Value &&value)
Definition: terminal.h:487
std::enable_if_t< meta::is_all_void_v< Key, Value >, void > send()
Definition: terminal.h:514
std::enable_if_t<!meta::is_void_v< Key > &&meta::is_void_v< Value >, void > sendk(const Key &key)
Definition: terminal.h:475
std::enable_if_t<!meta::is_void_v< Key >, void > finalize(const Key &key)
Definition: terminal.h:409
std::enable_if_t<!meta::is_void_v< Key >, void > set_size(const Key &key, std::size_t size)
Definition: terminal.h:393
A base class for all template tasks.
Definition: tt.h:30
ttg::TerminalBase * in(size_t i)
Returns a pointer to the i'th input terminal.
Definition: tt.h:235
static const std::vector< TerminalBase * > * get_outputs_tls_ptr()
Returns this thread's pointer to the vector of output terminals.
Definition: tt.h:229
ttg::TerminalBase * out(size_t i)
Returns a pointer to the i'th output terminal.
Definition: tt.h:241
virtual void connect(TerminalBase *in)=0
auto get_out_terminal(size_t i, const char *func)
Definition: func.h:29
auto get_out_base_terminal(size_t i, const char *func)
Definition: func.h:51
void broadcast(const std::tuple< RangesT... > &keylists, valueT &&value, std::tuple< ttg::Out< out_keysT, out_valuesT >... > &t)
Definition: func.h:347
constexpr bool is_output_terminal_v
detects whether a given type is an output terminal type
Definition: terminal.h:615
constexpr bool is_output_terminal_tuple_v
Definition: terminal.h:629
void make_executable_hook(ttg::World &)
Definition: ttg.h:122
top-level TTG namespace contains runtime-neutral functionality
Definition: keymap.h:8
auto fuse(const Edge< keyT, valuesT > &...args)
Fuse edges into one This allows receiving one data from either of the combined edges.
Definition: func.h:137
void send(const keyT &key, valueT &&value, ttg::Out< keyT, valueT > &t)
Sends a task id and a value to the given output terminal.
Definition: func.h:158
constexpr const ttg::Runtime ttg_runtime
Definition: import.h:20
int size(World world=default_execution_context())
Definition: run.h:89
std::enable_if_t<(std::is_convertible_v< decltype(*(std::declval< TTBasePtrs >))), TTBase & > bool make_graph_executable(TTBasePtrs &&...tts)
Definition: func.h:80
Runtime
Definition: runtimes.h:15
void sendk(const keyT &key, ttg::Out< keyT, void > &t)
Sends a task id (without an accompanying value) to the given output terminal.
Definition: func.h:169
void sendv(valueT &&value, ttg::Out< void, valueT > &t)
Sends a value (without an accompanying task id) to the given output terminal.
Definition: func.h:179
void connect(ttg::Out< keyT, valueT > *out, ttg::In< keyT, valueT > *in)
Connect output terminal to successor input terminal.
Definition: func.h:93
auto make_traverse(TTVisitor &&tt_v=trivial_1param_lambda, InVisitor &&in_v=trivial_1param_lambda, OutVisitor &&out_v=trivial_1param_lambda)
Definition: traverse.h:205
std::enable_if_t<!meta::is_void_v< keyT >, void > set_size(const keyT &key, const std::size_t size, ttg::Out< keyT, out_valueT > &t)
Definition: func.h:484
std::enable_if_t<!meta::is_void_v< keyT >, void > finalize(const keyT &key, ttg::Out< out_keyT, out_valueT > &t)
Finalize streaming input terminals connecting to the given output terminal for tasks identified by ke...
Definition: func.h:543
void broadcast(const rangeT &keylist, valueT &&value, std::tuple< ttg::Out< out_keysT, out_valuesT >... > &t)
Definition: func.h:414
void broadcastk(const rangeT &keylist, std::tuple< ttg::Out< out_keysT, out_valuesT >... > &t)
Definition: func.h:452
auto edges(inedgesT &&...args)
Make a tuple of Edges to pass to.
Definition: func.h:147