github ↗
docs menu

Module Renderer.Estimates

Cost estimates of kernels.

The type for estimates.

#val zero : t

zero is the estimate of no work: every count is 0.

#val add : t -> t -> t

add e0 e1 is the estimate of both e0's and e1's work: each count is the sum of theirs, exactly: an Int where it fits one, else a constant node.

#val simplify : t -> t

simplify e is e with each count simplified (Shape.ssimplify).

#val of_uops : ?ignore_indexing:bool -> Ops.t list -> t

of_uops ~ignore_indexing uops estimates the linearized kernel uops:

  • ops counts arithmetic and logic operations, a multiply-add as two, and a tensor core product as 2 N M K shared among the threads of its warp;
  • lds counts the bytes of each load and store, except those of registers;
  • mem counts, for each parameter, the bytes loaded from it and the bytes stored into it, each at most the parameter's size: a buffer read again is counted once.

Each operation counts once per iteration of the ranges and hardware indices around it. A range with no trip count, a loop, counts as one iteration, a trip count that depends on a hardware index is taken at index 0, and one that depends on another range, as a triangular loop's does, or on a value loaded from memory, at its greatest value: a count reads no value but the run's variables. ops and each parameter's part of mem are simplified; lds is not. With ignore_indexing (default false), the operations that compute the indices of Op.t.Index and Op.t.Shrink nodes, up to the Op.t.End or Op.t.Backedge of any loop they read, are not counted.

The counts are exact: an integer count that does not fit an int, as of a loop bounded by a value loaded from memory, is a node of constants, which ops and mem simplify to one.

Raises Invalid_argument if an Op.t.End or Op.t.Backedge closes no Op.t.Range, or if an Op.t.Wmma node has no tensor core argument.