<div dir="ltr"><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">hameeza ahmed</b> <span dir="ltr"><<a href="mailto:hahmed2305@gmail.com">hahmed2305@gmail.com</a>></span><br>Date: Sat, Jun 24, 2017 at 7:21 AM<br>Subject: Re: [llvm-dev] AVX Scheduling and Parallelism<br>To: Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>><br><br><br><div dir="ltr"><div>int a[100351], b[100351], c[100351];</div><div>foo () {</div><div>int i;</div><div>for (i=0; i<100351; i++) {</div><div>a[i] = b[i] + c[i];</div><div>}</div><div>}</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jun 24, 2017 at 7:16 AM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>It is possible that the issue with scheduling is constrained due
to pointer-aliasing assumptions. Could you share the source for
the loop in question?</p>
<p>RIP-relative indexing, as I recall, is a feature of
position-independent code. Based on what's below, it might cause
problems by making the instruction encodings large. cc'ing some
Intel folks for further comments.</p>
<p> -Hal<br>
</p><div><div class="m_-1589879501904212397h5">
<div class="m_-1589879501904212397m_7604358723266123794moz-cite-prefix">On 06/23/2017 09:02 PM, hameeza ahmed
via llvm-dev wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="m_-1589879501904212397h5">
<div dir="ltr">Hello,
<div><br>
</div>
<div>After generating AVX code for large no of iterations i came
to realize that it still uses only 2 registers zmm0 and zmm1
when the loop urnroll factor=1024,</div>
<div><br>
</div>
<div>i wonder if this register allocation allows operations in
parallel?</div>
<div><br>
</div>
<div>Also i know all the elements within a single vector
instruction are computed in parallel but does the elements of
multiple instructions computed in parallel? like are 2 vmov
with different registers executed in parallel? it can be
because each core has an AVX unit. does compiler exploit it?</div>
<div><br>
</div>
<div><br>
</div>
<div>secondly i am generating assembly for intel and there are
some offset like rip register or some constant addition in
memory index. why is that so?</div>
<div>eg.1</div>
<div><br>
</div>
<div>
<div><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmm0,
zmmword ptr [rip + c]</div>
<div><span style="white-space:pre-wrap"> </span>vpaddd<span style="white-space:pre-wrap"> </span>zmm0,
zmm0, zmmword ptr [rip + b]</div>
<div><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmmword
ptr [rip + a], zmm0</div>
<div><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmm0,
zmmword ptr [rip + c+64]</div>
<div><span style="white-space:pre-wrap"> </span>vpaddd<span style="white-space:pre-wrap"> </span>zmm0,
zmm0, zmmword ptr [rip + b+64]</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>and </div>
<div><br>
</div>
<div>eg. 2</div>
<div><br>
</div>
<div>
<div>mov<span style="white-space:pre-wrap"> </span>rax, -393216</div>
<div><span style="white-space:pre-wrap"> </span>.p2align<span style="white-space:pre-wrap"> </span>4,
0x90</div>
<div>.LBB0_1: # %vector.body</div>
<div> # =>This Inner
Loop Header: Depth=1</div>
<div><span style="white-space:pre-wrap"> </span><font color="#0000ff">vmovdqu32<span style="white-space:pre-wrap"> </span>zmm1,
zmmword ptr [rax + c+401344] ; load c[401344]
in zmm1</font></div>
<div><font color="#ff0000"><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmm0,
zmmword ptr [rax + c+401280] ;load b[401280]
in zmm0</font></div>
<div><font color="#0000ff"><span style="white-space:pre-wrap"> </span>vpaddd<span style="white-space:pre-wrap"> </span>zmm1,
zmm1, zmmword ptr [rax + b+401344] ;
zmm1<-zmm1+b[401344]</font></div>
<div><font color="#0000ff"><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmmword
ptr [rax + a+401344], zmm1 ; store zmm1 in
c[401344]</font></div>
</div>
<div>
<div><font color="#000000"><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmm1,
zmmword ptr [rax + c+401216]</font></div>
<div><font color="#ff0000"><span style="white-space:pre-wrap"> </span>vpaddd<span style="white-space:pre-wrap"> </span>zmm0,
zmm0, zmmword ptr [rax + b+401280] ;
zmm0<-zmm0+b[401280]</font></div>
<div><font color="#ff0000"><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmmword
ptr [rax + a+401280], zmm0 ; store zmm0 in
c[401280]</font></div>
<div><font color="#000000"><span style="white-space:pre-wrap"> </span>vmovdqu32<span style="white-space:pre-wrap"> </span>zmm0,
zmmword ptr [rax + c+401152]</font></div>
</div>
<div>........ in the remaining instructions also there is only
zmm0 and zmm1 used?</div>
<div><br>
</div>
<div>As you can see in the above examples there could be
multiple registers use. also i doubt if the above set of
repeating instructions in eg. 2 are executed in parallel? and
why repeat zmm0 and zmm1 cant it be more zmms and all in
parallel, mean the one w/o dependency. for eg in above example
blue has dependency in between and red has dependency among
each other they cant be executed in parallel but blue and red
can be executed in parallel?</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Please correct me if I am wrong.</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<fieldset class="m_-1589879501904212397m_7604358723266123794mimeAttachmentHeader"></fieldset>
<br>
</div></div><pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_-1589879501904212397m_7604358723266123794moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_-1589879501904212397m_7604358723266123794moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><span class="m_-1589879501904212397HOEnZb"><font color="#888888">
</font></span></pre><span class="m_-1589879501904212397HOEnZb"><font color="#888888">
</font></span></blockquote><span class="m_-1589879501904212397HOEnZb"><font color="#888888">
<br>
<pre class="m_-1589879501904212397m_7604358723266123794moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</font></span></div>
</blockquote></div><br></div>
</div></div></div><br></div>