diff --git a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp index b450a8334ae4..c4d1bba954cc 100644 --- a/mlir/lib/ExecutionEngine/AsyncRuntime.cpp +++ b/mlir/lib/ExecutionEngine/AsyncRuntime.cpp @@ -59,7 +59,12 @@ mlirAsyncRuntimeAwaitToken(AsyncToken *token) { extern "C" MLIR_ASYNCRUNTIME_EXPORT void mlirAsyncRuntimeExecute(CoroHandle handle, CoroResume resume) { +#if LLVM_ENABLE_THREADS + std::thread thread([handle, resume]() { (*resume)(handle); }); + thread.detach(); +#else (*resume)(handle); +#endif } extern "C" MLIR_ASYNCRUNTIME_EXPORT void diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt index f66d49f2d0ae..407be2f5c684 100644 --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -107,5 +107,6 @@ add_mlir_library(mlir_async_runtime LINK_LIBS PUBLIC mlir_c_runner_utils_static + ${LLVM_PTHREAD_LIB} ) target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)