VectorAPI and C2 compiler

joserz at linux.ibm.com joserz at linux.ibm.com
Tue Jan 12 19:11:46 UTC 2021


Hi Paul,

Thank you for your response!! :-)

This is my test case for x86 (basically got from VectorReshapeTests.java).
```
import java.io.IOException;
import java.util.Arrays;
import jdk.incubator.vector.IntVector;
import jdk.incubator.vector.ShortVector;
import jdk.incubator.vector.DoubleVector;
import jdk.incubator.vector.VectorSpecies;
import jdk.incubator.vector.LongVector;

class Cast
{
    static void vectorCastIntToShort(VectorSpecies<Integer> i,
                                     VectorSpecies<Short> s,
                                     int[] input,
                                     short[] output)
    {
        IntVector iv = IntVector.fromArray(i, input, 0);
        ShortVector sv = (ShortVector) iv.castShape(s, 0);
        sv.intoArray(output, 0);
    }

    public static void main(String[] args) throws IOException
    {
        for (int j = 0; j < 1_000_000; j++) {
            int[] iin128 = {25, -398, 415, Short.MAX_VALUE + 2};
            short[] sout64 = new short[ShortVector.SPECIES_64.length()];

            vectorCastIntToShort(IntVector.SPECIES_128,
                                 ShortVector.SPECIES_64,
                                 iin128, sout64);
        }

        //System.out.println(Arrays.toString(iin128));
        //System.out.println(Arrays.toString(sout64));
    }
}
```

Then, after compiling and running like:
$ javac Cast.java
$ java -Xcomp -XX:-TieredCompilation -XX:CompileThreshold=1 -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -XX:+PrintOptoAssembly -XX:+UnlockExperimentalVMOptions -XX:+EnableVectorSupport -XX:+EnableVectorReboxing -XX:+EnableVectorAggressiveReboxing -XX:UseAVX=2 Cast

I was expecting to see instructions from x86.ad, like "vector_cast_i2x" being printed but it seems that VectorCastI2X pattern isn't be generated because I see compiler C2 kicking in during the program execution.

Thank you very much!

Jose


On Tue, Jan 12, 2021 at 09:07:49AM -0800, Paul Sandoz wrote:
> Hi Jose,
> 
> Shifting over to panama-dev (bcc’ing discuss at openjdk.java.net <mailto:discuss at openjdk.java.net>).
> 
> Can you share a complete example on x86 that is not producing what you expect?
> 
> I suspect in the PPC case some wiring up to the vector intrinsics are missing.
> 
> Paul.
> 
> > On Jan 11, 2021, at 1:07 PM, joserz at linux.ibm.com wrote:
> > 
> > Hello team,
> > 
> > I'm currently working on the VectorAPI support to PowerPC64 but none of my instructions, defined in ppc64.ad, gets executed. I decided to take a look at x86, but again no Vector instructions printed.
> > 
> > Basically, I have a test case like this:
> >        for (int j = 0; j < 1_000_000; j++) {
> >            int[] iin128 = {25, -398, 415, Short.MAX_VALUE + 2};
> >            short[] sout64 = new short[ShortVector.SPECIES_64.length()];
> > 
> >            vectorCastIntToShort(IntVector.SPECIES_128,
> >                                 ShortVector.SPECIES_64,
> >                                 iin128, sout64);
> >        }
> > 
> > That I execute like:
> >        java -Xcomp -XX:-TieredCompilation -XX:CompileThreshold=1 \
> >             -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly \
> >             -XX:+PrintOptoAssembly -XX:+UnlockExperimentalVMOptions \
> >             -XX:+EnableVectorSupport -XX:+EnableVectorReboxing \
> >             -XX:+EnableVectorAggressiveReboxing -XX:UseAVX=2 Cast
> > 
> > And expected to see any of `format %{ "vector_* ... %}` instructions, defined in x86.ad, being printed.
> > 
> > Am I missing anything?
> > 
> > Thank you,
> > 
> > Jose R Ziviani
> 


More information about the panama-dev mailing list