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

Add SIMD support for Java 21 #90

Closed
wants to merge 3 commits into from

Conversation

rockfordroeNG
Copy link

Fixes #81

@CyberFlameGO
Copy link

CyberFlameGO commented May 28, 2024

Oops misclick! Just gonna do my actual review now

Copy link

@CyberFlameGO CyberFlameGO left a comment

Choose a reason for hiding this comment

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

JEPs 460 (targeting JDK 22) and 469 (targeting JDK 23) specify nothing which'd break the current patches - although Vector API is incubator and not preview I'd say it's safe enough to assume that the API won't change substantially enough to warrant restricting things here (reduces unnecessary friction each time there's a JDK release). If things do (by unlikely chance) change enough then we could always reimplement the other end of the check (assuming these suggestions are accepted).

@@ -48,7 +48,7 @@ index 0000000000000000000000000000000000000000..ab5fea0b03224bf249352ce340e94704
+ @Deprecated
+ public static boolean canEnable(Logger logger) {
+ try {
+ if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) {
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {

Choose a reason for hiding this comment

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

Suggested change
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {
+ if (SIMDDetection.getJavaVersion() < 17) {

@@ -42,15 +42,15 @@ index deb52c185705c4b4186c7bae02f2a827620c20ca..d1a8bfb29817d2b73689713b4d5f04d7
+ // Attempt to detect vectorization
+ try {
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(PufferfishLogger.LOGGER);
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19;
+ SIMDDetection.versionLimited = SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21;

Choose a reason for hiding this comment

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

Suggested change
+ SIMDDetection.versionLimited = SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21;
+ SIMDDetection.versionLimited = SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17;

Copy link
Member

Choose a reason for hiding this comment

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

No. We have been over this in the past.

+ } catch (NoClassDefFoundError | Exception ignored) {
+ ignored.printStackTrace();
+ }
+
+ if (SIMDDetection.isEnabled) {
+ PufferfishLogger.LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
+ } else if (SIMDDetection.versionLimited) {
+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17, Java 18, and Java 19.");
+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 through Java 21.");

Choose a reason for hiding this comment

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

Suggested change
+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 through Java 21.");
+ PufferfishLogger.LOGGER.warning("Will not enable SIMD! These optimizations are only safely supported on Java 17 and higher.");

Copy link
Member

Choose a reason for hiding this comment

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

This is not a true statement.

@kev626
Copy link
Member

kev626 commented May 30, 2024

@CyberFlameGO This feature is still actively being modified. Due to the performance-sensitive nature of this, we MUST actually verify that the machine code generated by the JIT is actually faster. If anything is broken or changed in the implementation of the JIT, it could substantially alter the performance characteristics of this patch. This is why we need thorough review for EVERY release.

This is not as simple as just enabling for all java versions, or even just enabling for one specific java version. And the procedure to validate this correctly is complex. None of the "reviewers" that have reviewed this have actually reviewed the correct thing.

@CyberFlameGO
Copy link

Ahhh my bad - I was just going off of the historical summary from the JEPs I linked

@kev626 kev626 closed this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIMD does not support Java 21
7 participants