Semiring Optimizations: Dynamic Elision of Expressions with Identity and Absorbing Elements
Thu 19 Nov 2020 05:40 - 06:00 at SPLASH-I - W-6 Chair(s): Jan Vitek, John Wickerson
This paper describes a compiler optimization to eliminates dynamic occurrences
of expressions in the format $a \leftarrow a \oplus b \otimes c$.
The operation $\oplus$ must admit an identity element $z$, such that
$a \oplus z = a$.
Also, $z$ must be the absorbing element of $\otimes$, such
that $b \otimes z = z \otimes c = z$.
Semirings where $\oplus$ is the additive operator and $\otimes$ is the
multiplicative operator meet this contract.
This pattern is common in high-performance benchmarks—its canonical
representative being the multiply-add operation $a \leftarrow a + b \times c$.
However, several other expressions involving arithmetic and logic operations
satisfy the required algebra.
We show that the runtime elimination of such assignments can be implemented in
a performance-safe way via online profiling.
The elimination of dynamic redundancies involving identity and absorbing
elements in 35 programs of the LLVM test suite that present semiring patterns
brings an average speedup of 1.19x (total optimized time over total
unoptimized time) on top of clang -O3.
When projected onto the entire test suite (259 programs) the optimization leads
to a speedup of 1.025x.
Once added onto \texttt{clang}, semiring optimizations approximates it to TACO,
a specialized tensor compiler.