<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<blockquote class="quotableTextTraining" style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span lang="fr">
<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0">If you wanted to hint</p>
<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0">to the compiler that we should use scalable vectors with my proposal you’d</p>
<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0">simply add an extra pragma, i.e.</p>
<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0"> </p>
<p style="font-size:11pt;font-family:Calibri,sans-serif;margin:0"><span lang="fr">#clang loop vectorize_predicate(enable) vectorize_width(scalable)</span></p>
</span></div>
</blockquote>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Ah yes, that might have been the thing that I missed, but that would indeed then be equivalent with:
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span lang="fr"><span lang="fr">#clang loop vectorize_predicate(enable) vectorize_style(scalable)</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I think that leaves us with 2 options that can express the same things, i.e. change or introduce:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
1) <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div style="color:black;font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
vectorize_width(VF, fixed|scalable)<br>
</div>
<div style="color:black;font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
vectorize_width(fixed|scalable)</div>
<div style="color:black;font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
vectorize_width(VF)<br>
</div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
2) <br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
vectorize_style(fixed|scalable)</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
And then it's probably more of a style question and not that important if there are no implementation or usability issues overloading vectorize_width.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Sjoerd.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span lang="fr"></span><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> David Sherwood <David.Sherwood@arm.com><br>
<b>Sent:</b> 25 November 2020 15:50<br>
<b>To:</b> Sjoerd Meijer <Sjoerd.Meijer@arm.com>; cfe-dev@lists.llvm.org <cfe-dev@lists.llvm.org><br>
<b>Cc:</b> Paul Walker <Paul.Walker@arm.com>; Sander De Smalen <Sander.DeSmalen@arm.com><br>
<b>Subject:</b> RE: Proposed changes to vectorize_width #pragma</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:DengXian}
@font-face
{font-family:Calibri}
@font-face
{}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:blue;
text-decoration:underline}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
p.x_xmsoplaintext, li.x_xmsoplaintext, div.x_xmsoplaintext
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
span.x_EmailStyle22
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-size:10.0pt}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.x_WordSection1
{}
-->
</style>
<div lang="EN-GB" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Sjoerd,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">As I understand it the interleave count is orthogonal to the vectorization factor and</p>
<p class="x_MsoNormal">one does not imply the other. I think the clang documentation gives an example of</p>
<p class="x_MsoNormal">this:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> #pragma clang loop vectorize_width(2)</p>
<p class="x_MsoNormal"> #pragma clang loop interleave_count(2)</p>
<p class="x_MsoNormal"> for(...) {</p>
<p class="x_MsoNormal"> ...</p>
<p class="x_MsoNormal"> }</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Also, I believe that each pragma that we set is a hint for one unit of the</p>
<p class="x_MsoNormal">loop vectorizer. It is true that vectorize_predicate enables vectorization, but</p>
<p class="x_MsoNormal">the vectorizer will always choose what it thinks is the most profitable</p>
<p class="x_MsoNormal">vectorization factor, which could be fixed or scalable. If you wanted to hint</p>
<p class="x_MsoNormal">to the compiler that we should use scalable vectors with my proposal you’d</p>
<p class="x_MsoNormal">simply add an extra pragma, i.e.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span lang="FR">#clang loop vectorize_predicate(enable) vectorize_width(scalable)</span></p>
<p class="x_MsoNormal"><span lang="FR"> </span></p>
<p class="x_MsoNormal">Kind Regards,</p>
<p class="x_MsoNormal">David.</p>
<p class="x_MsoNormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Sjoerd Meijer <Sjoerd.Meijer@arm.com>
<br>
<b>Sent:</b> 25 November 2020 13:14<br>
<b>To:</b> cfe-dev@lists.llvm.org; David Sherwood <David.Sherwood@arm.com><br>
<b>Subject:</b> Re: Proposed changes to vectorize_width #pragma</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Hi David,</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Thanks for bringing this up here. We have discussed this already on
<a href="https://reviews.llvm.org/D89031">https://reviews.llvm.org/D89031</a> and a bit offline, and it would be good to get some other opinions on this too.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">What we achieve with this extension is that we can toggle fixed/scalable vectorisation. The proposal is to add this property to vectorize_width, because it kind of defines the VectorType which
consists of the elementcount and the scalable/fixed part, which sounds reasonable. However, there are other loop pragmas that (implicitly) enable vectorisation:</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">#pragma clang loop interleave_count(some-number)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">or</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">#pragma clang loop vectorize_predicate(enable)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">for which you may want to toggle fixed|scalable vectorisation. If this is correct, then I think the current proposal/implementation is incomplete and/or inconsistent.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">I think your own suggestion was to introduce a vectorization_style(enable|disable) at some point, but my proposal would be to use that instead of adjusting vectorize_width as that would address
the issue incompleteness/inconsistency issue. Besides this, but more subjective, I don't see all the new combinations of vectorize_width() as making things clearer:</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">vectorize_width(VF)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">vectorize_width(VF, fixed|scalable)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">vectorize_width(fixed|scalable)</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Probably the implementation of adding vectorization_style(enable|disable) is easier and less contentious than adjusting an existing one, so all together I don't see why the approach of adjusting
vectorize_wdith would be preferred. But I might be wrong, might be missing something, so welcome other views on this.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Cheers,</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Sjoerd.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> cfe-dev <<a href="mailto:cfe-dev-bounces@lists.llvm.org">cfe-dev-bounces@lists.llvm.org</a>> on behalf of David Sherwood via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Sent:</b> 24 November 2020 09:04<br>
<b>To:</b> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> [cfe-dev] Proposed changes to vectorize_width #pragma</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi,</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">At the moment the vectorize_width(X) #pragma is used to provide hints to LLVM</p>
<p class="x_xmsonormal">about which vectorisation factor to use. The unsigned argument ‘X’ used to match</p>
<p class="x_xmsonormal">the NumElements property in the VectorType class, however VectorType is now</p>
<p class="x_xmsonormal">defined in terms of a ElementCount class.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I’d like to propose an extension to the vectorize_width #pragma that now takes</p>
<p class="x_xmsonormal">an optional second parameter of ‘fixed’ or ‘scalable’ that matches up with</p>
<p class="x_xmsonormal">ElementCount. When not specified the default value would be ‘fixed’. A few</p>
<p class="x_xmsonormal">examples of how this would look like are shown below:</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsoplaintext"> // Vectorize the loop with <4 x eltty></p>
<p class="x_xmsoplaintext"> #pragma clang loop vectorize_width(4)</p>
<p class="x_xmsoplaintext"> #pragma clang loop vectorize_width(4, fixed)</p>
<p class="x_xmsoplaintext"> </p>
<p class="x_xmsoplaintext"> // Vectorize the loop with <vscale x 4 x eltty></p>
<p class="x_xmsoplaintext"> #pragma clang loop vectorize_width(4, scalable)</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">As a further extension I’d also like to permit vectorize_width(fixed|scalable) to</p>
<p class="x_xmsonormal">allow users to hint at the type of vector used without specifying the</p>
<p class="x_xmsonormal">vectorisation factor. Examples of this would be:</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsoplaintext"> // Vectorize the loop with <N x eltty> for a profitable N</p>
<p class="x_xmsoplaintext"> #pragma clang loop vectorize_width(fixed)</p>
<p class="x_xmsoplaintext"> </p>
<p class="x_xmsoplaintext"> // Vectorize the loop with <vscale x N x eltty> for a profitable N</p>
<p class="x_xmsoplaintext"> #pragma clang loop vectorize_width(scalable)</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Any thoughts you have would be much appreciated!</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Kind Regards,</p>
<p class="x_xmsonormal">David Sherwood.</p>
<p class="x_xmsonormal"> </p>
</div>
</div>
</div>
</div>
</body>
</html>