Vector.shiftER, Vector.shiftEL not working as expected.
Paul Sandoz
paul.sandoz at oracle.com
Tue Oct 10 19:06:44 UTC 2017
> On 10 Oct 2017, at 11:34, Lupusoru, Razvan A <razvan.a.lupusoru at intel.com> wrote:
>
> Hi Richard,
>
> As Paul noted, there is currently no x86 implementation for these and the operation is done with Java implementation. The work to support all of the API in a performant manner is ongoing and will occur through next few months.
>
> Once implemented, Elemental shifting will be supported using x86 instructions vpslld and vpsrld (for Integers). http://www.felixcloutier.com/x86/PSLLW:PSLLD:PSLLQ.html
> Elemental rotate will be supported using a mix of vpslld and vpsrld plus vpand.
>
IIUC correctly those instructions are for logical shift operations on elements and are not a lane-wise shift. I am guessing for the latter some form of permute would be used.
So IIUC the following operations:
//Elemental shifting
Vector<E, S> rotateEL(int i); //Rotate elements left
Vector<E, S> rotateER(int i); //Rotate elements right
Vector<E, S> shiftEL(int i); //shift elements left
Vector<E, S> shiftER(int i); //shift elements right
are sugar for the more general:
Vector<E, S> swizzle(Shuffle<E, S> s);
Paul.
> --Razvan
>
> -----Original Message-----
> From: panama-dev [mailto:panama-dev-bounces at openjdk.java.net] On Behalf Of Paul Sandoz
> Sent: Tuesday, October 10, 2017 11:23 AM
> To: Richard Startin <richard at openkappa.co.uk>
> Cc: panama-dev at openjdk.java.net
> Subject: Re: Vector.shiftER, Vector.shiftEL not working as expected.
>
> Hi Richard,
>
> Thanks for reporting. It's a silly bug in the Java implementation as these are not intensified (they lack the @HotSpotIntrinsicCandidate annotation). I just pushed a fix. We currently lack docs and testing, the latter should be easily amenable to some combinator approach.
>
> These methods shift elements left or right into different lanes. I am not familiar with specific Intel instructions that might do this can you provide some links?
>
> They are not btiwise operations that shift the bits of the elements. The bitwise and logical operations reside on the bitwise compatible vectors (namely for byte, short, int and long [*])
>
> Paul.
>
> [*] It's an open question whether we should have a BitWise and FloatingPoint type in the hierarchy.
>
>
>> On 8 Oct 2017, at 11:03, Richard Startin <richard at openkappa.co.uk> wrote:
>>
>> What are the methods shiftEL and shiftER supposed to do? I read these as "shift elements left/right" and expect them to behave like the PS[L|R]L[W|D|Q] instructions.
>>
>>
>> Specifically, I expected the code below to print:
>>
>>
>> [2, 3, 4, 5, 6, 7, 8, 0]
>>
>> [0, 1, 2, 3, 4, 5, 6, 7]
>>
>>
>> int[] ymmword = new int[] {1, 2, 3, 4, 5, 6, 7, 8};
>>
>> int[] result = new int[8];
>>
>> IntVector.IntSpecies<Shapes.S256Bit> species = (IntVector.IntSpecies<Shapes.S256Bit>)Vector.speciesInstance(Integer.class, Shapes.S_256_BIT);
>>
>> IntVector<Shapes.256Bit> vector1 = (IntVector<Shapes.256Bit>)species.fromArray(ymmword, 0).shiftEL(1);
>>
>> vector1.intoArray(result, 0);
>>
>> System.out.println(Arrays.toString(result));// This prints [0, 1, 2, 3, 4, 5, 6, 7]
>>
>>
>> IntVector<Shapes.256Bit> vector2 = (IntVector<Shapes.256Bit>)species.fromArray(ymmword, 0).shiftER(1);
>>
>> vector2.intoArray(result, 0);
>>
>> System.out.println(Arrays.toString(result)); // This prints [2, 2, 2, 2, 2, 2, 2, 0]
>>
>>
>> To build the Panama code I followed the instructions at https://software.intel.com/en-us/articles/vector-api-developer-program-for-java
>>
>>
>> Have I understood the purpose of these methods correctly and is the observed output as expected? For reference is it possible to access the intended assembly snippets for a given method?
>>
>>
>> Thanks,
>> Richard
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Richard Startin
>>
>
More information about the panama-dev
mailing list