Skip to main content

Mojo struct

WorkIterator

struct WorkIterator[num_stages: Int, cluster_shape: IndexList[3, element_type=DType.uint32], rasterize_order: RasterOrder, block_swizzle_size: Int]

Per-warp work iterator that owns work_info and pipeline state.

Each warp creates its own WorkIterator which internally manages both the current work item and the CLC pipeline consumer state. Throttle pipeline is obtained from the scheduler.

Usage: var work_iter = scheduler.work_iterator() for current in work_iter: scheduler.throttle_signal(ctx.is_first_cta_in_cluster) do_work(current)

Fields

  • scheduler (WorkIterator[num_stages, cluster_shape, rasterize_order, block_swizzle_size].SchedulerType):
  • work_info (WorkInfo):
  • consumer_state (PipelineState[num_stages]):
  • needs_fetch (Bool):

Implemented traits

AnyType, Copyable, ImplicitlyDestructible, Iterable, Iterator, Movable, RegisterPassable

comptime members

Element

comptime Element = WorkInfo

IteratorType

comptime IteratorType[iterable_mut: Bool, //, iterable_origin: Origin[mut=iterable_mut]] = WorkIterator[num_stages, cluster_shape, rasterize_order, block_swizzle_size]

Parameters

  • iterable_mut (Bool):
  • iterable_origin (Origin):

SchedulerType

comptime SchedulerType = TileScheduler[num_stages, cluster_shape, rasterize_order, block_swizzle_size]

Methods

__init__

__init__(scheduler: TileScheduler[num_stages, cluster_shape, rasterize_order, block_swizzle_size], work_info: WorkInfo) -> Self

Create work iterator with initial work_info.

__iter__

__iter__(ref self) -> Self

__next__

__next__(mut self) -> WorkInfo

Return current work item, deferring fetch to next call.

On the first call, returns the initial work_info without fetching. On subsequent calls, fetches next work (deferred from previous iteration) before returning. This allows the caller to signal throttle between iterations, avoiding deadlock with the scheduler warp.

Returns:

WorkInfo Raises:

StopIteration: When there is no more work to process.

Was this page helpful?