From f8db53ccae88eef6df0dc81eb27e29c243b19a80 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Sat, 12 Jul 2025 22:12:57 -0700 Subject: [PATCH] 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 Part-of: --- src/intel/compiler/brw_lower_scoreboard.cpp | 12 ++++++------ src/intel/compiler/test_lower_scoreboard.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/intel/compiler/brw_lower_scoreboard.cpp b/src/intel/compiler/brw_lower_scoreboard.cpp index 80bb0f1c0ab..14c4579fc2c 100644 --- a/src/intel/compiler/brw_lower_scoreboard.cpp +++ b/src/intel/compiler/brw_lower_scoreboard.cpp @@ -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); } /** @} */ diff --git a/src/intel/compiler/test_lower_scoreboard.cpp b/src/intel/compiler/test_lower_scoreboard.cpp index b54dee8a051..b35c1b30dce 100644 --- a/src/intel/compiler/test_lower_scoreboard.cpp +++ b/src/intel/compiler/test_lower_scoreboard.cpp @@ -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();