lanes.zig
I’ve been feeling inspired by Multi-Core by Default for a while now. I wanted to try it for a personal project, so for the past week or so I’ve been putting together a very small library that ports these concepts to Zig. It’s based largely on the blog post, plus his work in Rad Debugger.
The idea is that by storing some context in a thread-local static variable, a thread can “locate” itself within a larger task, and synchronize with other threads via “Lanes”. Each thread gets a lane, knows how many other lanes there are, and can communicate with them.
The result is parallel code that resembles GPU kernels. I quite like it. Writing the examples was fun.
Feedback is welcome. I feel like the public interface still needs refinement, but I want to use it for a while before making changes.
Supported Zig versions
Written for zig 0.17. I will do my best to keep it maintained for stable releases.
AI / LLM usage disclosure
This code is mostly hand-written. LLM coding agents were used for troubleshooting, test authoring, and prototyping.