Skip to content

Commit b16f632

Browse files
committed
[mlir] Link with pthreads in AsyncRuntime
AsyncRuntime must be explicitly linked with LLVM pthreads Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D89983
1 parent 9f4b888 commit b16f632

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

mlir/lib/ExecutionEngine/AsyncRuntime.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ mlirAsyncRuntimeAwaitToken(AsyncToken *token) {
5959

6060
extern "C" MLIR_ASYNCRUNTIME_EXPORT void
6161
mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) {
62+
#if LLVM_ENABLE_THREADS
63+
std::thread thread([handle, resume]() { (*resume)(handle); });
64+
thread.detach();
65+
#else
6266
(*resume)(handle);
67+
#endif
6368
}
6469

6570
extern "C" MLIR_ASYNCRUNTIME_EXPORT void

mlir/lib/ExecutionEngine/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,6 @@ add_mlir_library(mlir_async_runtime
107107

108108
LINK_LIBS PUBLIC
109109
mlir_c_runner_utils_static
110+
${LLVM_PTHREAD_LIB}
110111
)
111112
target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)

0 commit comments

Comments
 (0)