<p dir="ltr"><br>
On Aug 12, 2015 4:41 AM, "Francisco Jerez" <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> wrote:<br>
><br>
> Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> writes:<br>
><br>
> > Neil Roberts <<a href="mailto:neil@linux.intel.com">neil@linux.intel.com</a>> writes:<br>
> ><br>
> >> Ok, that makes sense, thanks for the detailed explanation. I think<br>
> >> you're right, given the extra restrictions avoiding the integer dword<br>
> >> multiplication seems like the simplest solution.<br>
> >><br>
> >> I can't say that I fully understand what the documentation is trying to<br>
> >> say here. Does it mean that the horizontal strides must be set such that<br>
> >> each element in the source is offset to the same qword within its<br>
> >> register as the corresponding element in the destination?<br>
> >><br>
> ><br>
> > The way I understand it one's required to:<br>
> >  - Align the stride in bytes (i.e. horizontal stride times the size of<br>
> >    the register type) between components of an individual source or<br>
> >    destination to a multiple of 64b (if the register region is more than<br>
> >    a single scalar that is).  The multiple must be the same for all<br>
> >    non-scalar sources and the destination.<br>
> >  - Use the same sub-register offsets for all non-scalar sources and the<br>
> >    destination.<br>
> >  - Set vertical stride to horizontal stride times width.<br>
> >  - Don't use indirect addressing or ARF registers.<br>
> ><br>
> >> I tried changing the test case¹ so that one of the sources comes from a<br>
> >> uniform. That would make the register for the uniform source be a scalar<br>
> >> and thus all of its elements would come from the first qword, whereas<br>
> >> for the destination the elements would be written to different qwords.<br>
> >> That ends up with an instruction like this:<br>
> >><br>
> >> mul(16)         g120<1>D        g9<8,8,1>D      g6<0,1,0>D { align1<br>
> >>                                                             1H compacted };<br>
> >><br>
> ><br>
> > Yeah, this should definitely violate the alignment rule on both the<br>
> > destination and first source.<br>
> ><br>
> >> However, the test still passes on my BXT so I've probably misunderstood<br>
> >> something. On the other hand this does look similar to the stride you<br>
> >> had in your example instruction that the simulator complained about.<br>
> >><br>
> >> Given that the documentation and simulator implies this shouldn't work<br>
> >> I'm happy to leave this patch and I'm not suggesting we do anything now.<br>
> >><br>
> ><br>
> > Honestly I'm also not 100% sure if this restriction really applies to<br>
> > all BXT hardware or if it's specific to some preproduction steppings --<br>
> > The documentation seems to imply the former, but I guess it could be<br>
> > wrong.<br>
> ><br>
> I forgot to mention that when I tried this yesterday the simulator<br>
> seemed to complain about the alignment rule regardless of the stepping<br>
> for all the ones it recognised (a-c IIRC).</p>
<p dir="ltr">Have you actually seen this fail on hardware?  I'm guessing no since BXT is still hard to come by.  If it works on silicone, I'd be tempted to leave it alone. I guess it does make it a bit difficult to debug other things if the simulator is complaining about the multiply instruction.<br>
--Jason</p>
<p dir="ltr">> >> Regards,<br>
> >> - Neil<br>
> >><br>
> >> 1. <a href="https://github.com/bpeel/piglit/blob/test-integer-multiply-uniform/tests/general/mult32.c">https://github.com/bpeel/piglit/blob/test-integer-multiply-uniform/tests/general/mult32.c</a><br>
> >><br>
> >> Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> writes:<br>
> >><br>
> >>> Neil Roberts <<a href="mailto:neil@linux.intel.com">neil@linux.intel.com</a>> writes:<br>
> >>><br>
> >>>> Are you sure this patch is necessary? The documentation for the multiply<br>
> >>>> instruction on BDW+ says:<br>
> >>>><br>
> >>>> SourceType :       *D<br>
> >>>> DestinationType :  *D<br>
> >>>> Project :  EXCLUDE(CHV)<br>
> >>>><br>
> >>>> This to me implies that it should work on BXT because it doesn't say<br>
> >>>> EXCLUDE(BXT).<br>
> >>>><br>
> >>><br>
> >>> In fact both CHV and BXT *can* support 32x32 multiplication, that's not<br>
> >>> really the reason that motivated this patch -- The problem is that 32x32<br>
> >>> multiplication has QWORD execution type which has several restrictions<br>
> >>> on CHV and BXT, the annoying one is:<br>
> >>><br>
> >>> "CHV, BXT<br>
> >>><br>
> >>> When source or destination datatype is 64b or operation is integer DWord<br>
> >>> multiply, regioning in Align1 must follow these rules:<br>
> >>><br>
> >>>     Source and Destination horizontal stride must be aligned to the same<br>
> >>>     qword.<br>
> >>><br>
> >>>     Example:<br>
> >>> [...]<br>
> >>>     // mul (4) r10.0<2>:d r11.0<8;4,2>:d r12.0<8;4,2>:d // Source and Destination stride must be 2 since the execution type is Qword."<br>
> >>><br>
> >>> So it sounds like we could use the native 32x32 multiply with some<br>
> >>> additional effort to pass the arguments with the correct stride, but<br>
> >>> it's not clear to me whether the solution would be any more better than<br>
> >>> splitting up the multiply into 32x16 multiplies, so doing the same as in<br>
> >>> CHV and pre-Gen8 seemed like the most KISS solution for now.<br>
> >>><br>
> >>>> I made a little test case and ran it on my BXT and it seems to work even<br>
> >>>> without this patch. I looked at the assembler source and it is<br>
> >>>> definitely doing a MUL instruction with D types for the dst and two<br>
> >>>> sources.<br>
> >>>><br>
> >>>> <a href="https://github.com/bpeel/piglit/blob/test-integer-multiply/tests/general/mult32.c">https://github.com/bpeel/piglit/blob/test-integer-multiply/tests/general/mult32.c</a><br>
> >>>><br>
> >>> Hmm, I guess the docs could be wrong, but I'm not sure what the<br>
> >>> consequences would be of violating the alignment rule, I guess the<br>
> >>> failure may be non-deterministic.  What stepping of BXT did you test<br>
> >>> this on?<br>
> >>><br>
> >>>> Regards,<br>
> >>>> - Neil<br>
> >>>><br>
> >>>> Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> writes:<br>
> >>>><br>
> >>>>> AFAIK BXT has the same annoying alignment limitation as CHV on the<br>
> >>>>> source register regions of 32x32 bit MULs, give it the same treatment.<br>
> >>>>> ---<br>
> >>>>>  src/mesa/drivers/dri/i965/brw_fs.cpp | 4 ++--<br>
> >>>>>  1 file changed, 2 insertions(+), 2 deletions(-)<br>
> >>>>><br>
> >>>>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> >>>>> index 244f299..fc9f007 100644<br>
> >>>>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> >>>>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> >>>>> @@ -3126,9 +3126,9 @@ fs_visitor::lower_integer_multiplication()<br>
> >>>>>     bool progress = false;<br>
> >>>>><br>
> >>>>>     /* Gen8's MUL instruction can do a 32-bit x 32-bit -> 32-bit operation<br>
> >>>>> -    * directly, but Cherryview cannot.<br>
> >>>>> +    * directly, but CHV/BXT cannot.<br>
> >>>>>      */<br>
> >>>>> -   if (devinfo->gen >= 8 && !devinfo->is_cherryview)<br>
> >>>>> +   if (devinfo->gen >= 8 && !devinfo->is_cherryview && !devinfo->is_broxton)<br>
> >>>>>        return false;<br>
> >>>>><br>
> >>>>>     foreach_block_and_inst_safe(block, fs_inst, inst, cfg) {<br>
> >>>>> --<br>
> >>>>> 2.4.6<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">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><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">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
><br>
</p>