<div dir="ltr"><div>This is a very clever solution to the problem.  I like it. :-)<br></div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></div><div><br></div><div>I think that's all of them.  I've pushed the XML bump so you should be able to land at will.</div><div><br></div><div>--Jason<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Jul 8, 2018 at 5:29 PM Jose Maria Casanova Crespo <<a href="mailto:jmcasanova@igalia.com" target="_blank">jmcasanova@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Since Gen8+ Intel PRM states that "r127 must not be used for return<br>
address when there is a src and dest overlap in send instruction."<br>
<br>
This patch implements this restriction creating new grf127_send_hack_node<br>
at the register allocator. This node has a fixed assignation to grf127.<br>
<br>
For vgrf that are used as destination of send messages we create node<br>
interfereces with the grf127_send_hack_node. So the register allocator<br>
will never assign to these vgrf a register that involves grf127.<br>
<br>
If dispatch_width > 8 we don't create these interferences to the because<br>
all instructions have node interferences between sources and destination.<br>
That is enough to avoid the r127 restriction.<br>
<br>
This fixes CTS tests that raised this issue as they were executed as SIMD8:<br>
<br>
dEQP-VK.spirv_assembly.instruction.graphics.8bit_storage.8struct_to_32struct.storage_buffer_*int_geom<br>
<br>
Shader-db results on Skylake:<br>
   total instructions in shared programs: 7686798 -> 7686797 (<.01%)<br>
   instructions in affected programs: 301 -> 300 (-0.33%)<br>
   helped: 1<br>
   HURT: 0<br>
<br>
   total cycles in shared programs: 337092322 -> 337091919 (<.01%)<br>
   cycles in affected programs: 22420415 -> 22420012 (<.01%)<br>
   helped: 712<br>
   HURT: 588<br>
<br>
Shader-db results on Broadwell:<br>
<br>
   total instructions in shared programs: 7658574 -> 7658625 (<.01%)<br>
   instructions in affected programs: 19610 -> 19661 (0.26%)<br>
   helped: 3<br>
   HURT: 4<br>
<br>
   total cycles in shared programs: 340694553 -> 340676378 (<.01%)<br>
   cycles in affected programs: 24724915 -> 24706740 (-0.07%)<br>
   helped: 998<br>
   HURT: 916<br>
<br>
   total spills in shared programs: 4300 -> 4311 (0.26%)<br>
   spills in affected programs: 333 -> 344 (3.30%)<br>
   helped: 1<br>
   HURT: 3<br>
<br>
   total fills in shared programs: 5370 -> 5378 (0.15%)<br>
   fills in affected programs: 274 -> 282 (2.92%)<br>
   helped: 1<br>
   HURT: 3<br>
<br>
v2: Avoid duplicating register classes without grf127. Let's use a node<br>
    with a fixed assignation to grf127 and create interferences to send<br>
    message vgrf destinations. (Eric Anholt)<br>
v3: Update reference to CTS VK_KHR_8bit_storage failing tests.<br>
    (Jose Maria Casanova)<br>
---<br>
 src/intel/compiler/brw_fs_reg_allocate.cpp | 25 ++++++++++++++++++++++<br>
 1 file changed, 25 insertions(+)<br>
<br>
diff --git a/src/intel/compiler/brw_fs_reg_allocate.cpp b/src/intel/compiler/brw_fs_reg_allocate.cpp<br>
index ec8e116cb38..59e047483c0 100644<br>
--- a/src/intel/compiler/brw_fs_reg_allocate.cpp<br>
+++ b/src/intel/compiler/brw_fs_reg_allocate.cpp<br>
@@ -548,6 +548,9 @@ fs_visitor::assign_regs(bool allow_spilling, bool spill_all)<br>
    int first_mrf_hack_node = node_count;<br>
    if (devinfo->gen >= 7)<br>
       node_count += BRW_MAX_GRF - GEN7_MRF_HACK_START;<br>
+   int grf127_send_hack_node = node_count;<br>
+   if (devinfo->gen >= 8 && dispatch_width == 8)<br>
+      node_count ++;<br>
    struct ra_graph *g =<br>
       ra_alloc_interference_graph(compiler->fs_reg_sets[rsi].regs, node_count);<br>
<br>
@@ -653,6 +656,28 @@ fs_visitor::assign_regs(bool allow_spilling, bool spill_all)<br>
       }<br>
    }<br>
<br>
+   if (devinfo->gen >= 8 && dispatch_width == 8) {<br>
+      /* At Intel Broadwell PRM, vol 07, section "Instruction Set Reference",<br>
+       * subsection "EUISA Instructions", Send Message (page 990):<br>
+       *<br>
+       * "r127 must not be used for return address when there is a src and<br>
+       * dest overlap in send instruction."<br>
+       *<br>
+       * We are avoiding using grf127 as part of the destination of send<br>
+       * messages adding a node interference to the grf127_send_hack_node.<br>
+       * This node has a fixed asignment to grf127.<br>
+       *<br>
+       * We don't apply it to SIMD16 because previous code avoids any register<br>
+       * overlap between sources and destination.<br>
+       */<br>
+      ra_set_node_reg(g, grf127_send_hack_node, 127);<br>
+      foreach_block_and_inst(block, fs_inst, inst, cfg) {<br>
+         if (inst->is_send_from_grf() && inst->dst.file == VGRF) {<br>
+            ra_add_node_interference(g, inst-><a href="http://dst.nr" rel="noreferrer" target="_blank">dst.nr</a>, grf127_send_hack_node);<br>
+         }<br>
+      }<br>
+   }<br>
+<br>
    /* Debug of register spilling: Go spill everything. */<br>
    if (unlikely(spill_all)) {<br>
       int reg = choose_spill_reg(g);<br>
-- <br>
2.17.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>