Skip to content

Commit 9edcedf

Browse files
committed
[mlir] AsyncRuntime: disable threading until test flakiness is fixed
ExecutionEngine/LLJIT do not run globals destructors in loaded dynamic libraries when destroyed, and threads managed by ThreadPool can race with program termination, and it leads to segfaults. TODO: Re-enable threading after fixing a problem with destructors, or removing static globals from dynamic library. Differential Revision: https://reviews.llvm.org/D92368
1 parent 2b84efa commit 9edcedf

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

mlir/lib/ExecutionEngine/AsyncRuntime.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include <thread>
2525
#include <vector>
2626

27-
#include "llvm/Support/ThreadPool.h"
28-
2927
//===----------------------------------------------------------------------===//
3028
// Async runtime API.
3129
//===----------------------------------------------------------------------===//
@@ -45,7 +43,6 @@ class AsyncRuntime {
4543
AsyncRuntime() : numRefCountedObjects(0) {}
4644

4745
~AsyncRuntime() {
48-
threadPool.wait(); // wait for the completion of all async tasks
4946
assert(getNumRefCountedObjects() == 0 &&
5047
"all ref counted objects must be destroyed");
5148
}
@@ -54,8 +51,6 @@ class AsyncRuntime {
5451
return numRefCountedObjects.load(std::memory_order_relaxed);
5552
}
5653

57-
llvm::ThreadPool &getThreadPool() { return threadPool; }
58-
5954
private:
6055
friend class RefCounted;
6156

@@ -69,8 +64,6 @@ class AsyncRuntime {
6964
}
7065

7166
std::atomic<int32_t> numRefCountedObjects;
72-
73-
llvm::ThreadPool threadPool;
7467
};
7568

7669
// Returns the default per-process instance of an async runtime.
@@ -241,8 +234,7 @@ extern "C" void mlirAsyncRuntimeAwaitAllInGroup(AsyncGroup *group) {
241234
}
242235

243236
extern "C" void mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
244-
auto *runtime = getDefaultAsyncRuntimeInstance();
245-
runtime->getThreadPool().async([handle, resume]() { (*resume)(handle); });
237+
(*resume)(handle);
246238
}
247239

248240
extern "C" void mlirAsyncRuntimeAwaitTokenAndExecute(AsyncToken *token,

0 commit comments

Comments
 (0)