[PATCH] D78832: [Support] Fix fragile ThreadPool test
Alexandre Ganea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 24 15:12:08 PDT 2020
aganea created this revision.
aganea added reviewers: rnk, mehdi_amini, MaskRay.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The test `ThreadPoolTest.AllThreads_UseAllRessources` occasionally fails on the bots: http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/32015/steps/test-check-all/logs/FAIL%3A%20LLVM-Unit%3A%3AThreadPoolTest.AllThreads_UseAllRessources
This is because jobs were executed too fast on the first CPU socket, and never manage to reach the second CPU socket.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78832
Files:
llvm/unittests/Support/ThreadPool.cpp
Index: llvm/unittests/Support/ThreadPool.cpp
===================================================================
--- llvm/unittests/Support/ThreadPool.cpp
+++ llvm/unittests/Support/ThreadPool.cpp
@@ -71,7 +71,7 @@
void SetUp() override { MainThreadReady = false; }
- void TestAllThreads(ThreadPoolStrategy S);
+ void RunOnAllSockets(ThreadPoolStrategy S);
std::condition_variable WaitMainThread;
std::mutex WaitMainThreadMutex;
@@ -169,7 +169,7 @@
#if LLVM_ENABLE_THREADS == 1
-void ThreadPoolTest::TestAllThreads(ThreadPoolStrategy S) {
+void ThreadPoolTest::RunOnAllSockets(ThreadPoolStrategy S) {
// FIXME: Skip these tests on non-Windows because multi-socket system were not
// tested on Unix yet, and llvm::get_thread_affinity_mask() isn't implemented
// for Unix.
@@ -181,9 +181,10 @@
std::mutex Lock;
{
ThreadPool Pool(S);
- for (size_t I = 0; I < 10000; ++I) {
+ for (size_t I = 0; I < S.compute_thread_count() * 4; ++I) {
Pool.async([&] {
waitForMainThread();
+ std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::lock_guard<std::mutex> Guard(Lock);
auto Mask = llvm::get_thread_affinity_mask();
ThreadsUsed.insert(Mask);
@@ -197,12 +198,12 @@
TEST_F(ThreadPoolTest, AllThreads_UseAllRessources) {
CHECK_UNSUPPORTED();
- TestAllThreads({});
+ RunOnAllSockets({});
}
TEST_F(ThreadPoolTest, AllThreads_OneThreadPerCore) {
CHECK_UNSUPPORTED();
- TestAllThreads(llvm::heavyweight_hardware_concurrency());
+ RunOnAllSockets(llvm::heavyweight_hardware_concurrency());
}
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78832.259999.patch
Type: text/x-patch
Size: 1614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200424/ae1631f2/attachment.bin>
More information about the llvm-commits
mailing list