Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To address some of the scepticism expressed by others here I suggest anyone who wants to prove to themselves or other use the following method:</p> <ul> <li>Create a JMH project</li> <li>Write a small snippet of vectorizable math.</li> <li>Run their benchmark flipping between -XX:-UseSuperWord and -XX:+UseSuperWord(default)</li> <li>If no difference in performance is observed, your code probably didn't get vectorized</li> <li>To make sure, run your benchmark such that it prints out the assembly. On linux you can enjoy the perfasm profiler('-prof perfasm') have a look and see if the instructions you expect get generated.</li> </ul> <p>Example:</p> <pre><code>@Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) //makes looking at assembly easier public void inc() { for (int i=0;i&lt;a.length;i++) a[i]++;// a is an int[], I benchmarked with size 32K } </code></pre> <p>The result with and without the flag (on recent Haswell laptop, Oracle JDK 8u60): -XX:+UseSuperWord : 475.073 ± 44.579 ns/op (nanoseconds per op) -XX:-UseSuperWord : 3376.364 ± 233.211 ns/op</p> <p>The assembly for the hot loop is a bit much to format and stick in here but here's a snippet(hsdis.so is failing to format some of the AVX2 vector instructions so I ran with -XX:UseAVX=1): -XX:+UseSuperWord(with '-prof perfasm:intelSyntax=true')</p> <pre><code> 9.15% 10.90% │││ │↗ 0x00007fc09d1ece60: vmovdqu xmm1,XMMWORD PTR [r10+r9*4+0x18] 10.63% 9.78% │││ ││ 0x00007fc09d1ece67: vpaddd xmm1,xmm1,xmm0 12.47% 12.67% │││ ││ 0x00007fc09d1ece6b: movsxd r11,r9d 8.54% 7.82% │││ ││ 0x00007fc09d1ece6e: vmovdqu xmm2,XMMWORD PTR [r10+r11*4+0x28] │││ ││ ;*iaload │││ ││ ; - psy.lob.saw.VectorMath::inc@17 (line 45) 10.68% 10.36% │││ ││ 0x00007fc09d1ece75: vmovdqu XMMWORD PTR [r10+r9*4+0x18],xmm1 10.65% 10.44% │││ ││ 0x00007fc09d1ece7c: vpaddd xmm1,xmm2,xmm0 10.11% 11.94% │││ ││ 0x00007fc09d1ece80: vmovdqu XMMWORD PTR [r10+r11*4+0x28],xmm1 │││ ││ ;*iastore │││ ││ ; - psy.lob.saw.VectorMath::inc@20 (line 45) 11.19% 12.65% │││ ││ 0x00007fc09d1ece87: add r9d,0x8 ;*iinc │││ ││ ; - psy.lob.saw.VectorMath::inc@21 (line 44) 8.38% 9.50% │││ ││ 0x00007fc09d1ece8b: cmp r9d,ecx │││ │╰ 0x00007fc09d1ece8e: jl 0x00007fc09d1ece60 ;*if_icmpge </code></pre> <p>Have fun storming the castle!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload