<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 12, 2019 at 5:56 AM Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Empirical testing shows that gen8 has a bug where MAD instructions with<br>
a half-float source starting at a non-zero offset fail to execute<br>
properly.<br>
<br>
This scenario usually happened in SIMD8 executions, where we used to<br>
pack vector components Y and W in the second half of SIMD registers<br>
(therefore, with a 16B offset). It looks like we are not currently doing<br>
this any more but this would handle the situation properly if we ever<br>
happen to produce code like this again.<br>
<br>
v2 (Jason):<br>
- Move this workaround to the lower_regioning pass as an additional case<br>
to has_invalid_src_region()<br>
- Do not apply the workaround if the stride of the source operand is 0,<br>
testing suggests the problem doesn't exist in that case.<br>
<br>
Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com" target="_blank">topi.pohjolainen@intel.com</a>> (v1)<br>
---<br>
src/intel/compiler/brw_fs_lower_regioning.cpp | 39 +++++++++++++------<br>
1 file changed, 28 insertions(+), 11 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_fs_lower_regioning.cpp b/src/intel/compiler/brw_fs_lower_regioning.cpp<br>
index df50993dee6..7c70cfab535 100644<br>
--- a/src/intel/compiler/brw_fs_lower_regioning.cpp<br>
+++ b/src/intel/compiler/brw_fs_lower_regioning.cpp<br>
@@ -109,20 +109,37 @@ namespace {<br>
has_invalid_src_region(const gen_device_info *devinfo, const fs_inst *inst,<br>
unsigned i)<br>
{<br>
- if (is_unordered(inst)) {<br>
+ if (is_unordered(inst))<br>
return false;<br>
- } else {<br>
- const unsigned dst_byte_stride = inst->dst.stride * type_sz(inst->dst.type);<br>
- const unsigned src_byte_stride = inst->src[i].stride *<br>
- type_sz(inst->src[i].type);<br>
- const unsigned dst_byte_offset = reg_offset(inst->dst) % REG_SIZE;<br>
- const unsigned src_byte_offset = reg_offset(inst->src[i]) % REG_SIZE;<br>
<br>
- return has_dst_aligned_region_restriction(devinfo, inst) &&<br>
- !is_uniform(inst->src[i]) &&<br>
- (src_byte_stride != dst_byte_stride ||<br>
- src_byte_offset != dst_byte_offset);<br>
+ /* Empirical testing shows that Broadwell has a bug affecting half-float<br>
+ * MAD instructions when any of its sources has a non-zero offset, such<br>
+ * as:<br>
+ *<br>
+ * mad(8) g18<1>HF -g17<4,4,1>HF g14.8<4,4,1>HF g11<4,4,1>HF { align16 1Q };<br>
+ *<br>
+ * We used to generate code like this for SIMD8 executions where we<br>
+ * used to pack components Y and W of a vector at offset 16B of a SIMD<br>
+ * register. The problem doesn't occur if the stride of the source is 0.<br>
+ */<br>
+ if (devinfo->gen == 8 &&<br>
+ inst->opcode == BRW_OPCODE_MAD &&<br>
+ inst->src[i].type == BRW_REGISTER_TYPE_HF &&<br>
+ inst->src[i].offset > 0 &&<br>
+ inst->src[i].stride != 0) {<br></blockquote><div><br></div><div>The above assumes the register is a GRF. Perhaps we should make this assumption explicit? Or you can use some of curro's helpers and add another one to get the subreg offset. Also, the real problem here isn't offset > 0, it's offset % REG_SIZE > 0. If we have an array of 4 things, they'll be at offsets 0, 16, 32, and 48. We don't want an offset of 32 triggering it.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ return true;<br>
}<br>
+<br>
+ const unsigned dst_byte_stride = inst->dst.stride * type_sz(inst->dst.type);<br>
+ const unsigned src_byte_stride = inst->src[i].stride *<br>
+ type_sz(inst->src[i].type);<br>
+ const unsigned dst_byte_offset = reg_offset(inst->dst) % REG_SIZE;<br>
+ const unsigned src_byte_offset = reg_offset(inst->src[i]) % REG_SIZE;<br>
+<br>
+ return has_dst_aligned_region_restriction(devinfo, inst) &&<br>
+ !is_uniform(inst->src[i]) &&<br>
+ (src_byte_stride != dst_byte_stride ||<br>
+ src_byte_offset != dst_byte_offset);<br>
}<br>
<br>
/*<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></blockquote></div></div>