dispenso 1.6.0
A library for task parallelism
Loading...
Searching...
No Matches
graph_executor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
14#pragma once
16#include <dispenso/detail/graph_executor_impl.h>
17#include <dispenso/graph.h>
19#include <dispenso/platform.h>
20
21namespace dispenso {
25class SingleThreadExecutor : public detail::ExecutorBase {
26 public:
32 template <typename G>
33 void operator()(const G& graph);
34
35 private:
36 std::vector<const Node*> nodesToExecute_;
37 std::vector<const Node*> nodesToExecuteNext_;
38};
43class ParallelForExecutor : public detail::ExecutorBase {
44 public:
51 template <typename TaskSetT, typename G>
52 void operator()(TaskSetT& taskSet, const G& graph);
53
54 private:
55 // Per-thread state for collecting ready nodes locally during parallel_for
56 struct ThreadLocalCollector {
57 std::vector<const Node*> readyNodes;
58 };
59
60 std::vector<const Node*> nodesToExecute_;
61 std::vector<const Node*> nodesToExecuteNext_;
62 std::vector<ThreadLocalCollector> threadStates_;
63};
68class ConcurrentTaskSetExecutor : public detail::ExecutorBase {
69 public:
80 template <typename G>
81 void operator()(
83 const G& graph,
84 bool wait = true,
85 float poolRecursiveLoadFactor = 3.0f);
86
87 private:
88 std::vector<const Node*> startNodes_;
89};
90
94class ForwardPropagator : public detail::ExecutorBase {
95 public:
100 template <class G>
101 void operator()(const G& graph);
102
103 private:
104 template <class N>
105 void propagateIncompleteStateBidirectionally();
106
107 std::vector<const Node*> nodesToVisit_;
108 std::vector<const Node*> nodesToVisitNext_;
109 std::unordered_set<const Node*> visited_;
110 std::unordered_set<const std::vector<const BiPropNode*>*> groups_;
111};
112} // namespace dispenso