<div dir="ltr">Hi Erik,<div><br></div><div>Thanks for your reassuring reply. </div><div><br></div><div>&gt; Did you look at the generated code? Try calling the compiler with the &quot;-S&quot; option to get assembler output, or use &quot;objdump -d&quot; to disassemble the object file. You should see lots of &quot;ymms&quot; mentioned in your memory access and arithmetic operations.</div><div><br></div><div>Yep, as I mentioned, the `-S -g` commented assembler indeed did output lots of &quot;ymms&quot; in the innermost loop. Also, the annotated assembler on the innermost loop gave precisely the same remark about not being able to vectorize an operation:</div><div><br></div><div>                # optimization report<br>                # LOOP WITH USER VECTOR INTRINSICS<br>                # %s was not vectorized: operation cannot be vectorized<br>                # VECTOR TRIP COUNT IS ESTIMATED CONSTANT<br></div><div><br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px">-Zach</div><div style="font-size:12.8px"><br></div><span style="font-size:12.8px">*     *     *</span><br style="font-size:12.8px"><span style="font-size:12.8px">Prof. Zachariah Etienne</span><br style="font-size:12.8px"><div style="font-size:12.8px">West Virginia University</div><div><font color="#0000ee"><u><a href="https://math.wvu.edu/~zetienne/" target="_blank">https://math.wvu.edu/~zetienne/</a></u></font></div><div><a href="https://blackholesathome.net" style="font-size:12.8px" target="_blank">https://blackholesathome.net</a><br></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 23, 2019 at 11:08 AM Erik Schnetter &lt;<a href="mailto:schnetter@gmail.com">schnetter@gmail.com</a>&gt; 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">Zach<br>
<br>
The compiler is correct: The intrinsic _mm256_loadu_pd cannot be<br>
vectorized because ... it is already vectorized! If you are using<br>
intrinsics for vectorization, then the compiler does not need to<br>
perform any work.<br>
<br>
Did you look at the generated code? Try calling the compiler with the<br>
&quot;-S&quot; option to get assembler output, or use &quot;objdump -d&quot; to<br>
disassemble the object file. You should see lots of &quot;ymms&quot; mentioned<br>
in your memory access and arithmetic operations.<br>
<br>
-erik<br>
<br>
On Tue, Jul 23, 2019 at 9:35 AM Zach Etienne &lt;<a href="mailto:zachetie@gmail.com" target="_blank">zachetie@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi all,<br>
&gt;<br>
&gt; I used NRPy+ to create a &quot;minimal example&quot; SIMD-intrinsics-enabled PDE solver kernel -- solving the scalar wave equation in 3 spatial dimensions.<br>
&gt;<br>
&gt; With AVX256+FMA intrinsics, neither Intel nor GNU compilers report success at fully vectorizing the RHS eval loop. E.g., the Intel compiler yields the cryptic message when compiling the innermost loop:<br>
&gt;<br>
&gt;          remark #15310: loop was not vectorized: operation cannot be vectorized   [ ScalarWave/ScalarWave_RHSs-SIMD.h(31,52) ]<br>
&gt;<br>
&gt; The line it&#39;s referring to has to do with loading data from memory _mm256_loadu_pd(&amp;a).<br>
&gt;<br>
&gt; The entire source code is attached to this email, and I&#39;ve been compiling using<br>
&gt;<br>
&gt; icc -restrict -align -qopenmp -xHost -O2 -qopt-report=5 -qopt-report-phase ipo -qopt-report-phase vec -vec-threshold1 -qopt-prefetch=4 ScalarWave_Playground-SIMD.c -o ScalarWave_Playground-SIMD<br>
&gt;<br>
&gt; for Intel 19, and for GNU (gcc 9):<br>
&gt;<br>
&gt; gcc -fsimd-cost-model=unlimited -Ofast -fopenmp -march=native ScalarWave_Playground-SIMD.c -fopt-info-vec-optimized-missed -o ScalarWave_Playground-SIMD -lm<br>
&gt;<br>
&gt; When I look at the Intel-generated annotated assembly of the innermost RHS loop (using icc -S -g -restrict -align -qopenmp -xHost -O2 -qopt-report=5 -qopt-report-phase ipo -qopt-report-phase vec -vec-threshold1 -qopt-prefetch=4 ScalarWave_Playground-SIMD.c), I see many 256-bit &quot;ymmX&quot;&#39;s and corresponding instructions that seem to be consistent with the *math* intrinsics. I can&#39;t decipher much beyond that, though. Notably I didn&#39;t see any assembler instructions that look like _mm256_loadu_pd().<br>
&gt;<br>
&gt; I fiddled around a bit with what goes inside the _mm256_loadu_pd(), just to see what might be causing the cryptic remark above. I found that if I remove dependence on the innermost loop variable &quot;i0&quot; on certain (obviously this would break the functionality, but the compiler doesn&#39;t care), then it is capable of vectorizing that loop.<br>
&gt;<br>
&gt; Note that the version of the code that does not use intrinsics is about 1.8x slower with either compiler, so I think intrinsics are providing some good benefit. However, I am discouraged by the compiler telling me that the inner loop cannot be fully vectorized.<br>
&gt;<br>
&gt; Any tips would be greatly appreciated!<br>
&gt;<br>
&gt; -Zach<br>
&gt;<br>
&gt; *     *     *<br>
&gt; Prof. Zachariah Etienne<br>
&gt; West Virginia University<br>
&gt; <a href="https://math.wvu.edu/~zetienne/" rel="noreferrer" target="_blank">https://math.wvu.edu/~zetienne/</a><br>
&gt; <a href="https://blackholesathome.net" rel="noreferrer" target="_blank">https://blackholesathome.net</a><br>
&gt; _______________________________________________<br>
&gt; performanceoptimization-wg mailing list<br>
&gt; <a href="mailto:performanceoptimization-wg@einsteintoolkit.org" target="_blank">performanceoptimization-wg@einsteintoolkit.org</a><br>
&gt; <a href="http://lists.einsteintoolkit.org/mailman/listinfo/performanceoptimization-wg" rel="noreferrer" target="_blank">http://lists.einsteintoolkit.org/mailman/listinfo/performanceoptimization-wg</a><br>
<br>
<br>
<br>
-- <br>
Erik Schnetter &lt;<a href="mailto:schnetter@gmail.com" target="_blank">schnetter@gmail.com</a>&gt;<br>
<a href="http://www.perimeterinstitute.ca/personal/eschnetter/" rel="noreferrer" target="_blank">http://www.perimeterinstitute.ca/personal/eschnetter/</a><br>
</blockquote></div>