brw: Fix comparison with unordered_mode when making baked dependency

The unordered mode stored in dependencies might be a bitmask and not
only a single mode.  In practice, only the "stronger" mode will stick.
Make sure that the code testing for the mode uses "&" instead of "==",
to avoid prevent some valid combinations to happen, e.g.

```
   // ...
   add(16)         g104<1>F        g94<1,1,0>F     g34<1,1,0>F     { align1 1H @7 $7.dst compacted };
```

which without the fix ends up as

```
   // ...
   sync nop(1)                     null<0,1,0>UB                   { align1 WE_all 1N F@7 };
   add(16)         g104<1>F        g94<1,1,0>F     g34<1,1,0>F     { align1 1H $7.dst compacted };
```

Enables two tests for the scoreboard pass that illustrate this case.

For measuring the effect, re-enabled the sync.nop accounting on total of
instructions and got the following results.

```
   Totals:
   Instrs: 322041261 -> 321748285 (-0.09%)
   Cycle count: 22864587567 -> 22863073741 (-0.01%)
   Max dispatch width: 7989040 -> 7989024 (-0.00%); split: +0.00%, -0.00%

   Totals from 88212 (9.78% of 902056) affected shaders:
   Instrs: 102282050 -> 101989074 (-0.29%)
   Cycle count: 12787629859 -> 12786116033 (-0.01%)
   Max dispatch width: 525336 -> 525320 (-0.00%); split: +0.01%, -0.01%
```

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36096>
This commit is contained in:
Caio Oliveira 2025-07-12 22:12:57 -07:00 committed by Marge Bot
parent 1e18a2d1a8
commit f8db53ccae
2 changed files with 8 additions and 8 deletions

View file

@ -1014,19 +1014,19 @@ namespace {
return true;
else if (devinfo->ver < 20)
return ordered_pipe == inferred_pipe &&
unordered_mode == (is_unordered(devinfo, inst) ? TGL_SBID_SET :
TGL_SBID_DST);
unordered_mode & (is_unordered(devinfo, inst) ? TGL_SBID_SET :
TGL_SBID_DST);
else if (is_send(inst))
return unordered_mode == TGL_SBID_SET &&
return unordered_mode & TGL_SBID_SET &&
(ordered_pipe == TGL_PIPE_FLOAT ||
ordered_pipe == TGL_PIPE_INT ||
ordered_pipe == TGL_PIPE_ALL);
else if (inst->opcode == BRW_OPCODE_DPAS)
return ordered_pipe == inferred_pipe;
else
return (unordered_mode == TGL_SBID_DST && ordered_pipe == inferred_pipe) ||
(unordered_mode == TGL_SBID_SRC && ordered_pipe == inferred_pipe) ||
(unordered_mode == TGL_SBID_DST && ordered_pipe == TGL_PIPE_ALL);
return (unordered_mode & TGL_SBID_DST && ordered_pipe == inferred_pipe) ||
(unordered_mode & TGL_SBID_SRC && ordered_pipe == inferred_pipe) ||
(unordered_mode & TGL_SBID_DST && ordered_pipe == TGL_PIPE_ALL);
}
/** @} */

View file

@ -1144,7 +1144,7 @@ TEST_F(scoreboard_test, scalar_register_mov_grf_is_not_in_scalar_pipe)
EXPECT_SHADERS_MATCH(bld, exp);
}
TEST_F(scoreboard_test, DISABLED_baked_dependency_with_inferred_pipe_combination)
TEST_F(scoreboard_test, baked_dependency_with_inferred_pipe_combination)
{
brw_builder bld = make_shader();
brw_builder exp = make_shader();
@ -1181,7 +1181,7 @@ TEST_F(scoreboard_test, DISABLED_baked_dependency_with_inferred_pipe_combination
EXPECT_SHADERS_MATCH(bld, exp);
}
TEST_F(scoreboard_test, DISABLED_math_inv_with_mul_dependency)
TEST_F(scoreboard_test, math_inv_with_mul_dependency)
{
brw_builder bld = make_shader();
brw_builder exp = make_shader();