Hi,
I'm trying to use Mali Offline Compiler to build a more accurate runtime GPU workload estimation for our game.
I have a shader with a loop whose iteration count comes from a CPU-provided uniform/constant buffer, for example:
uniform int lightCount; for (int i = 0; i < lightCount; ++i) { ProcessLight(i); }
For a specific draw call, the CPU knows the actual value, for example:
lightCount = 2
What I would like to estimate is the Mali Offline Compiler cycle cost for the original compiled shader executing this loop exactly twice, especially the per-functional-unit costs:
A / LS / V / T cycles
The problem is that Mali Offline Compiler does not know the runtime uniform value. For a uniform-controlled loop, the Longest Path Cycles can also be reported as N/A.
I tried replacing the runtime value with a compile-time constant, for example:
const int lightCount = 2;
However, this changes the compiler optimization. In my tests, the generated shader uses a different number of work registers, presumably due to optimizations such as loop unrolling, constant propagation, dead-code elimination, and different register allocation.
Therefore, the result from the specialized shader is not necessarily representative of the original shader executing with lightCount = 2 at runtime.
What I am looking for is something conceptually like:
Original compiled shader + Known runtime uniform values ↓ Path-aware performance analysis ↓ A / LS / V / T cycles
without recompiling/specializing the shader in a way that changes its register usage or occupancy.
Is there any supported way to do this with Mali Offline Compiler?
In particular:
Can Mali Offline Compiler expose cycle costs at a finer granularity, such as per basic block, loop body, or control-flow region?
If so, we could keep the original compiled shader and calculate something like:
base cost + loop body cost × runtime iteration count + loop control overhead
Our goal is not necessarily to predict the final GPU execution time directly. We are mainly trying to estimate the shader-core workload in terms of the same A / LS / V / T cycle metrics reported by Mali Offline Compiler, while preserving the register usage and occupancy of the original shader.
Thanks!
Thanks! This is very helpful.
My main goal is to improve the accuracy of the estimation. In real game shaders, a significant part of the workload is controlled by runtime loop counts. For our game, although these are runtime values, we usually know their approximate ranges in representative scenes, and the counts can be much larger than 2.
I also noticed in our experiments that, when we know the actual FS invocation count, the malioc cycle estimate seems to correlate quite well with:
FS Invocations × malioc cycles/thread ≈ Execution Core Active Cycles × Unit Utilization
Is this observation and interpretation correct? If so, is there any approach you would recommend today to better estimate the runtime-dependent loop cost?
Thanks again!