[PATCH] D152390: [InstrProf] Fix BalancedPartitioning when threads are disabled
Ellis Hoag via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 7 12:04:56 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1d935ece346: [InstrProf] Fix BalancedPartitioning when threads are disabled (authored by ellis).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152390/new/
https://reviews.llvm.org/D152390
Files:
llvm/lib/Support/BalancedPartitioning.cpp
llvm/test/tools/llvm-profdata/show-order.proftext
llvm/unittests/Support/BalancedPartitioningTest.cpp
Index: llvm/unittests/Support/BalancedPartitioningTest.cpp
===================================================================
--- llvm/unittests/Support/BalancedPartitioningTest.cpp
+++ llvm/unittests/Support/BalancedPartitioningTest.cpp
@@ -17,13 +17,6 @@
using testing::UnorderedElementsAre;
using testing::UnorderedElementsAreArray;
-// PR63168: Balanced Partitioning tests currently hang on ARM.
-#if defined(__arm__)
-#define SKIP_UNSUPPORTED_PLATFORM GTEST_SKIP()
-#else
-#define SKIP_UNSUPPORTED_PLATFORM do { } while(0)
-#endif
-
namespace llvm {
void PrintTo(const BPFunctionNode &Node, std::ostream *OS) {
@@ -47,7 +40,6 @@
};
TEST_F(BalancedPartitioningTest, Basic) {
- SKIP_UNSUPPORTED_PLATFORM;
std::vector<BPFunctionNode> Nodes = {
BPFunctionNode(0, {1, 2}), BPFunctionNode(2, {3, 4}),
BPFunctionNode(1, {1, 2}), BPFunctionNode(3, {3, 4}),
@@ -67,7 +59,6 @@
}
TEST_F(BalancedPartitioningTest, Large) {
- SKIP_UNSUPPORTED_PLATFORM;
const int ProblemSize = 1000;
std::vector<BPFunctionNode::UtilityNodeT> AllUNs;
for (int i = 0; i < ProblemSize; i++)
@@ -94,7 +85,6 @@
}
TEST_F(BalancedPartitioningTest, MoveGain) {
- SKIP_UNSUPPORTED_PLATFORM;
BalancedPartitioning::SignaturesT Signatures = {
{10, 10, 10.f, 0.f, true}, // 0
{10, 10, 0.f, 10.f, true}, // 1
Index: llvm/test/tools/llvm-profdata/show-order.proftext
===================================================================
--- llvm/test/tools/llvm-profdata/show-order.proftext
+++ llvm/test/tools/llvm-profdata/show-order.proftext
@@ -1,6 +1,4 @@
# RUN: llvm-profdata order %s | FileCheck %s
-# PR63168: Balanced Partitioning tests currently hang on ARM.
-# UNSUPPORTED: target=arm{{.*}}
# CHECK: a
# CHECK: b
Index: llvm/lib/Support/BalancedPartitioning.cpp
===================================================================
--- llvm/lib/Support/BalancedPartitioning.cpp
+++ llvm/lib/Support/BalancedPartitioning.cpp
@@ -27,6 +27,7 @@
template <typename Func>
void BalancedPartitioning::BPThreadPool::async(Func &&F) {
+#if LLVM_ENABLE_THREADS
// This new thread could spawn more threads, so mark it as active
++NumActiveThreads;
TheThreadPool.async([=]() {
@@ -44,9 +45,13 @@
cv.notify_one();
}
});
+#else
+ llvm_unreachable("threads are disabled");
+#endif
}
void BalancedPartitioning::BPThreadPool::wait() {
+#if LLVM_ENABLE_THREADS
// TODO: We could remove the mutex and condition variable and use
// std::atomic::wait() instead, but that isn't available until C++20
{
@@ -56,6 +61,9 @@
}
// Now we can call ThreadPool::wait() since all tasks have been submitted
TheThreadPool.wait();
+#else
+ llvm_unreachable("threads are disabled");
+#endif
}
BalancedPartitioning::BalancedPartitioning(
@@ -73,8 +81,10 @@
"Partitioning %d nodes using depth %d and %d iterations per split\n",
Nodes.size(), Config.SplitDepth, Config.IterationsPerSplit));
std::optional<BPThreadPool> TP;
+#if LLVM_ENABLE_THREADS
if (Config.TaskSplitDepth > 1)
TP.emplace();
+#endif
// Record the input order
for (unsigned I = 0; I < Nodes.size(); I++)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152390.529398.patch
Type: text/x-patch
Size: 3168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230607/788fbe0b/attachment.bin>
More information about the llvm-commits
mailing list