<div dir="ltr">On 29 October 2013 16:37, Francisco Jerez <span dir="ltr"><<a href="mailto:currojerez@riseup.net" target="_blank">currojerez@riseup.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">The latency information has been obtained empirically from<br>
measurements taken on Haswell and Ivy Bridge.<br>
---<br>
 .../drivers/dri/i965/brw_schedule_instructions.cpp | 41 ++++++++++++++++++++++<br>
 1 file changed, 41 insertions(+)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp<br>
</div>index 944b5c8..cbfaabe 100644<br>
<div class="HOEnZb"><div class="h5">--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp<br>
@@ -329,6 +329,47 @@ schedule_node::set_latency_gen7(bool is_haswell)<br>
       latency = 200;<br>
       break;<br>
<br>
+   case SHADER_OPCODE_UNTYPED_ATOMIC:<br>
+      /* Test code:<br>
+       *   mov(8)    g112<1>ud       0x00000000ud       { align1 WE_all 1Q };<br>
+       *   mov(1)    g112.7<1>ud     g1.7<0,1,0>ud      { align1 WE_all };<br>
+       *   mov(8)    g113<1>ud       0x00000000ud       { align1 WE_normal 1Q };<br>
+       *   send(8)   g4<1>ud         g112<8,8,1>ud<br>
+       *             data (38, 5, 6) mlen 2 rlen 1      { align1 WE_normal 1Q };<br>
+       *<br>
+       * Running it 100 times as fragment shader on a 128x128 quad<br>
+       * gives an average latency of 13867 cycles per atomic op,<br>
+       * standard deviation 3%.  Note that this is a rather<br>
+       * pessimistic estimate, the actual latency in cases with few<br>
+       * collisions between threads and favorable pipelining has been<br>
+       * seen to be reduced by a factor of 100.<br>
+       */<br>
+      latency = 14000;<br></div></div></blockquote><div><br></div><div>Wow, that's a really huge latency.  Given your argument in the comment, I suspect that in practice, shaders that use atomic counters are going to be a lot closer to the "few collisions between threads and favorable pipelining" case than they are going to be to this pessimistic estimate.  Personally, I'd be inclined to make the latency the same as SHADER_OPCODE_UNTYPED_SURFACE_READ.<br>
<br>But I'm not an expert on scheduling latencies so I'll defer to Eric and Matt.  Consider this patch:<br><br></div><div>Acked-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
<br></div><div>I made comments on all the other patches in the series except patch 3.  Patch 3 is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
+      break;<br>
+<br>
+   case SHADER_OPCODE_UNTYPED_SURFACE_READ:<br>
+      /* Test code:<br>
+       *   mov(8)    g112<1>UD       0x00000000UD       { align1 WE_all 1Q };<br>
+       *   mov(1)    g112.7<1>UD     g1.7<0,1,0>UD      { align1 WE_all };<br>
+       *   mov(8)    g113<1>UD       0x00000000UD       { align1 WE_normal 1Q };<br>
+       *   send(8)   g4<1>UD         g112<8,8,1>UD<br>
+       *             data (38, 6, 5) mlen 2 rlen 1      { align1 WE_normal 1Q };<br>
+       *   .<br>
+       *   . [repeats 8 times]<br>
+       *   .<br>
+       *   mov(8)    g112<1>UD       0x00000000UD       { align1 WE_all 1Q };<br>
+       *   mov(1)    g112.7<1>UD     g1.7<0,1,0>UD      { align1 WE_all };<br>
+       *   mov(8)    g113<1>UD       0x00000000UD       { align1 WE_normal 1Q };<br>
+       *   send(8)   g4<1>UD         g112<8,8,1>UD<br>
+       *             data (38, 6, 5) mlen 2 rlen 1      { align1 WE_normal 1Q };<br>
+       *<br>
+       * Running it 100 times as fragment shader on a 128x128 quad<br>
+       * gives an average latency of 583 cycles per surface read,<br>
+       * standard deviation 0.9%.<br>
+       */<br>
+      latency = is_haswell ? 300 : 600;<br>
+      break;<br>
+<br>
    default:<br>
       /* 2 cycles:<br>
        * mul(8) g4<1>F g2<0,1,0>F      0.5F            { align1 WE_normal 1Q };<br>
--<br>
1.8.3.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>