YOrch 1.0.0
Loading...
Searching...
No Matches
compiled_plan.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <tuple>
5#include <type_traits>
6#include <utility>
7
8#include "../detail/executor/plan_validation.hpp"
9#include "../task_tree.hpp"
10#include "layout.hpp"
11#include "traits.hpp"
12
13namespace yorch {
14
24template <typename... Nodes>
26 using tuple_type = std::tuple<Nodes...>;
27
28 static constexpr std::size_t node_count = sizeof...(Nodes);
29 static constexpr std::size_t max_level = detail::max_level_v<Nodes...>;
30 static constexpr std::size_t no_parent = node_count;
31 static constexpr std::size_t slot_count = node_count;
32
35
37 static constexpr auto levels = detail::compiled_levels_v<Nodes...>;
39 static constexpr auto parent_indices = detail::compiled_parent_indices_v<Nodes...>;
41 static constexpr auto child_counts = detail::compiled_child_layout_v<Nodes...>.counts;
43 static constexpr auto child_offsets = detail::compiled_child_layout_v<Nodes...>.offsets;
45 static constexpr auto child_indices = detail::compiled_child_layout_v<Nodes...>.indices;
47 static constexpr auto slot_indices = detail::compiled_slot_indices_v<Nodes...>;
48
49 template <std::size_t I>
50 using node_type = std::tuple_element_t<I, tuple_type>;
51
52 template <std::size_t I>
54
55 template <std::size_t I>
57
58 template <std::size_t I>
60
61 template <std::size_t I>
63
64 template <std::size_t I>
67
68 template <std::size_t I>
71
72 template <std::size_t I>
73 static constexpr std::size_t level = levels[I];
74
75 template <std::size_t I>
76 static constexpr std::size_t parent_index = parent_indices[I];
77
78 template <std::size_t I>
79 static constexpr std::size_t child_count = child_counts[I];
80
81 template <std::size_t I>
82 static constexpr std::size_t child_offset = child_offsets[I];
83
84 template <std::size_t I>
85 static constexpr std::size_t slot_index = slot_indices[I];
86
87 template <std::size_t I, std::size_t ChildOrdinal>
88 static constexpr std::size_t child_index =
89 child_indices[child_offset<I> + ChildOrdinal];
90
91 template <std::size_t I>
92 [[nodiscard]] constexpr auto& entry() & noexcept {
93 return std::get<I>(nodes);
94 }
95
96 template <std::size_t I>
97 [[nodiscard]] constexpr const auto& entry() const& noexcept {
98 return std::get<I>(nodes);
99 }
100
101 template <std::size_t I>
102 [[nodiscard]] constexpr auto&& entry() && noexcept {
103 return std::get<I>(std::move(nodes));
104 }
105};
106
107template <typename Tree>
109
119template <typename... Nodes>
121 using type = compiled_plan<Nodes...>;
122};
123
132template <typename Tree>
134
145template <typename... Nodes>
146 requires (sizeof...(Nodes) > 0) &&
148[[nodiscard]] constexpr auto compile_plan(task_tree_builder<Nodes...>&& tree) {
150
151 return compiled_plan<Nodes...> {
152 std::move(tree.nodes)
153 };
154}
155
156template <typename... Nodes>
157 requires (sizeof...(Nodes) > 0) &&
158 detail::plannable_plan_nodes<Nodes...>
159[[nodiscard]] constexpr auto compile_plan(const task_tree_builder<Nodes...>& tree) {
161
162 return compiled_plan<Nodes...> {
163 tree.nodes
164 };
165}
166
167} // namespace yorch
typename task_output_for< Task >::type task_output_for_t
Definition traits.hpp:126
constexpr auto compiled_parent_indices_v
Definition layout.hpp:133
output_storage_mode
Describes how a node's logical output is backed at runtime.
Definition policy.hpp:46
consteval void emit_plan_diagnostic()
constexpr std::size_t max_level_v
Definition metadata.hpp:42
constexpr auto compiled_slot_indices_v
Definition layout.hpp:141
constexpr auto compiled_levels_v
Definition layout.hpp:130
typename task_raw_result< Task >::type task_raw_result_t
Convenience alias for a task's raw return type.
Definition traits.hpp:53
slot_logical_policy
Node-local slot semantics inferred from a task's result protocol.
Definition policy.hpp:17
constexpr auto compiled_child_layout_v
Definition layout.hpp:137
constexpr bool is_adapter_descriptor_v
Definition adapters.hpp:63
constexpr auto compile_plan(task_tree_builder< Nodes... > &&tree)
Compiles a populated task_tree_builder into a static plan.
typename compiled_plan_from< std::remove_cvref_t< Tree > >::type compiled_plan_t
Convenience alias for the compiled plan type produced from a tree type.
Static plan compiled from a task_tree_builder.
static constexpr std::size_t child_index
std::tuple< Nodes... > tuple_type
static constexpr std::size_t slot_index
static constexpr std::size_t child_count
static constexpr detail::output_storage_mode output_storage_mode_for
constexpr auto & entry() &noexcept
tuple_type nodes
Stored plan nodes in insertion order.
static constexpr std::size_t node_count
static constexpr auto levels
Node levels in insertion order.
typename node_type< I >::task_type task_type
static constexpr std::size_t parent_index
static constexpr auto child_indices
Flattened direct-child adjacency storage.
constexpr auto && entry() &&noexcept
static constexpr auto slot_indices
Logical output slot assigned to each node by now.
static constexpr auto parent_indices
Direct parent index for each node; the root stores no_parent.
static constexpr detail::slot_logical_policy slot_logical_policy_for
detail::task_raw_result_t< task_type< I > > raw_result_type
static constexpr auto child_offsets
Start offset of each node's child list inside child_indices.
static constexpr std::size_t no_parent
static constexpr std::size_t level
detail::task_output_for_t< task_type< I > > output_type
std::tuple_element_t< I, tuple_type > node_type
static constexpr auto child_counts
Number of direct children for each node.
static constexpr std::size_t child_offset
static constexpr std::size_t slot_count
constexpr const auto & entry() const &noexcept
typename node_type< I >::fanout_policy_type fanout_policy_type
static constexpr std::size_t max_level