Enhance ADC scoring with SIMD Vector API and add comprehensive tests#3167
Enhance ADC scoring with SIMD Vector API and add comprehensive tests#3167ajw711 wants to merge 3 commits intoopensearch-project:mainfrom
Conversation
Signed-off-by: An Jinwon <ajw711@naver.com>
d6a2fab to
01a31cc
Compare
|
Hi @navneet1v and team, I've implemented the SIMD optimization for Key highlights compared to the existing implementation:
Happy to receive any feedback! |
|
Thank you @ajw711 |
|
Thank you for the PR @ajw711 ! The logic looks correct. 3 comments:
Since OpenSearch 3.x supports jdk21, can we use reflection to access the preview SIMD methods instead of There's an example in some code from @0ctopus13prime that uses the MemorySegment feature that's preview in JDK21 but part of main since JDK22. Refs: |
Signed-off-by: Navneet Verma <navneev@amazon.com>
… SIMD reflection Signed-off-by: An Jinwon <ajw711@naver.com>
|
Thanks for the review. To fix the JDK 25 build error, I removed the --enable-preview flag from build.gradle and only kept the required module (--add-modules jdk.incubator.vector). I also added a reflection fallback in KNNScoringUtil. The SIMD class remains in the build, but if the Vector API is unavailable at runtime, it safely falls back to the scalar logic. Please let me know if this approach looks okay or if further changes are needed. |
Description
Resolves #3150
Implements SIMD optimization for
l2SquaredADCandinnerProductADCusing Java Vector API (FloatVector.SPECIES_PREFERRED) as suggested in the linked issue.Key Improvements & Stability Considerations:
--add-modules jdk.incubator.vectorand--enable-previewglobally inbuild.gradleusingtasks.withType. This ensures the Vector API is consistently injected not only duringJavaCompilebut also duringTestandJavaExecphases, preventing unexpectedNoClassDefFoundErrorat runtime.CHANGELOG.mdto reflect the enhancement.Related Issues
Resolves #3150
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.