Gallium Clover With SPIR-V & NIR Opening Up New Compute Options Inside Mesa
Longtime Nouveau contributor Karol Herbst joined Red Hat almost one year ago and for much of that time he's been working on NIR support for SPIR-V, getting Nouveau's NIR support up to the quality of TGSI IR, basic compute support, and more all squared up. It's not yet all mainlined or ready for end-users, but Karol continues working on it as well as Rob Clark of Red Hat. It's been interesting though the amount of work Red Hat has been investing in the effort considering Maxwell and newer graphics cards continue to be crippled performance-wise due to the inability to have proper re-clocking on these desktop GPUs.
Their fundamental initiative is about getting NIR as more of a general purpose IR within Mesa and being able to use NIR for all necessary driver operations. Here's a useful look at the planned overview of the intermediate presentations inside Mesa for OpenCL and SPIR-V and ultimately hitting the different drivers:
To get NIR working for their use-case, they've had to work on proper pointer support, additional operations, VEC8/VEC16 support, and other features.
While there are other drivers utilizing NIR inside Mesa like Intel, RadeonSI, and VC4/V3D, for now most of this work and testing is done on the Nouveau and Freedreno drivers. But ultimately other drivers may be able to easily benefit if they add support for the new compute intrinsics and other necessary instructions.
In total this year-long effort is nearing fruition but at around 150 patches, currently breaking graphics support, and the NIR code-path is slower than the mature TGSI code for Nouveau... It doesn't sound like this NIR/SPIR-V compute work will be settled in full in time for Mesa 18.3 to end out the year.
In the future, this SPIR-V/NIR support may allow for support of other languages and even a potential OpenMP offloading state tracker inside Mesa. The other work going on within Red Hat for Heterogeneous Memory Management (HMM) may play nicely into this as well.
The XDC2018 slide deck by Karol and Rob can be viewed here.