[all-commits] [llvm/llvm-project] 145d2a: Add Async Function to the Async Dialect

yijia1212 via All-commits all-commits at lists.llvm.org
Wed Nov 2 11:34:22 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 145d2a50b86fabe220284ca4a28b67cb8d26f1f1
      https://github.com/llvm/llvm-project/commit/145d2a50b86fabe220284ca4a28b67cb8d26f1f1
  Author: yijiagu <yijiagu at google.com>
  Date:   2022-11-02 (Wed, 02 Nov 2022)

  Changed paths:
    M mlir/include/mlir/Dialect/Async/IR/Async.h
    M mlir/include/mlir/Dialect/Async/IR/AsyncOps.td
    M mlir/lib/Dialect/Async/IR/Async.cpp
    M mlir/test/Dialect/Async/ops.mlir
    M mlir/test/Dialect/Async/verify.mlir
    M utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

  Log Message:
  -----------
  Add Async Function to the Async Dialect

Add Async Function to the Async Dialect

Today `async.execute` operation semantics requires attached region to be executed in a thread managed by the runtime, and always returns an `!async.token` result. We need to model async functions that are not necessarily executed in a runtime-managed threads, but eventually lowered to llvm coroutines.

Example:

```
async.func @foo(%arg0: !async.value<f32>) -> !async.token {
  %0 = async.await %arg0: !async.value<f32>
  "do_something_with_f32"(%0)
  return
}
```

If `arg0` is available this function will be executed in the caller thread. If it's not available it will be suspended and resumed later later on a thread managed by the async runtime. Currently this is not representable with `async.execute` operations.

The longer term goal is to make async dialect more like https://github.com/lewissbaker/cppcoro to be able to represent structured host concurrency in MLIR.

(1) Add async.func, async.call, and async.return operations in Async Dialect

Reviewed By: ezhulenev, rriddle

Differential Revision: https://reviews.llvm.org/D137189




More information about the All-commits mailing list