Skip to content
Tech News
← Back to articles

Kraid is a now a real compiler

read original more articles
Why This Matters

The successful development of Kraid as a fully functional compiler marks a significant milestone for the Panfrost driver stack, promising improved graphics performance and stability for devices using this open-source graphics driver. This progress demonstrates how targeted compiler advancements can enhance hardware efficiency and developer flexibility, ultimately benefiting consumers with better graphics experiences. While still in progress, Kraid's capabilities lay the groundwork for more optimized and reliable graphics processing in the future.

Key Takeaways

The last time I wrote about Kraid, the new compiler we're writing for the Panfrost driver stack, the big news was that it was finally passing a single Vulkan CTS test. Today, the big news is that it's now passing all 800,000 of them, including a few the old compiler fails. Kraid is now a real compiler.

Before you get too excited, though, we're still far from done. The 100% pass rate is with only compute shaders going through Kraid. Vertex and fragment shading are still works in progress. We'll hopefully have those working in the next few weeks but they aren't implemented yet. Also, the quality of the generated code is still fairly poor. This isn't a problem with the design of Kraid, but rather it was a strategic choice. Having the register allocator make bad allocation decisions helps us ferret out bugs in the rest of the compiler that can occur when the register pressure gets tight and the allocator isn't able to make good decisions.

Importantly, however, we now have all the tools in place to make it good. Nearly every single item on our checklist of requirements for the new compiler has been checked off. Kraid now has:

An SSA-based register allocator that's capable of allocating within an arbitrary fixed budget

An SSA-based spiller that runs in near-linear time and always succeeds at getting the program to fit in the desired number of registers

Proper handling of 64-bit operations

Proper handling of integer and float widen operations on sources

Full and correct swizzle support everywhere

A copy-propagation pass capable of propagating both at the word and byte granularity, including seeing through swizzles and vector collect operations

Full support for 16-bit destinations and seamlessly emulated support for 8-bit destinations. (Most instructions don't support actual 8-bit destinations, so we have to fake it by giving them 16 bits.)

... continue reading