hn.today

Write your own kernel optimiser

blog.csongor.co.uk3 points0 comments
Screenshot of Write your own kernel optimiser

Cachet is a programming language designed to make performance decisions explicit rather than leaving them hidden in compiler heuristics or a programmer’s head. The central idea is to separate what a program computes from how it computes it: a mathematical expression defines the result, and a schedule applies rewrites to produce an optimized kernel. Cachet’s compiler checks that each rewrite preserves the original meaning, including assumptions such as output storage not overlapping inputs. This can turn a fragile optimization into a checked property that fails at compile time if later changes make it invalid.

Matrix multiplication illustrates the approach. A straightforward loop nest reaches only 1.17 GFLOP/s on one CPU core for 1024 × 1024 single-precision matrices, about 1% of OpenBLAS’s speed. Reordering loops so the inner loop walks across contiguous rows improves performance to 33 GFLOP/s, or 30% of OpenBLAS, by using cache lines more effectively. Cachet expresses the multiplication as a contraction, identifying independent output elements and the sum for each one; schedules then implement transformations such as initializing output storage and moving loop steps so the reordered computation remains correct. The broader demonstration derives cache-blocked CPU kernels and GPU kernels using matrix hardware, comparing them with optimized libraries on an Apple M4 Max.

Read on blog.csongor.co.uk0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Aristotle Expands into Rust

Aristotle Expands into Rust

Aristotle has expanded its formal verification platform to Rust, allowing developers to prove code meets specifications and contains no undefined behavior, including in unsafe blocks. It can also verify that Rust rewrites behave like their original C code, targeting critical software such as smart contracts and infrastructure. (harmonic.fun)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.