Skip to main content

Module op_count

Module op_count 

Source
Expand description

Thread-local arithmetic-IR-op counting for roofline / complexity analysis. Thread-local counting of arithmetic IR operations executed by the reference interpreter, a backend-agnostic dynamic operation count for roofline / complexity analysis.

The reference interpreter executes the same vyre IR with the same data-dependent control flow that any backend (GPU or CPU) would, so the arithmetic-op count it reports for a (program, inputs) pair equals the dynamic IR-op count the GPU would execute for the same inputs, at the vyre-IR granularity, which is distinct from (and coarser than) hardware SASS instructions. This gives an honest, non-root operational-intensity measurement (ops / bytes) for the roofline without Nsight-Compute; the SASS-level dynamic count remains the ncu refinement.

Counting is a no-op unless a [count_ops] scope is active on the current thread, so ordinary reference evaluation (the vast majority of interpreter use, all in tests) pays only one thread-local read per arithmetic op and no allocation.

Functionsยง

count_ops
Run f with arithmetic-op counting active and return (f's result, arithmetic IR ops executed). The count is every BinOp / UnOp / Fma the reference interpreter evaluates during f: a backend-agnostic dynamic operation count.