In April this year, I decided to start trying to figure out how to write an M1 GPU kernel driver! [...] it was already clear this was no ordinary GPU. Over the first couple of months, I worked on writing and improving a m1n1 hypervisor tracer for the GPU, and what I found was very, very unusual in the GPU world.
Since I was already writing a GPU tracer for the m1n1 hypervisor and filling out structure definitions in Python, I decided to just flip it on its head and start writing a Python GPU kernel driver, using the same structure definitions. Python is great for this, since it is very easy to iterate with!
With the eldritch horror Mesa+Python driver stack working, I started to have a better idea of how the eventual kernel driver had to work and what it had to do. [...] At around the same time, rumours of Rust soon being adopted officially by the Linux kernel were beginning to come up. The Rust for Linux project had been working on officially adding support for several years, and it looked like their work might be merged soon. Could I… could I write the GPU driver in Rust?
Normally, when you write a brand new kernel driver as complicated as this one, trying to go from simple demo apps to a full desktop with multiple apps using the GPU concurrently ends up triggering all sorts of race conditions, memory leaks, use-after-free issues, and all kinds of badness. But all that just… didn’t happen!
This is an awesome read. The idea of a python module inside of a shim library running a GPU over USB made me want to curl up in a corner. Trying to reverse engineer the data structures required by...
This is an awesome read. The idea of a python module inside of a shim library running a GPU over USB made me want to curl up in a corner. Trying to reverse engineer the data structures required by a closed source GPU firmware (that change from release to release) makes me physically ill.
This is an awesome read. The idea of a python module inside of a shim library running a GPU over USB made me want to curl up in a corner. Trying to reverse engineer the data structures required by a closed source GPU firmware (that change from release to release) makes me physically ill.
10/10
Interesting read. I liked the bit about Rust being a real improvement over C by eliminating whole classes of bugs.