RFR: 8265128: [REDO] Optimize Vector API slice and unslice operations [v2]

Paul Sandoz psandoz at openjdk.java.net
Fri Apr 30 00:26:57 UTC 2021


On Fri, 30 Apr 2021 00:17:24 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

>> All the slice and unslice variants that take more than one argument can benefit from already intrinsic methods on similar lines as slice(origin) and unslice(origin).
>> 
>> Changes include:
>>  * Rewrite Vector API slice/unslice using already intrinsic methods
>>  * Fix in library_call.cpp:inline_preconditions_checkIndex() to not modify control if intrinsification fails
>>  * Vector API conversion tests thresholds adjustment
>>  
>> Base Performance:
>> Benchmark (size) Mode Cnt Score Error Units
>> TestSlice.vectorSliceOrigin 1024 thrpt 5 11763.372 ± 254.580 ops/ms
>> TestSlice.vectorSliceOriginVector 1024 thrpt 5 599.286 ± 326.770 ops/ms
>> TestSlice.vectorSliceUnsliceOrigin 1024 thrpt 5 6627.601 ± 22.060 ops/ms
>> TestSlice.vectorSliceUnsliceOriginVector 1024 thrpt 5 401.858 ± 220.340 ops/ms
>> TestSlice.vectorSliceUnsliceOriginVectorPart 1024 thrpt 5 421.993 ± 231.703 ops/ms
>> 
>> Performance with patch:
>> Benchmark (size) Mode Cnt Score Error Units
>> TestSlice.vectorSliceOrigin 1024 thrpt 5 11792.091 ± 37.296 ops/ms
>> TestSlice.vectorSliceOriginVector 1024 thrpt 5 8388.174 ± 115.886 ops/ms
>> TestSlice.vectorSliceUnsliceOrigin 1024 thrpt 5 6662.159 ± 8.203 ops/ms
>> TestSlice.vectorSliceUnsliceOriginVector 1024 thrpt 5 5206.300 ± 43.637 ops/ms
>> TestSlice.vectorSliceUnsliceOriginVectorPart 1024 thrpt 5 5194.278 ± 13.376 ops/ms
>
> Sandhya Viswanathan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Review comments implementation

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2255:

> 2253:         Objects.checkIndex(origin, length() + 1);
> 2254:         VectorShuffle<$Boxtype$> iota = iotaShuffle();
> 2255:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));

Suggestion:

        VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2257:

> 2255:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));
> 2256:         iota = iotaShuffle(origin, 1, true);
> 2257:         return (($abstractvectortype$)v1).rearrange(iota).blend(this.rearrange(iota), BlendMask);

Suggestion:

        return that.rearrange(iota).blend(this.rearrange(iota), blendMask);

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2285:

> 2283:         Objects.checkIndex(origin, length() + 1);
> 2284:         VectorShuffle<$Boxtype$> iota = iotaShuffle();
> 2285:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));

Suggestion:

        VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2287:

> 2285:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin))));
> 2286:         iota = iotaShuffle(origin, 1, true);
> 2287:         return vspecies().zero().blend(this.rearrange(iota), BlendMask);

Suggestion:

        return vspecies().zero().blend(this.rearrange(iota), blendMask);

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2306:

> 2304:         Objects.checkIndex(origin, length() + 1);
> 2305:         VectorShuffle<$Boxtype$> iota = iotaShuffle();
> 2306:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT,

Suggestion:

        VectorMask<$Boxtype$> blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT,

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2309:

> 2307:                                                                   (broadcast(($type$)(origin))));
> 2308:         iota = iotaShuffle(-origin, 1, true);
> 2309:         return (($abstractvectortype$)w).blend(this.rearrange(iota), BlendMask);

Suggestion:

        return that.blend(this.rearrange(iota), blendMask);

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2346:

> 2344:         Objects.checkIndex(origin, length() + 1);
> 2345:         VectorShuffle<$Boxtype$> iota = iotaShuffle();
> 2346:         VectorMask<$Boxtype$> BlendMask = iota.toVector().compare(VectorOperators.GE,

Suggestion:

        VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.GE,

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 2349:

> 2347:                                                                   (broadcast(($type$)(origin))));
> 2348:         iota = iotaShuffle(-origin, 1, true);
> 2349:         return vspecies().zero().blend(this.rearrange(iota), BlendMask);

Suggestion:

        return vspecies().zero().blend(this.rearrange(iota), blendMask);

-------------

PR: https://git.openjdk.java.net/jdk/pull/3804


More information about the hotspot-compiler-dev mailing list