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.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.