mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
89 lines
4.5 KiB
Diff
89 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Thu, 24 Nov 2022 01:19:12 +0100
|
|
Subject: [PATCH] SIMD support
|
|
|
|
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following patch:
|
|
"Add SIMD utilities"
|
|
By: Kevin Raneri <kevin.raneri@gmail.com>
|
|
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/build.gradle.kts b/build.gradle.kts
|
|
index c2f60f3f638d8a94046d20ff1dfca316a3395861..9839d38652d04fcc3e97a85a9120a1848e203de6 100644
|
|
--- a/build.gradle.kts
|
|
+++ b/build.gradle.kts
|
|
@@ -63,6 +63,7 @@ tasks.withType<JavaCompile> {
|
|
compilerArgs.add("-Xlint:-module")
|
|
compilerArgs.add("-Xlint:-removal")
|
|
compilerArgs.add("-Xlint:-dep-ann")
|
|
+ compilerArgs.add("--add-modules=jdk.incubator.vector") // Gale - Pufferfish - SIMD support
|
|
}
|
|
// Gale end - hide irrelevant compilation warnings
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
index d2b14c65e6a925ba4a29d48bcedc0d9504092052..007fe6820e208c04e81acbd7bb7eaf0a22f6f64f 100644
|
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
@@ -14,6 +14,8 @@ import java.util.Locale;
|
|
import java.util.Optional;
|
|
import java.util.function.BooleanSupplier;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
|
|
import net.minecraft.DefaultUncaughtExceptionHandler;
|
|
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
|
import net.minecraft.SharedConstants;
|
|
@@ -51,6 +53,7 @@ import net.minecraft.world.level.GameType;
|
|
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
|
import net.minecraft.world.level.storage.LevelStorageSource;
|
|
import org.galemc.gale.command.GaleCommands;
|
|
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
|
import org.slf4j.Logger;
|
|
|
|
// CraftBukkit start
|
|
@@ -228,6 +231,21 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
|
// Paper end
|
|
|
|
+ // Gale start - Pufferfish - SIMD support
|
|
+ // Attempt to detect vectorization
|
|
+ try {
|
|
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER, GaleGlobalConfiguration.get().smallOptimizations.simd.logVectorSizesToConsole);
|
|
+ } catch (NoClassDefFoundError | Exception ignored) {}
|
|
+
|
|
+ if (!SIMDDetection.isEnabled && !SIMDDetection.unsupportingLaneSize && GaleGlobalConfiguration.get().smallOptimizations.simd.warnIfDisabled) {
|
|
+ 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\".");
|
|
+ LOGGER.warn("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
|
|
+ LOGGER.warn("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun);
|
|
+ LOGGER.warn("If you would like to disable this message, set simd.warn-if-disabled to false in gale-global.yml");
|
|
+ }
|
|
+ // Gale start - Pufferfish - SIMD support
|
|
+
|
|
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
|
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
|
this.setMotd(dedicatedserverproperties.motd);
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
index 5bf0c4d9cf136cd19d87ee04a834413240eec339..a1d5197a5e7a00fad1025741ef8adcea45d42533 100644
|
|
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
@@ -43,6 +43,14 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
|
|
|
public boolean disableVanillaProfiler = true; // Gale - Airplane - config to disable vanilla profiler
|
|
|
|
+ // Gale start - Pufferfish - SIMD support
|
|
+ public Simd simd;
|
|
+ public class Simd extends ConfigurationPart {
|
|
+ public boolean warnIfDisabled = true;
|
|
+ public boolean logVectorSizesToConsole = false;
|
|
+ }
|
|
+ // Gale end - Pufferfish - SIMD support
|
|
+
|
|
}
|
|
|
|
}
|