<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 7, 2019, 09:21 Simon Moll <<a href="mailto:moll@cs.uni-saarland.de">moll@cs.uni-saarland.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
On 2/7/19 6:08 PM, David Greene wrote:<br>
> Jacob Lifshay <<a href="mailto:programmerjake@gmail.com" target="_blank" rel="noreferrer">programmerjake@gmail.com</a>> writes:<br>
><br>
>> So it would be handy for the vector length on evl intrinsics to be in<br>
>> units of the mask length so we don't have to pattern match a division<br>
>> in the backend. We could have 2 variants of the vector length<br>
>> argument, one in terms of the data vector and one in terms of the mask<br>
>> vector. we could legalize the mask vector variant for those<br>
>> architectures that need it by pulling the multiplication out and<br>
>> switching to the data vector variants.<br>
> Would it make sense to have two different intrinsics?<br>
><br>
> # "Normal" form, L is in terms of flat vector length.<br>
> <scalable 2 x float> evl.fsub(<scalable 2 x float> %x,<br>
>                                <scalable 2 x float> %y,<br>
>                                <scalable 2 x i1> %M, i32 %L)<br>
><br>
> # "Sub-vector" form, L is in terms of sub-vectors elements.<br>
> <scalable 1 x <2 x float>> evl.fsub(<scalable 1 x <2 x float>> %x,<br>
>                                      <scalable 1 x <2 x float>> %y,<br>
>                                      <scalable 1 x <2 x i1>> %M, i32 %L<br>
><br>
> Overloading types to mean two very different things is confusing to me.<br>
><br>
>                             -David<br>
<br>
Allowing vector types as vector elements would solve the vlen <br>
interpretation issue in an elegant way.<br></blockquote></div></div><div dir="auto">This seems like the best solution, though maybe out of scope of the current evl proposal. This would also create a decent IR representation of a matrix or other 2D vector: matMxN would be <N x <M x float>>.</div><div dir="auto">While we're adding this, it may be a good idea to go all in and just lift the restriction on vectors containing other non-scalable vectors, so you could do something like: <scalable 1 x <4 x <4 x float>>> to be a scalable vector of 4x4 matrices.</div><div dir="auto">all the standard arithmetic operations (fadd, fmul, etc.) would still be the standard operations (so fmul would be element-wise, not matrix multiplication), we would, as a separate proposal, add matrix multiplication as a separate intrinsic.</div><div dir="auto"><br></div><div dir="auto">Most operations would treat a <scalable I x <J x <K x <L x ... type ...>>>> as a <scalable I x <(J * K * L * ...) x type>> for everything but result type.</div><div dir="auto"><br></div><div dir="auto">We could have methods on Type that return the next level down vector type, the scalar type under the vector type nest (probably getScalarType), and the number of total scalar elements (getVectorNumElementsRecursive) assuming VL is the first valid non-zero integer: so <span style="font-family:sans-serif"><scalable I x <J x <K x <L x ... type ...>>>> returns I * J * K * L * ...</span></div><div dir="auto"><span style="font-family:sans-serif">We will probably want to cache the innermost scalar type and the number of total scalar elements. Since we want to avoid adding another field to Type, we could have vector types store the </span><span style="font-family:sans-serif">getVectorNumElementsRecursive</span><span style="font-family:sans-serif">  instead of the </span><span style="font-family:sans-serif">getVectorNumElements value, for </span><span style="font-family:sans-serif">getVectorNumElements we would divide the stored value by the stored value of the next level down.</span></div><div dir="auto"><br></div><div dir="auto">There would be a pass to convert vector kinds for different targets.</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Simon<br>
<br>
-- <br>
<br>
Simon Moll<br>
Researcher / PhD Student<br>
<br>
Compiler Design Lab (Prof. Hack)<br>
Saarland University, Computer Science<br>
Building E1.3, Room 4.31<br>
<br>
Tel. +49 (0)681 302-57521 : <a href="mailto:moll@cs.uni-saarland.de" target="_blank" rel="noreferrer">moll@cs.uni-saarland.de</a><br>
Fax. +49 (0)681 302-3065  : <a href="http://compilers.cs.uni-saarland.de/people/moll" rel="noreferrer noreferrer" target="_blank">http://compilers.cs.uni-saarland.de/people/moll</a><br>
<br>
</blockquote></div></div></div>