File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 40
40
#define LLVM_SUPPORT_BALANCED_PARTITIONING_H
41
41
42
42
#include " raw_ostream.h"
43
- #include " llvm/Support/ThreadPool .h"
43
+ #include " llvm/ADT/ArrayRef .h"
44
44
45
+ #include < atomic>
46
+ #include < condition_variable>
47
+ #include < mutex>
45
48
#include < random>
46
49
#include < vector>
47
50
48
51
namespace llvm {
49
52
53
+ class ThreadPool ;
50
54
// / A function with a set of utility nodes where it is beneficial to order two
51
55
// / functions close together if they have similar utility nodes
52
56
class BPFunctionNode {
@@ -111,7 +115,7 @@ class BalancedPartitioning {
111
115
// / threads, so we need to track how many active threads that could spawn more
112
116
// / threads.
113
117
struct BPThreadPool {
114
- ThreadPool TheThreadPool;
118
+ ThreadPool & TheThreadPool;
115
119
std::mutex mtx;
116
120
std::condition_variable cv;
117
121
// / The number of threads that could spawn more threads
@@ -124,6 +128,7 @@ class BalancedPartitioning {
124
128
// / acceptable for other threads to add more tasks while blocking on this
125
129
// / call.
126
130
void wait ();
131
+ BPThreadPool (ThreadPool &TheThreadPool) : TheThreadPool(TheThreadPool) {}
127
132
};
128
133
129
134
// / Run a recursive bisection of a given list of FunctionNodes
Original file line number Diff line number Diff line change 16
16
#include " llvm/Support/Debug.h"
17
17
#include " llvm/Support/Format.h"
18
18
#include " llvm/Support/FormatVariadic.h"
19
+ #include " llvm/Support/ThreadPool.h"
19
20
20
21
using namespace llvm ;
21
22
#define DEBUG_TYPE " balanced-partitioning"
@@ -82,8 +83,9 @@ void BalancedPartitioning::run(std::vector<BPFunctionNode> &Nodes) const {
82
83
Nodes.size (), Config.SplitDepth , Config.IterationsPerSplit ));
83
84
std::optional<BPThreadPool> TP;
84
85
#if LLVM_ENABLE_THREADS
86
+ ThreadPool TheThreadPool;
85
87
if (Config.TaskSplitDepth > 1 )
86
- TP.emplace ();
88
+ TP.emplace (TheThreadPool );
87
89
#endif
88
90
89
91
// Record the input order
You can’t perform that action at this time.
0 commit comments