This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

want to now more detail about GPU register number

I was profilering our game using Arm Graphics analyzer and noticed that in the profiler there is a column in the shader window called spilling uses.It said that when the number required for work registers it too great,it will store variable to RAM istead. And saidly most of our game shader program causes the register spilling. But something strange is that some shader program uses 8 uniform registers and 16 work registers and dosn not cause spilling while other shader programs with 16 uniform registers and only 8 work registers cause spilling. I wander if the maximun number of the uniform registers and work registers is fixed?  Or the maximun allowed work registers have nothing to do with uniform registers number?

Parents
  • Hi CloudBunny, 

    The work registers and uniform registers are separate allocations from different register pools. When we talk about spilling we are generally talking about the work registers.

    Mali can allocate work registers in variable amounts:

    • Midgard GPUs: 4, 8, or 16
    • Bifrost/Valhall : 32, or 64

    Increasing the size of the register allocation reduces spilling, but it also reduces the number of concurrent threads that can be executed in the shader core. This reduces the shader core's ability to hide cache misses and data fetches, which can impact performance.

    How many registers are selected is a compiler-managed heuristic trying to balance thread occupancy and spilling. In general the shader compiler will try hard to keep fragment shaders in 4 or 32 registers, giving the highest thread occupancy, for other shader types the compiler is a little more relaxed and will allow the shader program to use 8 or 64 more of the time. 

    The quickest way to reduce spilling is to reduce variable precision - Mali can store packed vectors in the registers, so we can fit twice as many "mediump" variables in a register than "highp" variables. They also generally process faster and arithmetic operations on 16-bit values need less energy, so it's generally a good thing to use mediump variables as much as possible. 

    Kind regards, 
    Pete

    P.S. Note that the current Graphics Analyzer always runs on Mali-T880, which is an older GPU now and quite a different architecture to the more recent Bifrost and Valhall GPUs. The Mali Offline Compiler that ships in Mobile Studio will let you test the problem shaders against newer GPUs.

Reply
  • Hi CloudBunny, 

    The work registers and uniform registers are separate allocations from different register pools. When we talk about spilling we are generally talking about the work registers.

    Mali can allocate work registers in variable amounts:

    • Midgard GPUs: 4, 8, or 16
    • Bifrost/Valhall : 32, or 64

    Increasing the size of the register allocation reduces spilling, but it also reduces the number of concurrent threads that can be executed in the shader core. This reduces the shader core's ability to hide cache misses and data fetches, which can impact performance.

    How many registers are selected is a compiler-managed heuristic trying to balance thread occupancy and spilling. In general the shader compiler will try hard to keep fragment shaders in 4 or 32 registers, giving the highest thread occupancy, for other shader types the compiler is a little more relaxed and will allow the shader program to use 8 or 64 more of the time. 

    The quickest way to reduce spilling is to reduce variable precision - Mali can store packed vectors in the registers, so we can fit twice as many "mediump" variables in a register than "highp" variables. They also generally process faster and arithmetic operations on 16-bit values need less energy, so it's generally a good thing to use mediump variables as much as possible. 

    Kind regards, 
    Pete

    P.S. Note that the current Graphics Analyzer always runs on Mali-T880, which is an older GPU now and quite a different architecture to the more recent Bifrost and Valhall GPUs. The Mali Offline Compiler that ships in Mobile Studio will let you test the problem shaders against newer GPUs.

Children