mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-23 17:09:29 +00:00
Cleanup get java version & SIMD util
- Use modern API which introduced since Java 10 to get java major version - Remove useless fields in SIMD util, Java 21+ supports SIMD.
This commit is contained in:
@@ -14,10 +14,10 @@ Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..90d87374e9dddd79aeca3e05f9cd6c82eb3aad27
|
||||
index 0000000000000000000000000000000000000000..8d614483b8011d47e88ace3da28e072d1febaef7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,48 @@
|
||||
@@ -0,0 +1,41 @@
|
||||
+// Gale - Pufferfish - SIMD support
|
||||
+
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
@@ -38,13 +38,6 @@ index 0000000000000000000000000000000000000000..90d87374e9dddd79aeca3e05f9cd6c82
|
||||
+ }
|
||||
+ SIMDDetection.setInitialized();
|
||||
+ try {
|
||||
+ int javaVersion = SIMDDetection.getJavaVersion();
|
||||
+ if (javaVersion < 17) {
|
||||
+ return;
|
||||
+ }
|
||||
+ SIMDDetection.supportingJavaVersion = true;
|
||||
+ SIMDDetection.testRunStarted = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
@@ -68,10 +61,10 @@ index 0000000000000000000000000000000000000000..90d87374e9dddd79aeca3e05f9cd6c82
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b19b6bc85cb08a49f064a4ecb88af858a9a22fe7
|
||||
index 0000000000000000000000000000000000000000..df3ef7bface99072b5bfbcdc5bf653a01a9c798c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,78 @@
|
||||
@@ -0,0 +1,59 @@
|
||||
+// Gale - Pufferfish - SIMD support
|
||||
+
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
@@ -83,8 +76,6 @@ index 0000000000000000000000000000000000000000..b19b6bc85cb08a49f064a4ecb88af858
|
||||
+ static int floatVectorBitSize;
|
||||
+ static int intElementSize;
|
||||
+ static int floatElementSize;
|
||||
+ static boolean supportingJavaVersion;
|
||||
+ static boolean testRunStarted;
|
||||
+ static boolean testRunCompleted;
|
||||
+ static boolean unsupportingLaneSize;
|
||||
+ static boolean isEnabled;
|
||||
@@ -120,10 +111,6 @@ index 0000000000000000000000000000000000000000..b19b6bc85cb08a49f064a4ecb88af858
|
||||
+ return floatElementSize;
|
||||
+ }
|
||||
+
|
||||
+ public static boolean supportingJavaVersion() {
|
||||
+ return supportingJavaVersion;
|
||||
+ }
|
||||
+
|
||||
+ public static boolean testRunCompleted() {
|
||||
+ return testRunCompleted;
|
||||
+ }
|
||||
@@ -136,17 +123,4 @@ index 0000000000000000000000000000000000000000..b19b6bc85cb08a49f064a4ecb88af858
|
||||
+ return isEnabled;
|
||||
+ }
|
||||
+
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
|
||||
@@ -13,10 +13,10 @@ As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index c9c7590a5635d966a0ca262ed5985714d9e66598..119d26ada18ad1451b893657a1c9fa3bc2be6be4 100644
|
||||
index c9c7590a5635d966a0ca262ed5985714d9e66598..c0255b4493cfcdd4b89f4002b731adaf57422f61 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -936,6 +936,46 @@ public class Metrics {
|
||||
@@ -936,6 +936,40 @@ public class Metrics {
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("gale_semantic_version", () -> semanticVersionMap));
|
||||
// Gale end - semantic version - include in metrics
|
||||
|
||||
@@ -36,13 +36,7 @@ index c9c7590a5635d966a0ca262ed5985714d9e66598..119d26ada18ad1451b893657a1c9fa3b
|
||||
+ if (isEnabled) {
|
||||
+ details = "int " + gg.pufferfish.pufferfish.simd.SIMDDetection.intVectorBitSize() + "*" + gg.pufferfish.pufferfish.simd.SIMDDetection.intElementSize() + ", float " + gg.pufferfish.pufferfish.simd.SIMDDetection.floatVectorBitSize() + "*" + gg.pufferfish.pufferfish.simd.SIMDDetection.floatElementSize();
|
||||
+ } else {
|
||||
+ if (!gg.pufferfish.pufferfish.simd.SIMDDetection.supportingJavaVersion()) {
|
||||
+ details = "unsupported Java";
|
||||
+ try {
|
||||
+ var javaVersion = gg.pufferfish.pufferfish.simd.SIMDDetection.getJavaVersion();
|
||||
+ details += " (" + javaVersion + ")";
|
||||
+ } catch (Throwable ignored) {}
|
||||
+ } else if (!gg.pufferfish.pufferfish.simd.SIMDDetection.testRunCompleted()) {
|
||||
+ if (!gg.pufferfish.pufferfish.simd.SIMDDetection.testRunCompleted()) {
|
||||
+ details = "test failed";
|
||||
+ } else if (gg.pufferfish.pufferfish.simd.SIMDDetection.unsupportingLaneSize()) {
|
||||
+ details = "no supporting lane size";
|
||||
|
||||
@@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index 119d26ada18ad1451b893657a1c9fa3bc2be6be4..8685b42dd00c964b0fbf42334cd6d23f187b2658 100644
|
||||
index c0255b4493cfcdd4b89f4002b731adaf57422f61..4e7adf20887c527d2a011040d9d616f6065c5726 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -976,6 +976,22 @@ public class Metrics {
|
||||
@@ -970,6 +970,19 @@ public class Metrics {
|
||||
}));
|
||||
// Gale end - SIMD support - include in metrics
|
||||
|
||||
@@ -19,12 +19,9 @@ index 119d26ada18ad1451b893657a1c9fa3bc2be6be4..8685b42dd00c964b0fbf42334cd6d23f
|
||||
+ {
|
||||
+ Map<String, Integer> entry = new HashMap<>(2);
|
||||
+ boolean isSupported = org.galemc.gale.virtualthread.VirtualThreadService.isSupported();
|
||||
+ try {
|
||||
+ int javaMajorVersion = org.galemc.gale.virtualthread.VirtualThreadService.getJavaMajorVersion();
|
||||
+ int javaMajorVersion = Runtime.version().feature();
|
||||
+ entry.put(isSupported + " (Java " + javaMajorVersion + ")", 1);
|
||||
+ } catch (Exception ignored) {
|
||||
+ entry.put(String.valueOf(isSupported), 1);
|
||||
+ }
|
||||
+
|
||||
+ virtualThreadSupportMap.put(String.valueOf(isSupported), entry);
|
||||
+ }
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("virtual_thread_support", () -> virtualThreadSupportMap));
|
||||
|
||||
@@ -5,7 +5,7 @@ import joptsimple.OptionSet;
|
||||
|
||||
public class LeafBootstrap {
|
||||
|
||||
public static final boolean enableFMA = Boolean.getBoolean("Leaf.enableFMA");
|
||||
public static final boolean enableFMA = Boolean.getBoolean("Leaf.enableFMA"); // Leaf - Optimize Entity distanceTo
|
||||
|
||||
public static void boot(final OptionSet options) {
|
||||
//runPreBootTasks();
|
||||
|
||||
@@ -88,17 +88,4 @@ public sealed abstract class VirtualThreadService permits ReflectionVirtualThrea
|
||||
* even without any feature preview flags.
|
||||
*/
|
||||
public static final int minimumJavaMajorVersionWithoutFeaturePreview = 21;
|
||||
|
||||
public static int getJavaMajorVersion() {
|
||||
var version = System.getProperty("java.version");
|
||||
if (version.startsWith("1.")) {
|
||||
return version.charAt(2) - '0';
|
||||
}
|
||||
if (version.contains("-")) {
|
||||
version = version.substring(0, version.indexOf("-"));
|
||||
}
|
||||
|
||||
int dotIndex = version.indexOf(".");
|
||||
return Integer.parseInt(dotIndex == -1 ? version : version.substring(0, dotIndex));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user