Module Uop.Opt

Schedule options attached to kernel metadata.

Each variant except Nolocals carries an axis — the schedule axis it applies to — and most carry an amount interpreted by the scheduler (tile width, unroll factor, lane count, padding target).

Note. The variant declaration order is load-bearing: total ordering over t uses Stdlib.compare, which reads the constructor ordinal first.

type t =
  1. | Tc of {
    1. axis : int;
    2. tc_select : int;
    3. tc_opt : int;
    4. use_tc : int;
    }
    (*

    Tensor-core configuration on axis.

    *)
  2. | Upcast of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Vectorize axis by amount lanes.

    *)
  3. | Unroll of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Unroll axis by amount iterations.

    *)
  4. | Local of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Split axis into workgroup-shared tiles of amount.

    *)
  5. | Thread of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Split axis into per-thread tiles of amount.

    *)
  6. | Group of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Split axis into workgroups of amount.

    *)
  7. | Grouptop of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Like Group but takes the top portion of axis.

    *)
  8. | Nolocals
    (*

    Disable local memory for this kernel.

    *)
  9. | Padto of {
    1. axis : int;
    2. amount : int;
    }
    (*

    Pad axis to a multiple of amount.

    *)
  10. | Swap of {
    1. axis : int;
    2. with_axis : int;
    }
    (*

    Swap axis and with_axis in the schedule.

    *)

The type for schedule options.

val to_string : t -> string

to_string opt is a compact textual form of opt (e.g. "UPCAST:0:4").

val pp : Stdlib.Format.formatter -> t -> unit

pp formats options with to_string.

val axis : t -> int option

axis opt is the axis carried by opt, or None for Nolocals.

val amount : t -> int option

amount opt is the amount carried by opt, or None for Tc, Swap, and Nolocals.

val with_amount : t -> int -> t

with_amount opt n is opt with its amount replaced by n. Returns opt unchanged for Tc, Swap, and Nolocals.