Skip to content

Commit

Permalink
Correct java version checks in SIMD optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHua269 committed Aug 6, 2024
1 parent 2e52016 commit d0d9ce0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions patches/server/0037-Pufferfish-SIMD-Utilities.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ index c2d3d699edfd60d773af96116c5663c812c691e9..1049681dfa7e48b4b6c29f4b1a09c689

diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..35b79cfdef8c3c873491bd52f9a8e2b0f8112499
index 0000000000000000000000000000000000000000..76cea165bcef0794a66ef7c29721f7716869420f
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/SIMDConfig.java
@@ -0,0 +1,53 @@
Expand Down Expand Up @@ -65,15 +65,15 @@ index 0000000000000000000000000000000000000000..35b79cfdef8c3c873491bd52f9a8e2b0
+ // Attempt to detect vectorization
+ try {
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER);
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21;
+ SIMDDetection.versionLimited = SIMDDetection.getJavaVersion() < 17;
+ } catch (NoClassDefFoundError | Exception ignored) {
+ ignored.printStackTrace();
+ }
+
+ if (SIMDDetection.isEnabled) {
+ LOGGER.info("SIMD operations detected as functional. Will replace some operations with faster versions.");
+ } else if (SIMDDetection.versionLimited) {
+ LOGGER.warn("Will not enable SIMD! These optimizations are only safely supported on Java 17-21.");
+ LOGGER.warn("Will not enable SIMD! These optimizations are only safely supported on Java 17+.");
+ } else {
+ LOGGER.warn("SIMD operations are available for your server, but are not configured!");
+ LOGGER.warn("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
Expand Down

0 comments on commit d0d9ce0

Please sign in to comment.