Skip to content

Metrics and Objective Functions

Andrew Johnson edited this page Oct 12, 2024 · 12 revisions

When appropriate, the compiler may choose from among equivalent candidate functions and data to minimize or maximize a final objective metric.

What is a Metric?

Metrics are integer tuples.

0 < 1 < (1 1) < (1 (0 2))

One Expression, Multiple Metrics

A single expression may yield multiple metrics such as memory pressure or cpu pressure.

cpu( e ) = (2 34 (5 67))
memory( e ) = (8 (9 1011))

Objectives are Goals to be Minimized

Objective functions are optimization goals that can be tweaked and weighted.

Goal: min( 0.8 * cpu(program) + 0.2 * memory(program) )

Selecting a Representation from a Class

Sometimes selecting a candidate representation is straightforward. Sometimes it can be not so simple. Constraint Solvers may be involved in the future.

mov := λ(: src Imm64)(: tgt Register64). ...;

mov := λ(: src Imm64/0)(: tgt Register64). ...;

In this code two forms of mov are declared. Types define equivalence. Metrics define preference.