Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit vectorization API to Hotspot VMs (and rename some constants and fix Javadocs) #12765

Merged
merged 2 commits into from
Nov 5, 2023

Conversation

uschindler
Copy link
Contributor

@uschindler uschindler commented Nov 5, 2023

I did some tests after fixing the bug in VM option detection.

With OpenJ9 (IBM Semeru) Java v20.0.2 there are no optimizations for Panama Vectors. If you enable the jdk.incubator.vector module it is like 1000 times slower, because there's no support at all. The module is there, but fallbacks to the default interpreted mode:

Benchmark                                   (size)   Mode  Cnt  Score   Error   Units
VectorUtilBenchmark.binaryCosineScalar        1024  thrpt   15  1,202 ± 0,101  ops/us
VectorUtilBenchmark.binaryCosineVector        1024  thrpt   15  1,067 ± 0,034  ops/us
VectorUtilBenchmark.binaryDotProductScalar    1024  thrpt   15  2,312 ± 0,033  ops/us
VectorUtilBenchmark.binaryDotProductVector    1024  thrpt   15  2,303 ± 0,033  ops/us
VectorUtilBenchmark.binarySquareScalar        1024  thrpt   15  1,970 ± 0,019  ops/us
VectorUtilBenchmark.binarySquareVector        1024  thrpt   15  1,785 ± 0,122  ops/us
VectorUtilBenchmark.floatCosineScalar         1024  thrpt   15  0,942 ± 0,081  ops/us
VectorUtilBenchmark.floatCosineVector         1024  thrpt   75  0,009 ± 0,001  ops/us
VectorUtilBenchmark.floatDotProductScalar     1024  thrpt   15  2,391 ± 0,290  ops/us
VectorUtilBenchmark.floatDotProductVector     1024  thrpt   75  0,023 ± 0,002  ops/us
VectorUtilBenchmark.floatSquareScalar         1024  thrpt   15  1,932 ± 0,085  ops/us
VectorUtilBenchmark.floatSquareVector         1024  thrpt   75  0,017 ± 0,001  ops/us

Please note: The binary code is not slower, as the vectorization is not used at all:

INFORMATION: Java vector incubator API enabled; uses preferredBitSize=128; floating-point vectors only

This PR enables vectorization only if Hotspot was detected by it's JVM flags, any other VM type is logged as not compatible.

@@ -111,6 +111,12 @@ static VectorizationProvider lookup(boolean testMode) {
+ Locale.getDefault());
return new DefaultVectorizationProvider();
}
// only use vector module with Hotspot VM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order is a bit different than in @rmuir's PR #12764: Here it exits early and does not even suggests to add the incubator command line flags. Therefore the check for a readable vector module is done after the Hotspot check.

@uschindler uschindler merged commit 382aa54 into apache:main Nov 5, 2023
4 checks passed
@uschindler uschindler deleted the dev/vectorization_hotspot_only branch November 5, 2023 18:22
asfgit pushed a commit that referenced this pull request Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants