[vectorIntrinsics] RFR: 8263149: Adding some algorithms optimized by Vector API into JMH benc…

Xiaohong Gong xgong at openjdk.java.net
Tue Mar 9 03:36:14 UTC 2021


On Mon, 8 Mar 2021 03:31:38 GMT, Wang Zhuo <wzhuo at openjdk.org> wrote:

> Here are some code samples for panama-vector vectorIntrinsics JMH benchmarks. 
> These code were developed during our work on optimizing Alibaba applications with Vector API.
> VectorDistance contains Cosine distance and Euclidean distance, scalar code from 
> https://github.com/opendistro-for-elasticsearch/k-NN/blob/aa5d1d40b136e2b3d33a14e80a2a374b2be015f9/src/main/java/com/amazon/opendistroforelasticsearch/knn/plugin/script/KNNScoringUtil.java#L61
> In many scenarios, ElasticSearch engineers reported more than 4X E2E speedup using Vector API.
> 
> BooleanArrayCheck and ValueRangeCheckAndCastL2I were from OLAP applications.
> 
> Co-authored-by: Joshua Zhu <jzhu at openjdk.org>

test/jdk/jdk/incubator/vector/benchmark/src/main/java/benchmark/bigdata/VectorDistance.java line 128:

> 126:         for (i = 0; i + (SPECIES.length()) <= queryVectorFloat.length; i += SPECIES.length()) {
> 127:             vecX = FloatVector.fromArray(SPECIES, queryVectorFloat, i);
> 128:             vecY = FloatVector.fromArray(SPECIES, inputVectorFloat, i);

Thanks for your JMH benchmarks! Could you please use `"SPECIES_FLOAT_128"` inside the API instead of defining a new variable here? I'm wondering whether the API can be vectorized by using `"SPECIES"` here, since the API needs the SPECIES argument to be a constant. I'm not sure about this case, but I really met the same issue before when I ran the jtreg tests. To make sure everything works as expect,  I'd like using the `static final field "SPECIES_FLOAT_128"` all through the API usage.

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

PR: https://git.openjdk.java.net/panama-vector/pull/45


More information about the panama-dev mailing list