<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 16, 2016 at 1:54 PM, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This uses the unblocked time of the exit assigned to each available<br>
node to attempt to unblock exit nodes as early as possible,<br>
potentially reducing the runtime of the shader when an exit branch is<br>
taken.  There is a natural trade-off between terminating the program<br>
as early as possible and reducing the worst-case latency of the<br>
program as a whole (since this will typically move exit-unblocking<br>
nodes closer to its dependencies potentially causing additional stalls<br>
of the execution pipeline), but in practice the bandwidth and ALU<br>
cycle savings from terminating the program earlier tend to outweigh<br>
the slight increase in worst-case program execution latency, so it<br>
makes sense to prefer nodes likely to unblock an earlier exit<br>
regardless of the latency benefits of other available nodes.<br>
<br>
I haven't observed any benchmark regressions from this change after<br>
testing on VLV, HSW, BDW, BSW and SKL.  The FPS of the GfxBench<br>
Manhattan benchmark increases by 10%-20% and the FPS of Unigine Valley<br>
improves by roughly 5% depending on the platform and settings.<br></blockquote><div><br></div><div>Thanks for working on this!  We've known about it for a while and it's nice to finally get some progress.<br><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The change to the register pressure-sensitive heuristic is rather<br>
conservative and gives precedence to the existing heuristic in order<br>
to avoid increasing register pressure and causing spill count and SIMD<br>
width regressions in shader-db.  It may make sense to revisit this<br>
with additional performance data.<br>
---<br>
 .../drivers/dri/i965/brw_<wbr>schedule_instructions.cpp    | 19 ++++++++++++++++---<br>
 1 file changed, 16 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/<wbr>brw_schedule_instructions.cpp<br>
index 96562cf..dfcaa80 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_schedule_instructions.cpp<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_schedule_instructions.cpp<br>
@@ -1407,11 +1407,15 @@ fs_instruction_scheduler::<wbr>choose_instruction_to_<wbr>schedule()<br>
    if (mode == SCHEDULE_PRE || mode == SCHEDULE_POST) {<br>
       int chosen_time = 0;<br>
<br>
-      /* Of the instructions ready to execute or the closest to<br>
-       * being ready, choose the oldest one.<br>
+      /* Of the instructions ready to execute or the closest to being ready,<br>
+       * choose the one most likely to unblock an early program exit, or<br>
+       * otherwise the oldest one.<br>
        */<br>
       foreach_in_list(schedule_node, n, &instructions) {<br>
-         if (!chosen || n->unblocked_time < chosen_time) {<br>
+         if (!chosen ||<br>
+             exit_unblocked_time(n) < exit_unblocked_time(chosen) ||<br>
+             (exit_unblocked_time(n) == exit_unblocked_time(chosen) &&<br>
+              n->unblocked_time < chosen_time)) {<br>
             chosen = n;<br>
             chosen_time = n->unblocked_time;<br>
          }<br>
@@ -1500,6 +1504,15 @@ fs_instruction_scheduler::<wbr>choose_instruction_to_<wbr>schedule()<br>
             continue;<br>
          }<br>
<br>
+         /* Prefer the node most likely to unblock an early program exit.<br>
+          */<br>
+         if (exit_unblocked_time(n) < exit_unblocked_time(chosen)) {<br>
+            chosen = n;<br>
+            continue;<br>
+         } else if (exit_unblocked_time(n) > exit_unblocked_time(chosen)) {<br>
+            continue;<br>
+         }<br>
+<br>
          /* If all other metrics are equal, we prefer the first instruction in<br>
           * the list (program execution).<br>
           */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>