Kraid 现在是一个真正的编译器了
Kraid is a now a real compiler

原始链接: https://www.collabora.com/news-and-blog/news-and-events/kraid-is-a-now-a-real-compiler.html

Faith Ekstrand 带来了关于 Panfrost 驱动栈新编译器 Kraid 的重要更新。Kraid 现已通过全部 800,000 项 Vulkan CTS 计算着色器测试,达成了一个重要里程碑,正式确立了其作为功能性编译器的地位。 尽管计算着色器支持已经完成,但针对顶点和片段着色器的开发仍在继续。目前,为了在开发过程中优先考虑稳定性和错误检测,生成的代码质量仍处于较低水平。不过,基础架构——包括基于 SSA 的寄存器分配器和溢出处理、64 位运算支持以及稳健的副本传播——均已完全实现。 团队目前正将重心转向性能优化和寄存器分配器的微调。剩下的关键任务包括完成顶点和片段着色器阶段,其中后者涉及混合着色器和 ABI 定义等复杂的设计工作。虽然 Kraid 目前在 64 位算术运算上已优于旧编译器,但未来几周的首要目标是改进编译器的效率,使其在所有工作负载下均能匹配或超越旧编译器。

Hacker News | 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 | 登录 Kraid 现在是一个真正的编译器了 (collabora.com) 8 分,发布者:losgehts,2 小时前 | 隐藏 | 过往 | 收藏 | 1 条评论 | 帮助 jdw64 2 分钟前 [–] 80 万个测试???哇 所以如果我能使用 Kraid,是不是意味着我不需要使用 NVIDIA 芯片就能构建人工智能了? 回复 考虑申请 YC 2026 秋季批次!申请截止日期为 7 月 27 日。 准则 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系 搜索:
相关文章

原文

Faith Ekstrand
July 30, 2026

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.)

  • The encoding and any metadata about instructions is extracted directly from XML provided by Arm

  • Hardware unit tests for most instructions which validate our understanding of the instruction's precise semantics against hardware

Where do we go from here?

Now that we've built the compiler, it's time to make it sing. We have all the core pieces in place. It's now time to shift gears and start looking at the code it generates and using the tools we've built to try and do better. There are still a few optimization passes that need to be written, the register allocator needs a lot of fine-tuning, and we need to refine our strategies around booleans and 8-bit data.

We also need to finish off the other two shader stages. Vertex shaders are pretty straightforward but fragment shaders are a bit trickier. The BLEND and ATEST instructions have register allocation implications, and the blend shaders themselves require us to define an ABI between the main fragment shader and the blend shader because BLEND sometimes ends up being a function pointer call. This ends up adding a bunch of subtle corners to the IR which we have yet to sort out. None of it is especially fundamental but there is some design work left to do.

Hopefully, we'll start to see some good performance improvements soon. Kraid is already better than the old compiler at 64-bit arithmetic. As we continue to make improvements, it will hopefully match or beat the old compiler for most workloads but that has yet to be seen.

 

联系我们 contact @ memedata.com