Mesa Drivers' Use Of Multiple IRs, Gallium3D With NIR
Following the news this week that RadeonSI may switch to NIR completely in the future, in the forums a number of questions were raised about why the Linux graphics drivers are using multiple forms of intermediate representation and whether this would still make RadeonSI a Gallium3D driver if it doesn't default to TGSI.
Freedreno lead developer Rob Clark sought to clarify these misconceptions today in a blog post. In regards to RadeonSI and other graphics drivers making use of multiple forms of intermediate representation (IR; e.g. TGSI, NIR, then LLVM IR, and then the actual GPU instructions), it's because each IR has in effect its own specialty for what it can be best done for optimization/lowering passes at that stage, etc. The cost of translating from one IR to another is relatively tiny in the grand scheme and the drivers aren't redundantly running the same optimization passes with each form of intermediate representation.
In Rob's profiling of the Freedreno behavior with OpenGL, about 10% of the time was spent parsing into OpenGL while going from GLSL to NIR was just 1.3% and going from NIR to the IR3 hardware instructions were just 1.5%. The actual optimization passes for each IR were taking about 21%. In Freedreno's case, the NIR passes do some algebraic optimizations, common subexpression elimination, dead code elimination, and other optimizations. Most of the IR3 passes come down to scheduling, register allocation, and other near-final optimizations.
He also explains how even if drivers are using an alternative IR like NIR rather than TGSI, they are still Gallium3D drivers, and there are glsl-to-nir and tgsi-to-nir helpers.
More details can be found via Rob's blog.
Freedreno lead developer Rob Clark sought to clarify these misconceptions today in a blog post. In regards to RadeonSI and other graphics drivers making use of multiple forms of intermediate representation (IR; e.g. TGSI, NIR, then LLVM IR, and then the actual GPU instructions), it's because each IR has in effect its own specialty for what it can be best done for optimization/lowering passes at that stage, etc. The cost of translating from one IR to another is relatively tiny in the grand scheme and the drivers aren't redundantly running the same optimization passes with each form of intermediate representation.
In Rob's profiling of the Freedreno behavior with OpenGL, about 10% of the time was spent parsing into OpenGL while going from GLSL to NIR was just 1.3% and going from NIR to the IR3 hardware instructions were just 1.5%. The actual optimization passes for each IR were taking about 21%. In Freedreno's case, the NIR passes do some algebraic optimizations, common subexpression elimination, dead code elimination, and other optimizations. Most of the IR3 passes come down to scheduling, register allocation, and other near-final optimizations.
He also explains how even if drivers are using an alternative IR like NIR rather than TGSI, they are still Gallium3D drivers, and there are glsl-to-nir and tgsi-to-nir helpers.
More details can be found via Rob's blog.
1 Comment