dispenso 1.5.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:
77 template <typename G>
78 void operator()(dispenso::ConcurrentTaskSet& tasks, const G& graph, bool wait = true);
79
80 private:
81 std::vector<const Node*> startNodes_;
82};
83
87class ForwardPropagator : public ::detail::ExecutorBase {
88 public:
93 template <class G>
94 void operator()(const G& graph);
95
96 private:
97 template <class N>
98 void propagateIncompleteStateBidirectionally();
99
100 std::vector<const Node*> nodesToVisit_;
101 std::vector<const Node*> nodesToVisitNext_;
102 std::unordered_set<const Node*> visited_;
103 std::unordered_set<const std::vector<const BiPropNode*>*> groups_;
104};
105} // namespace dispenso