Skip to content

Commit

Permalink
enable SIMD on java 17 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
foss-mc committed Sep 4, 2024
1 parent b43a72f commit fd1bcf7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
19 changes: 19 additions & 0 deletions patches/api/0007-enable-SIMD-on-java-17-and-later.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: foss-mc <[email protected]>
Date: Wed, 4 Sep 2024 18:54:39 +1200
Subject: [PATCH] enable SIMD on java 17 and later


diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
index ab5fea0b03224bf249352ce340e94704ff713345..7024a47b0de5083c3ba49c8e45b4c4b1369ab2c5 100644
--- a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
@@ -15,7 +15,7 @@ public class SIMDChecker {
@Deprecated
public static boolean canEnable(Logger logger) {
try {
- if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) {
+ if (SIMDDetection.getJavaVersion() < 17) {
return false;
} else {
SIMDDetection.testRun = true;
28 changes: 28 additions & 0 deletions patches/server/0020-enable-SIMD-on-java-17-and-later.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: foss-mc <[email protected]>
Date: Wed, 4 Sep 2024 18:53:37 +1200
Subject: [PATCH] enable SIMD on java 17 and later


diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
index 1ca25529245ed369b8705075a8c2e32fa4d9b1d1..7c6820b1320c40ef17f1c327bb7f49f8dfc02674 100644
--- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
+++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java
@@ -94,7 +94,7 @@ public class PufferfishConfig {
// 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.getJavaVersion() < 17;
} catch (NoClassDefFoundError | Exception ignored) {
ignored.printStackTrace();
}
@@ -102,7 +102,7 @@ public class PufferfishConfig {
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 or later");
} else {
PufferfishLogger.LOGGER.warning("SIMD operations are available for your server, but are not configured!");
PufferfishLogger.LOGGER.warning("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");

0 comments on commit fd1bcf7

Please sign in to comment.