← Sun, Nov 15 digest

Write your own kernel optimiser

read article ↗ hn thread ↗

Cachet is a new experimental language that lets developers write performance-critical kernels using explicitly verified code schedules rather than opaque compiler optimizations.

read it Offers a detailed, hands-on look at designing a language that makes performance transformations explicit and formally checkable.

summary

The author introduces Cachet, a language where hardware attributes like caches, memory layouts, and vector registers are explicit components. Programmers define computations separately from execution schedules—sequences of rewrites like loop swapping, blocking, and packing—which the compiler formally checks for correctness. Using matrix multiplication as a running example, the post demonstrates deriving a cache-optimized CPU kernel from a naive definition. This approach turns performance regressions into verifiable compile-time errors.

key points

  1. Cachet makes hardware concerns like cache levels and memory layouts explicit language features rather than hidden compiler heuristics.
  2. Calculations are separated from execution schedules, allowing developers to apply step-by-step rewrites that the compiler checks for semantic equivalence.
  3. The framework can derive blocked CPU matrix multiplication kernels that approach OpenBLAS performance.

who should read it

Systems engineers, compiler developers, and performance optimization specialists.

discussion positive

best comment by teo_zero ↗

TFA describes two coding alternatives: abstract, high-level, easy-to-read code that we give to the compiler to optimize, or low-level, CPU-specific, manually optimized code. A Python library is mentioned as the archetype of the first kind.

Clarifies the article's opening reference to Python libraries as high-level abstractions.

Generated by an LLM from the article and thread. Check the sources before relying on it.