Skip to content

intel/compiler: better tracking of dependencies in scoreboarding pass

Marcin Ślusarz requested to merge mslusarz/mesa:sbid-recycle2 into main

We have only 16 SBID tokens, so when shader wants to define more synchronization points, we must reuse them. This means that unrelated operations must share the same SBID token. There's one situation where this sharing leads to excessive stalling: when shader wants to synchronize against SBID token issued 16 tokens earlier but ends up synchronizing against just emitted token:

send ... $0  (sync point 0)
send ... $1  (sync point 1)
send ... $2  (sync point 2)
...
send ... $14 (sync point 14)
send ... $15 (sync point 15)
send ... $0  (sync point 16)

Now we want to synchronize against sync point 0, so we generate:

sync nop $0.dst

We end up synchronizing against both sync point 16 and sync point 0.

This patch solves this problem by tracking real dependency numbers and avoiding reissuing syncs against already synchronized dependencies. It also removes duplicated syncs.

In the example above, "sync nop $0.dst" is removed because reissuing send with $0 token has an implicit stall (sync nop $0.dst).

Shader-db on DG2 after this patch looks like this:

total instructions in shared programs: 22994595 -> 21933641 (-4.61%)
instructions in affected programs: 19391657 -> 18330703 (-5.47%)
helped: 84347
HURT: 4
helped stats (abs) min: 1 max: 3808 x̄: 12.58 x̃: 5
helped stats (rel) min: 0.11% max: 33.13% x̄: 4.23% x̃: 3.41%
HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
HURT stats (rel)   min: 0.25% max: 0.52% x̄: 0.38% x̃: 0.38%
95% mean confidence interval for instructions value: -12.89 -12.27
95% mean confidence interval for instructions %-change: -4.25% -4.20%
Instructions are helped.

total loops in shared programs: 5867 -> 5867 (0.00%)
loops in affected programs: 0 -> 0
helped: 0
HURT: 0

total cycles in shared programs: 839861778 -> 833418057 (-0.77%)
cycles in affected programs: 769088842 -> 762645121 (-0.84%)
helped: 68272
HURT: 24
helped stats (abs) min: 1 max: 768792 x̄: 94.44 x̃: 8
helped stats (rel) min: <.01% max: 50.49% x̄: 0.68% x̃: 0.41%
HURT stats (abs)   min: 1 max: 1404 x̄: 168.67 x̃: 2
HURT stats (rel)   min: 0.03% max: 1.50% x̄: 0.27% x̃: 0.09%
95% mean confidence interval for cycles value: -117.16 -71.54
95% mean confidence interval for cycles %-change: -0.69% -0.67%
Cycles are helped.

total spills in shared programs: 10742 -> 10742 (0.00%)
spills in affected programs: 0 -> 0
helped: 0
HURT: 0

total fills in shared programs: 13631 -> 13631 (0.00%)
fills in affected programs: 0 -> 0
helped: 0
HURT: 0

total sends in shared programs: 1035411 -> 1035411 (0.00%)
sends in affected programs: 0 -> 0
helped: 0
HURT: 0

LOST:   101
GAINED: 194

Supersedes !23566 (closed).

Edited by Marcin Ślusarz

Merge request reports