Skip to content

Commit

Permalink
Remove AVX2 detection
Browse files Browse the repository at this point in the history
We don't make use of AVX2 instructions right now
  • Loading branch information
httpdigest committed Oct 31, 2022
1 parent 8bcc1b2 commit 09be171
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/main/java/org/joml/JvmciCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

class JvmciCode {
static final boolean canUseJvmci;
static final boolean hasAvx2;

static final byte[] MATRIX4F_MUL_AVX_LINUX = {
(byte) 0xC5, (byte) 0xFC, (byte) 0x10, (byte) 0x42, (byte) 0x10, (byte) 0xC5,
Expand Down Expand Up @@ -222,12 +221,12 @@ class JvmciCode {
(byte) 0x58, (byte) 0x20, (byte) 0xC4, (byte) 0xC1, (byte) 0x78, (byte) 0x11, (byte) 0x60, (byte) 0x30,
(byte) 0xC4, (byte) 0xC1, (byte) 0x78, (byte) 0x11, (byte) 0x40, (byte) 0x40, (byte) 0xC3 };

static final byte[] MATRIX4F_SET_AVX2_LINUX = {
static final byte[] MATRIX4F_SET_AVX_LINUX = {
(byte) 0xC5, (byte) 0xFC, (byte) 0x10, (byte) 0x46, (byte) 0x10, (byte) 0xC5,
(byte) 0xFC, (byte) 0x10, (byte) 0x4E, (byte) 0x30, (byte) 0xC5, (byte) 0xFC, (byte) 0x11, (byte) 0x42,
(byte) 0x10, (byte) 0xC5, (byte) 0xFC, (byte) 0x11, (byte) 0x4A, (byte) 0x30, (byte) 0xC5, (byte) 0xF8,
(byte) 0x77, (byte) 0xC3 };
static final byte[] MATRIX4F_SET_AVX2_WINDOWS = {
static final byte[] MATRIX4F_SET_AVX_WINDOWS = {
(byte) 0xC5, (byte) 0xFC, (byte) 0x10, (byte) 0x42, (byte) 0x10, (byte) 0xC5,
(byte) 0xFC, (byte) 0x10, (byte) 0x4A, (byte) 0x30, (byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x11,
(byte) 0x40, (byte) 0x10, (byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x11, (byte) 0x48, (byte) 0x30,
Expand Down Expand Up @@ -276,7 +275,6 @@ class JvmciCode {

static {
boolean _canUseJvmci = false;
boolean _hasAvx2 = false;
try {
boolean _isWindows = System.getProperty("os.name").contains("Windows");
JVMCIRuntime jvmciRuntime = JVMCI.getRuntime();
Expand All @@ -287,13 +285,12 @@ class JvmciCode {
Set features = amd64arch.getFeatures();
if (!features.contains(AMD64.CPUFeature.AVX) || !features.contains(AMD64.CPUFeature.FMA))
throw new AssertionError("CPU lacks AVX or FMA support");
_hasAvx2 = features.contains(AMD64.CPUFeature.AVX2);
checkMatrix4f();
checkQuaternionf();
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_mul", Matrix4f.class, Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_MUL_AVX_WINDOWS : MATRIX4F_MUL_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_invert", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_INVERT_AVX_WINDOWS : MATRIX4F_INVERT_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_transpose", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_TRANSPOSE_AVX_WINDOWS : MATRIX4F_TRANSPOSE_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_set", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_SET_AVX2_WINDOWS : MATRIX4F_SET_AVX2_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_set", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_SET_AVX_WINDOWS : MATRIX4F_SET_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Quaternionf_mul", Quaternionf.class, Quaternionf.class, Quaternionf.class), _isWindows ? QUATERNIONF_MUL_AVX_WINDOWS : QUATERNIONF_MUL_AVX_LINUX);
_canUseJvmci = true;
} catch (Throwable e) {
Expand All @@ -302,7 +299,6 @@ class JvmciCode {
}
}
canUseJvmci = _canUseJvmci;
hasAvx2 = _hasAvx2;
}
private static void checkMatrix4f() throws Throwable {
Field f;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joml/Matrix4f.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public Matrix4f identity() {
*/
public Matrix4f set(Matrix4fc m) {
//#ifdef __HAS_JVMCI__
if (JvmciCode.canUseJvmci && JvmciCode.hasAvx2 && m instanceof Matrix4f) {
if (JvmciCode.canUseJvmci && m instanceof Matrix4f) {
JvmciCode.__Matrix4f_set((Matrix4f) m, this);
properties = m.properties();
return this;
Expand Down

0 comments on commit 09be171

Please sign in to comment.