Beaver. MLIR. Dialect. Async
(beaver v0.4.8)
Copy Markdown
Summary
Functions
Return op name async.add_to_group as a bitstring.
async.add_to_group - adds an async token or value to the group
Return op name async.await as a bitstring.
async.await - waits for the argument to become ready
Return op name async.await_all as a bitstring.
async.await_all - waits for the all async tokens or values in the group to become ready
Return op name async.call as a bitstring.
async.call - async call operation
Return op name async.coro.begin as a bitstring.
async.coro.begin - returns a handle to the coroutine
Return op name async.coro.end as a bitstring.
async.coro.end - marks the end of the coroutine in the suspend block
Return op name async.coro.free as a bitstring.
async.coro.free - deallocates the coroutine frame
Return op name async.coro.id as a bitstring.
async.coro.id - returns a switched-resume coroutine identifier
Return op name async.coro.save as a bitstring.
async.coro.save - saves the coroutine state
Return op name async.coro.suspend as a bitstring.
async.coro.suspend - suspends the coroutine
Return op name async.create_group as a bitstring.
async.create_group - creates an empty async group
Return op name async.execute as a bitstring.
async.execute - Asynchronous execute operation
Return op name async.func as a bitstring.
async.func - async function operation
Return op name async.return as a bitstring.
async.return - Async function return operation
Return op name async.runtime.add_ref as a bitstring.
async.runtime.add_ref - adds a reference to async value
Return op name async.runtime.add_to_group as a bitstring.
async.runtime.add_to_group - adds an async token or value to the group
Return op name async.runtime.await as a bitstring.
async.runtime.await - blocks the caller thread until the operand becomes available
Return op name async.runtime.await_and_resume as a bitstring.
async.runtime.await_and_resume - awaits the async operand and resumes the coroutine
Return op name async.runtime.create as a bitstring.
async.runtime.create - creates an async runtime token or value
Return op name async.runtime.create_group as a bitstring.
async.runtime.create_group - creates an async runtime group
Return op name async.runtime.drop_ref as a bitstring.
async.runtime.drop_ref - drops a reference to async value
Return op name async.runtime.is_error as a bitstring.
async.runtime.is_error - returns true if token, value or group is in error state
Return op name async.runtime.load as a bitstring.
async.runtime.load - loads the value from the runtime async.value
Return op name async.runtime.num_worker_threads as a bitstring.
async.runtime.num_worker_threads - gets the number of threads in the threadpool from the runtime
Return op name async.runtime.resume as a bitstring.
async.runtime.resume - resumes the coroutine on a thread managed by the runtime
Return op name async.runtime.set_available as a bitstring.
async.runtime.set_available - switches token or value to available state
Return op name async.runtime.set_error as a bitstring.
async.runtime.set_error - switches token or value to error state
Return op name async.runtime.store as a bitstring.
async.runtime.store - stores the value into the runtime async.value
Return op name async.yield as a bitstring.
async.yield - terminator for Async execute operation
Functions
Return op name async.add_to_group as a bitstring.
async.add_to_group - adds an async token or value to the group
This op has support for result type inference.
Operands
operand- Single,Async_AnyValueOrTokenType, async value type or async token typegroup- Single,Async_GroupType, async group type
Results
rank- Single,Index, index
Description
The async.add_to_group adds an async token or value to the async group.
Returns the rank of the added element in the group. This rank is fixed
for the group lifetime.
Example:
%0 = async.create_group %size : !async.group
%1 = ... : !async.token
%2 = async.add_to_group %1, %0 : !async.token
Return op name async.await as a bitstring.
async.await - waits for the argument to become ready
Operands
operand- Single,Async_AnyValueOrTokenType, async value type or async token type
Results
result- Optional,AnyType, any non-token type
Description
The async.await operation waits until the argument becomes ready, and for
the async.value arguments it unwraps the underlying value
Example:
%0 = ... : !async.token
async.await %0 : !async.token
%1 = ... : !async.value<f32>
%2 = async.await %1 : !async.value<f32>
Return op name async.await_all as a bitstring.
async.await_all - waits for the all async tokens or values in the group to become ready
Operands
operand- Single,Async_GroupType, async group type
Description
The async.await_all operation waits until all the tokens or values in the
group become ready.
Example:
%0 = async.create_group %size : !async.group
%1 = ... : !async.token
%2 = async.add_to_group %1, %0 : !async.token
%3 = ... : !async.token
%4 = async.add_to_group %2, %0 : !async.token
async.await_all %0
Return op name async.call as a bitstring.
async.call - async call operation
Attributes
callee- Single,FlatSymbolRefAttr, flat symbol reference attributearg_attrs- Optional,DictArrayAttr, Array of dictionary attributesres_attrs- Optional,DictArrayAttr, Array of dictionary attributes
Operands
operands- Variadic,AnyType, variadic of any non-token type
Results
- anonymous - Variadic,
Async_AnyValueOrTokenType, variadic of async value type or async token type
Description
The async.call operation represents a direct call to an async function
that is within the same symbol scope as the call. The operands and result
types of the call must match the specified async function type. The callee
is encoded as a symbol reference attribute named "callee".
Example:
%2 = async.call @my_add(%0, %1) : (f32, f32) -> !async.value<f32>
Return op name async.coro.begin as a bitstring.
async.coro.begin - returns a handle to the coroutine
This op has support for result type inference.
Operands
id- Single,Async_CoroIdType, switched-resume coroutine identifier
Results
handle- Single,Async_CoroHandleType, coroutine handle
Description
The async.coro.begin allocates a coroutine frame and returns a handle to
the coroutine.
Return op name async.coro.end as a bitstring.
async.coro.end - marks the end of the coroutine in the suspend block
Operands
handle- Single,Async_CoroHandleType, coroutine handle
Description
The async.coro.end marks the point where a coroutine needs to return
control back to the caller if it is not an initial invocation of the
coroutine. In the start part of the coroutine it is no-op.
Return op name async.coro.free as a bitstring.
async.coro.free - deallocates the coroutine frame
Operands
id- Single,Async_CoroIdType, switched-resume coroutine identifierhandle- Single,Async_CoroHandleType, coroutine handle
Description
The async.coro.free deallocates the coroutine frame created by the
async.coro.begin operation.
Return op name async.coro.id as a bitstring.
async.coro.id - returns a switched-resume coroutine identifier
This op has support for result type inference.
Results
id- Single,Async_CoroIdType, switched-resume coroutine identifier
Description
The async.coro.id returns a switched-resume coroutine identifier.
Return op name async.coro.save as a bitstring.
async.coro.save - saves the coroutine state
This op has support for result type inference.
Operands
handle- Single,Async_CoroHandleType, coroutine handle
Results
state- Single,Async_CoroStateType, saved coroutine state
Description
The async.coro.saves saves the coroutine state.
Return op name async.coro.suspend as a bitstring.
async.coro.suspend - suspends the coroutine
Operands
state- Single,Async_CoroStateType, saved coroutine state
Description
The async.coro.suspend suspends the coroutine and transfers control to the
suspend successor. If suspended coroutine later resumed it will transfer
control to the resume successor. If it is destroyed it will transfer
control to the the cleanup successor.
In switched-resume lowering coroutine can be already in resumed state when
suspend operation is called, in this case control will be transferred to the
resume successor skipping the suspend successor.
Return op name async.create_group as a bitstring.
async.create_group - creates an empty async group
This op has support for result type inference.
Operands
size- Single,Index, index
Results
result- Single,Async_GroupType, async group type
Description
The async.create_group allocates an empty async group. Async tokens or
values can be added to this group later. The size of the group must be
specified at construction time, and await_all operation will first
wait until the number of added tokens or values reaches the group size.
Example:
%size = ... : index
%group = async.create_group %size : !async.group
...
async.await_all %group
Return op name async.execute as a bitstring.
async.execute - Asynchronous execute operation
Operands
dependencies- Variadic,Async_TokenType, variadic of async token typebodyOperands- Variadic,Async_AnyValueOrTokenType, variadic of async value type or async token type
Results
token- Single,Async_TokenType, async token typebodyResults- Variadic,Async_ValueType, variadic of async value type
Description
The body region attached to the async.execute operation semantically
can be executed concurrently with the successor operation. In the followup
example "compute0" can be executed concurrently with "compute1".
The actual concurrency semantics depends on the dialect lowering to the executable format. Fully sequential execution ("compute0" completes before "compute1" starts) is a completely legal execution.
Because concurrent execution is not guaranteed, it is illegal to create an
implicit dependency from "compute1" to "compute0" (e.g. via shared global
state). All dependencies must be made explicit with async execute arguments
(async.token or async.value).
async.execute operation takes async.token dependencies and async.value
operands separately, and starts execution of the attached body region only
when all tokens and values become ready.
Example:
%dependency = ... : !async.token
%value = ... : !async.value<f32>
%token, %results =
async.execute [%dependency](%value as %unwrapped: !async.value<f32>)
-> !async.value<!some.type>
{
%0 = "compute0"(%unwrapped): (f32) -> !some.type
async.yield %0 : !some.type
}
%1 = "compute1"(...) : !some.typeIn the example above asynchronous execution starts only after dependency token and value argument become ready. Unwrapped value passed to the attached body region as an %unwrapped value of f32 type.
Return op name async.func as a bitstring.
async.func - async function operation
Attributes
sym_name- Single,SymbolNameAttr, string attributefunction_type- Single, anonymous/composite constraint, type attribute of function typesym_visibility- Optional,StrAttr, string attributearg_attrs- Optional,DictArrayAttr, Array of dictionary attributesres_attrs- Optional,DictArrayAttr, Array of dictionary attributes
Description
An async function is like a normal function, but supports non-blocking await. Internally, async function is lowered to the LLVM coroutinue with async runtime intrinsic. It can return an async token and/or async values. The token represents the execution state of async function and can be used when users want to express dependencies on some side effects, e.g., the token becomes available once every thing in the func body is executed.
Example:
// Async function can't return void, it always must be some async thing.
async.func @async.0() -> !async.token {
return
}
// Function returns only async value.
async.func @async.1() -> !async.value<i32> {
%0 = arith.constant 42 : i32
return %0 : i32
}
// Implicit token can be added to return types.
async.func @async.2() -> !async.token, !async.value<i32> {
%0 = arith.constant 42 : i32
return %0 : i32
}
Return op name async.return as a bitstring.
async.return - Async function return operation
Operands
operands- Variadic,AnyType, variadic of any non-token type
Description
The async.return is a special terminator operation for Async function.
Example:
async.func @foo() : !async.token {
return
}
Return op name async.runtime.add_ref as a bitstring.
async.runtime.add_ref - adds a reference to async value
Attributes
count- Single,I64Attr, 64-bit signless integer attribute whose value is positive
Operands
operand- Single,Async_AnyAsyncType, async value type or async token type or async group type
Description
The async.runtime.add_ref operation adds a reference(s) to async value
(token, value or group).
Return op name async.runtime.add_to_group as a bitstring.
async.runtime.add_to_group - adds an async token or value to the group
This op has support for result type inference.
Operands
operand- Single,Async_AnyValueOrTokenType, async value type or async token typegroup- Single,Async_GroupType, async group type
Results
rank- Single,Index, index
Description
The async.runtime.add_to_group adds an async token or value to the async
group. Returns the rank of the added element in the group.
Return op name async.runtime.await as a bitstring.
async.runtime.await - blocks the caller thread until the operand becomes available
Operands
operand- Single,Async_AnyAsyncType, async value type or async token type or async group type
Description
The async.runtime.await operation blocks the caller thread until the
operand becomes available or error.
Return op name async.runtime.await_and_resume as a bitstring.
async.runtime.await_and_resume - awaits the async operand and resumes the coroutine
Operands
operand- Single,Async_AnyAsyncType, async value type or async token type or async group typehandle- Single,Async_CoroHandleType, coroutine handle
Description
The async.runtime.await_and_resume operation awaits for the operand to
become available or error and resumes the coroutine on a thread managed by
the runtime.
Return op name async.runtime.create as a bitstring.
async.runtime.create - creates an async runtime token or value
Results
result- Single,Async_AnyValueOrTokenType, async value type or async token type
Description
The async.runtime.create operation creates an async dialect token or
value. Tokens and values are created in the non-ready state.
Return op name async.runtime.create_group as a bitstring.
async.runtime.create_group - creates an async runtime group
This op has support for result type inference.
Operands
size- Single,Index, index
Results
result- Single,Async_GroupType, async group type
Description
The async.runtime.create_group operation creates an async dialect group
of the given size. Group created in the empty state.
Return op name async.runtime.drop_ref as a bitstring.
async.runtime.drop_ref - drops a reference to async value
Attributes
count- Single,I64Attr, 64-bit signless integer attribute whose value is positive
Operands
operand- Single,Async_AnyAsyncType, async value type or async token type or async group type
Description
The async.runtime.drop_ref operation drops a reference(s) to async value
(token, value or group).
Return op name async.runtime.is_error as a bitstring.
async.runtime.is_error - returns true if token, value or group is in error state
This op has support for result type inference.
Operands
operand- Single,Async_AnyAsyncType, async value type or async token type or async group type
Results
is_error- Single,I1, 1-bit signless integer
Description
The async.runtime.is_error operation returns true if the token, value or
group (any of the async runtime values) is in the error state. It is the
caller responsibility to check error state after the call to await or
resuming after await_and_resume.
Return op name async.runtime.load as a bitstring.
async.runtime.load - loads the value from the runtime async.value
This op has support for result type inference.
Operands
storage- Single,Async_ValueType, async value type
Results
result- Single,AnyType, any non-token type
Description
The async.runtime.load operation loads the value from the runtime
async.value storage.
Return op name async.runtime.num_worker_threads as a bitstring.
async.runtime.num_worker_threads - gets the number of threads in the threadpool from the runtime
This op has support for result type inference.
Results
result- Single,Index, index
Description
The async.runtime.num_worker_threads operation gets the number of threads
in the threadpool from the runtime.
Return op name async.runtime.resume as a bitstring.
async.runtime.resume - resumes the coroutine on a thread managed by the runtime
Operands
handle- Single,Async_CoroHandleType, coroutine handle
Description
The async.runtime.resume operation resumes the coroutine on a thread
managed by the runtime.
Return op name async.runtime.set_available as a bitstring.
async.runtime.set_available - switches token or value to available state
Operands
operand- Single,Async_AnyValueOrTokenType, async value type or async token type
Description
The async.runtime.set_available operation switches async token or value
state to available.
Return op name async.runtime.set_error as a bitstring.
async.runtime.set_error - switches token or value to error state
Operands
operand- Single,Async_AnyValueOrTokenType, async value type or async token type
Description
The async.runtime.set_error operation switches async token or value
state to error.
Return op name async.runtime.store as a bitstring.
async.runtime.store - stores the value into the runtime async.value
Operands
value- Single,AnyType, any non-token typestorage- Single,Async_ValueType, async value type
Description
The async.runtime.store operation stores the value into the runtime
async.value storage.
Return op name async.yield as a bitstring.
async.yield - terminator for Async execute operation
Operands
operands- Variadic,AnyType, variadic of any non-token type
Description
The async.yield is a special terminator operation for the block inside
async.execute operation.