[mlir] Convert from Async dialect to LLVM coroutines
authorEugene Zhulenev <ezhulenev@google.com>
Thu, 22 Oct 2020 12:59:05 +0000 (05:59 -0700)
committerEugene Zhulenev <ezhulenev@google.com>
Thu, 22 Oct 2020 13:30:46 +0000 (06:30 -0700)
commitf8fcff5a9d7ee948add3f28382d4ced5710edaaf
treeaf27d3279e2dc07d4bfc2f96af33c3e727d6cbcf
parent41185226f6d80663b4a1064c6f47581ee567d78d
[mlir] Convert from Async dialect to LLVM coroutines

Lower from Async dialect to LLVM by converting async regions attached to `async.execute` operations into LLVM coroutines (https://llvm.org/docs/Coroutines.html):
1. Outline all async regions to functions
2. Add LLVM coro intrinsics to mark coroutine begin/end
3. Use MLIR conversion framework to convert all remaining async types and ops to LLVM + Async runtime function calls

All `async.await` operations inside async regions converted to coroutine suspension points. Await operation outside of a coroutine converted to the blocking wait operations.

Implement simple runtime to support concurrent execution of coroutines.

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D89292
14 files changed:
mlir/include/mlir/Conversion/AsyncToLLVM/AsyncToLLVM.h [new file with mode: 0644]
mlir/include/mlir/Conversion/Passes.h
mlir/include/mlir/Conversion/Passes.td
mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
mlir/include/mlir/ExecutionEngine/AsyncRuntime.h [new file with mode: 0644]
mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp [new file with mode: 0644]
mlir/lib/Conversion/AsyncToLLVM/CMakeLists.txt [new file with mode: 0644]
mlir/lib/Conversion/CMakeLists.txt
mlir/lib/ExecutionEngine/AsyncRuntime.cpp [new file with mode: 0644]
mlir/lib/ExecutionEngine/CMakeLists.txt
mlir/lib/ExecutionEngine/OptUtils.cpp
mlir/test/CMakeLists.txt
mlir/test/Conversion/AsyncToLLVM/convert-to-llvm.mlir [new file with mode: 0644]
mlir/test/mlir-cpu-runner/async.mlir [new file with mode: 0644]