Synchronization

The synchronization part of IR APIs.

tvm.aipu.script.ir.synchronization.barrier()

All work-items in a work-group executing the kernel on a processor must execute this function before any are allowed to continue execution beyond the barrier. The barrier function will queue a memory fence to ensure correct ordering of memory operations to private memory and wait for events to finish between TECs.

Examples

S.barrier()

See Also

  • Zhouyi Compass OpenCL Programming Guide: barrier

tvm.aipu.script.ir.synchronization.alloc_events(count)

Allocates the specified number of events. The total number of events that the whole DSL program can allocate up to the concrete Zhouyi NPU target.

Parameters

countint

The number of events you want to allocate for this invocation.

Returns

retUnion[PrimExpr, Tuple[PrimExpr]]

The events that already allocated.

Examples

ev0, ev1, ev2, ev3 = S.alloc_events(4)

See Also

tvm.aipu.script.ir.synchronization.wait_events(*events)

Blocks the current DSL program until all specified events are occurred.

Parameters

eventsTuple[PrimExpr]

The events need to be waited.

Examples

S.wait_events(ev0)
S.wait_events(ev0, ev1, ev2)

See Also

tvm.aipu.script.ir.synchronization.free_events(*events)

Release the allocated events, will call S.wait_events first automatically.

Parameters

eventsTuple[PrimExpr]

The events need to be released.

Examples

S.free_events(ev0)
S.free_events(ev0, ev1, ev2)

See Also