Skip to content

Commit

Permalink
Improve JVMCI AVX Matrix4f.mul()
Browse files Browse the repository at this point in the history
we can just do the arithmetic with 256-bit YMM
registers if we assume transposed matrices
and just do the reverse multiplication, because
a * b == (b^T * a^T)^T.

also print reason for not using JVMCI when -Djoml.debug is enabled
  • Loading branch information
httpdigest committed Oct 31, 2022
1 parent e059268 commit 8bcc1b2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 84 deletions.
132 changes: 53 additions & 79 deletions src/main/java/org/joml/JvmciCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,71 +50,42 @@ class JvmciCode {
static final boolean hasAvx2;

static final byte[] MATRIX4F_MUL_AVX_LINUX = {
(byte) 0xC5, (byte) 0xF8, (byte) 0x10, (byte) 0x56, (byte) 0x10, (byte) 0xC5, (byte) 0xF8, (byte) 0x10,
(byte) 0x5E, (byte) 0x20, (byte) 0xC5, (byte) 0xF8, (byte) 0x10, (byte) 0x46, (byte) 0x30, (byte) 0xC5,
(byte) 0xF8, (byte) 0x10, (byte) 0x4E, (byte) 0x40, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18,
(byte) 0x62, (byte) 0x10, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x6A, (byte) 0x14,
(byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x72, (byte) 0x18, (byte) 0xC4, (byte) 0xE2,
(byte) 0x79, (byte) 0x18, (byte) 0x7A, (byte) 0x1C, (byte) 0xC5, (byte) 0xE8, (byte) 0x59, (byte) 0xE4,
(byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED, (byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5,
(byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE, (byte) 0xC5, (byte) 0xF0, (byte) 0x59, (byte) 0xF7,
(byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE, (byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5,
(byte) 0xC5, (byte) 0xF8, (byte) 0x11, (byte) 0x61, (byte) 0x10, (byte) 0xC4, (byte) 0xE2, (byte) 0x79,
(byte) 0x18, (byte) 0x62, (byte) 0x20, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x6A,
(byte) 0x24, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x72, (byte) 0x28, (byte) 0xC4,
(byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x7A, (byte) 0x2C, (byte) 0xC5, (byte) 0xE8, (byte) 0x59,
(byte) 0xE4, (byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED, (byte) 0xC5, (byte) 0xD8, (byte) 0x58,
(byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE, (byte) 0xC5, (byte) 0xF0, (byte) 0x59,
(byte) 0xF7, (byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE, (byte) 0xC5, (byte) 0xD8, (byte) 0x58,
(byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x11, (byte) 0x61, (byte) 0x20, (byte) 0xC4, (byte) 0xE2,
(byte) 0x79, (byte) 0x18, (byte) 0x62, (byte) 0x30, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18,
(byte) 0x6A, (byte) 0x34, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x72, (byte) 0x38,
(byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x7A, (byte) 0x3C, (byte) 0xC5, (byte) 0xE8,
(byte) 0x59, (byte) 0xE4, (byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED, (byte) 0xC5, (byte) 0xD8,
(byte) 0x58, (byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE, (byte) 0xC5, (byte) 0xF0,
(byte) 0x59, (byte) 0xF7, (byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE, (byte) 0xC5, (byte) 0xD8,
(byte) 0x58, (byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x11, (byte) 0x61, (byte) 0x30, (byte) 0xC4,
(byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x62, (byte) 0x40, (byte) 0xC4, (byte) 0xE2, (byte) 0x79,
(byte) 0x18, (byte) 0x6A, (byte) 0x44, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x72,
(byte) 0x48, (byte) 0xC4, (byte) 0xE2, (byte) 0x79, (byte) 0x18, (byte) 0x7A, (byte) 0x4C, (byte) 0xC5,
(byte) 0xE8, (byte) 0x59, (byte) 0xD4, (byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xDD, (byte) 0xC5,
(byte) 0xE8, (byte) 0x58, (byte) 0xD3, (byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xC6, (byte) 0xC5,
(byte) 0xF0, (byte) 0x59, (byte) 0xCF, (byte) 0xC5, (byte) 0xF8, (byte) 0x58, (byte) 0xC1, (byte) 0xC5,
(byte) 0xE8, (byte) 0x58, (byte) 0xC0, (byte) 0xC5, (byte) 0xF8, (byte) 0x11, (byte) 0x41, (byte) 0x40,
(byte) 0xC3};
(byte) 0xC5, (byte) 0xFC, (byte) 0x10, (byte) 0x42, (byte) 0x10, (byte) 0xC5,
(byte) 0xFC, (byte) 0x10, (byte) 0x4A, (byte) 0x30, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04,
(byte) 0xD0, (byte) 0x00, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A, (byte) 0x5E, (byte) 0x10,
(byte) 0xC5, (byte) 0xE4, (byte) 0x59, (byte) 0xD2, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04,
(byte) 0xE0, (byte) 0x55, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A, (byte) 0x6E, (byte) 0x20,
(byte) 0xC4, (byte) 0xE2, (byte) 0x55, (byte) 0xA8, (byte) 0xE2, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D,
(byte) 0x04, (byte) 0xD0, (byte) 0xAA, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A, (byte) 0x76,
(byte) 0x30, (byte) 0xC4, (byte) 0xE2, (byte) 0x4D, (byte) 0xA8, (byte) 0xD4, (byte) 0xC4, (byte) 0xE3,
(byte) 0x7D, (byte) 0x04, (byte) 0xC0, (byte) 0xFF, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A,
(byte) 0x66, (byte) 0x40, (byte) 0xC4, (byte) 0xE2, (byte) 0x5D, (byte) 0xA8, (byte) 0xC2, (byte) 0xC4,
(byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xD1, (byte) 0x00, (byte) 0xC5, (byte) 0xE4, (byte) 0x59,
(byte) 0xD2, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xD9, (byte) 0x55, (byte) 0xC4,
(byte) 0xE2, (byte) 0x55, (byte) 0xA8, (byte) 0xDA, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04,
(byte) 0xD1, (byte) 0xAA, (byte) 0xC4, (byte) 0xE2, (byte) 0x4D, (byte) 0xA8, (byte) 0xD3, (byte) 0xC4,
(byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xC9, (byte) 0xFF, (byte) 0xC4, (byte) 0xE2, (byte) 0x5D,
(byte) 0xA8, (byte) 0xCA, (byte) 0xC5, (byte) 0xFC, (byte) 0x11, (byte) 0x41, (byte) 0x10, (byte) 0xC5,
(byte) 0xFC, (byte) 0x11, (byte) 0x49, (byte) 0x30, (byte) 0xC5, (byte) 0xF8, (byte) 0x77, (byte) 0xC3 };
static final byte[] MATRIX4F_MUL_AVX_WINDOWS = {
(byte) 0xC5, (byte) 0xF8, (byte) 0x10, (byte) 0x52, (byte) 0x10, (byte) 0xC5, (byte) 0xF8, (byte) 0x10,
(byte) 0x5A, (byte) 0x20, (byte) 0xC5, (byte) 0xF8, (byte) 0x10, (byte) 0x42, (byte) 0x30, (byte) 0xC5,
(byte) 0xF8, (byte) 0x10, (byte) 0x4A, (byte) 0x40, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18,
(byte) 0x60, (byte) 0x10, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x68, (byte) 0x14,
(byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x70, (byte) 0x18, (byte) 0xC4, (byte) 0xC2,
(byte) 0x79, (byte) 0x18, (byte) 0x78, (byte) 0x1C, (byte) 0xC5, (byte) 0xE8, (byte) 0x59, (byte) 0xE4,
(byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED, (byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5,
(byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE, (byte) 0xC5, (byte) 0xF0, (byte) 0x59, (byte) 0xF7,
(byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE, (byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5,
(byte) 0xC4, (byte) 0xC1, (byte) 0x78, (byte) 0x11, (byte) 0x61, (byte) 0x10, (byte) 0xC4, (byte) 0xC2,
(byte) 0x79, (byte) 0x18, (byte) 0x60, (byte) 0x20, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18,
(byte) 0x68, (byte) 0x24, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x70, (byte) 0x28,
(byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x78, (byte) 0x2C, (byte) 0xC5, (byte) 0xE8,
(byte) 0x59, (byte) 0xE4, (byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED, (byte) 0xC5, (byte) 0xD8,
(byte) 0x58, (byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE, (byte) 0xC5, (byte) 0xF0,
(byte) 0x59, (byte) 0xF7, (byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE, (byte) 0xC5, (byte) 0xD8,
(byte) 0x58, (byte) 0xE5, (byte) 0xC4, (byte) 0xC1, (byte) 0x78, (byte) 0x11, (byte) 0x61, (byte) 0x20,
(byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x60, (byte) 0x30, (byte) 0xC4, (byte) 0xC2,
(byte) 0x79, (byte) 0x18, (byte) 0x68, (byte) 0x34, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18,
(byte) 0x70, (byte) 0x38, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x78, (byte) 0x3C,
(byte) 0xC5, (byte) 0xE8, (byte) 0x59, (byte) 0xE4, (byte) 0xC5, (byte) 0xE0, (byte) 0x59, (byte) 0xED,
(byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5, (byte) 0xC5, (byte) 0xF8, (byte) 0x59, (byte) 0xEE,
(byte) 0xC5, (byte) 0xF0, (byte) 0x59, (byte) 0xF7, (byte) 0xC5, (byte) 0xD0, (byte) 0x58, (byte) 0xEE,
(byte) 0xC5, (byte) 0xD8, (byte) 0x58, (byte) 0xE5, (byte) 0xC4, (byte) 0xC1, (byte) 0x78, (byte) 0x11,
(byte) 0x61, (byte) 0x30, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x60, (byte) 0x40,
(byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18, (byte) 0x68, (byte) 0x44, (byte) 0xC4, (byte) 0xC2,
(byte) 0x79, (byte) 0x18, (byte) 0x70, (byte) 0x48, (byte) 0xC4, (byte) 0xC2, (byte) 0x79, (byte) 0x18,
(byte) 0x78, (byte) 0x4C, (byte) 0xC5, (byte) 0xE8, (byte) 0x59, (byte) 0xD4, (byte) 0xC5, (byte) 0xE0,
(byte) 0x59, (byte) 0xDD, (byte) 0xC5, (byte) 0xE8, (byte) 0x58, (byte) 0xD3, (byte) 0xC5, (byte) 0xF8,
(byte) 0x59, (byte) 0xC6, (byte) 0xC5, (byte) 0xF0, (byte) 0x59, (byte) 0xCF, (byte) 0xC5, (byte) 0xF8,
(byte) 0x58, (byte) 0xC1, (byte) 0xC5, (byte) 0xE8, (byte) 0x58, (byte) 0xC0, (byte) 0xC4, (byte) 0xC1,
(byte) 0x78, (byte) 0x11, (byte) 0x41, (byte) 0x40, (byte) 0xC3};
(byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x10, (byte) 0x40, (byte) 0x10,
(byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x10, (byte) 0x48, (byte) 0x30, (byte) 0xC4, (byte) 0xE3,
(byte) 0x7D, (byte) 0x04, (byte) 0xD0, (byte) 0x00, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A,
(byte) 0x5A, (byte) 0x10, (byte) 0xC5, (byte) 0xE4, (byte) 0x59, (byte) 0xD2, (byte) 0xC4, (byte) 0xE3,
(byte) 0x7D, (byte) 0x04, (byte) 0xE0, (byte) 0x55, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D, (byte) 0x1A,
(byte) 0x6A, (byte) 0x20, (byte) 0xC4, (byte) 0xE2, (byte) 0x55, (byte) 0xA8, (byte) 0xE2, (byte) 0xC4,
(byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xD0, (byte) 0xAA, (byte) 0xC4, (byte) 0xE2, (byte) 0x7D,
(byte) 0x1A, (byte) 0x72, (byte) 0x30, (byte) 0xC4, (byte) 0xE2, (byte) 0x4D, (byte) 0xA8, (byte) 0xD4,
(byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xC0, (byte) 0xFF, (byte) 0xC4, (byte) 0xE2,
(byte) 0x7D, (byte) 0x1A, (byte) 0x62, (byte) 0x40, (byte) 0xC4, (byte) 0xE2, (byte) 0x5D, (byte) 0xA8,
(byte) 0xC2, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xD1, (byte) 0x00, (byte) 0xC5,
(byte) 0xE4, (byte) 0x59, (byte) 0xD2, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xD9,
(byte) 0x55, (byte) 0xC4, (byte) 0xE2, (byte) 0x55, (byte) 0xA8, (byte) 0xDA, (byte) 0xC4, (byte) 0xE3,
(byte) 0x7D, (byte) 0x04, (byte) 0xD1, (byte) 0xAA, (byte) 0xC4, (byte) 0xE2, (byte) 0x4D, (byte) 0xA8,
(byte) 0xD3, (byte) 0xC4, (byte) 0xE3, (byte) 0x7D, (byte) 0x04, (byte) 0xC9, (byte) 0xFF, (byte) 0xC4,
(byte) 0xE2, (byte) 0x5D, (byte) 0xA8, (byte) 0xCA, (byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x11,
(byte) 0x41, (byte) 0x10, (byte) 0xC4, (byte) 0xC1, (byte) 0x7C, (byte) 0x11, (byte) 0x49, (byte) 0x30,
(byte) 0xC5, (byte) 0xF8, (byte) 0x77, (byte) 0xC3 };

static final byte[] MATRIX4F_INVERT_AVX_LINUX = {
(byte) 0xC5, (byte) 0xFB, (byte) 0x10, (byte) 0x46, (byte) 0x10, (byte) 0xC5,
Expand Down Expand Up @@ -315,17 +286,20 @@ class JvmciCode {
AMD64 amd64arch = (AMD64) arch;
Set features = amd64arch.getFeatures();
if (!features.contains(AMD64.CPUFeature.AVX) || !features.contains(AMD64.CPUFeature.FMA))
throw new AssertionError();
throw new AssertionError("CPU lacks AVX or FMA support");
_hasAvx2 = features.contains(AMD64.CPUFeature.AVX2);
checkMatrix4f();
checkQuaternionf();
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_mulAvx", Matrix4f.class, Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_MUL_AVX_WINDOWS : MATRIX4F_MUL_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_invertAvx", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_INVERT_AVX_WINDOWS : MATRIX4F_INVERT_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_transposeAvx", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_TRANSPOSE_AVX_WINDOWS : MATRIX4F_TRANSPOSE_AVX_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Matrix4f_setAvx2", Matrix4f.class, Matrix4f.class), _isWindows ? MATRIX4F_SET_AVX2_WINDOWS : MATRIX4F_SET_AVX2_LINUX);
installCode(jvmciBackend, JvmciCode.class.getDeclaredMethod("__Quaternionf_mulAvx", Quaternionf.class, Quaternionf.class, Quaternionf.class), _isWindows ? QUATERNIONF_MUL_AVX_WINDOWS : QUATERNIONF_MUL_AVX_LINUX);
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("__Quaternionf_mul", Quaternionf.class, Quaternionf.class, Quaternionf.class), _isWindows ? QUATERNIONF_MUL_AVX_WINDOWS : QUATERNIONF_MUL_AVX_LINUX);
_canUseJvmci = true;
} catch (Throwable ignored) {
} catch (Throwable e) {
if (Options.DEBUG) {
System.err.println("JVMCI not available, because: " + e.getMessage());
}
}
canUseJvmci = _canUseJvmci;
hasAvx2 = _hasAvx2;
Expand All @@ -339,7 +313,7 @@ private static void checkMatrix4f() throws Throwable {
f = Matrix4f.class.getDeclaredField("m" + c + r);
long offset = u.objectFieldOffset(f);
if (offset != 16 + (i << 2))
throw new AssertionError();
throw new AssertionError("invalid Matrix4f field offset");
}
}
private static void checkQuaternionf() throws Throwable {
Expand All @@ -348,7 +322,7 @@ private static void checkQuaternionf() throws Throwable {
u.objectFieldOffset(Quaternionf.class.getDeclaredField("x")) != 20L ||
u.objectFieldOffset(Quaternionf.class.getDeclaredField("y")) != 24L ||
u.objectFieldOffset(Quaternionf.class.getDeclaredField("z")) != 28L)
throw new AssertionError();
throw new AssertionError("invalid Quaternionf field offset");
}
private static sun.misc.Unsafe unsafeInstance() throws SecurityException {
java.lang.reflect.Field[] fields = sun.misc.Unsafe.class.getDeclaredFields();
Expand All @@ -367,7 +341,7 @@ private static sun.misc.Unsafe unsafeInstance() throws SecurityException {
}
break;
}
throw new UnsupportedOperationException();
throw new AssertionError("no sun.misc.Unsafe available");
}
private static void installCode(JVMCIBackend jvmciBackend, Method m, byte[] code) throws Throwable {
ResolvedJavaMethod rm = jvmciBackend.getMetaAccess().lookupJavaMethod(m);
Expand All @@ -384,10 +358,10 @@ private static void installCode(JVMCIBackend jvmciBackend, Method m, byte[] code
setDefaultCodeMethod.invoke(codeCache, rm, nm);
}

static native void __Matrix4f_mulAvx(Matrix4f a, Matrix4f b, Matrix4f r);
static native void __Matrix4f_invertAvx(Matrix4f a, Matrix4f r);
static native void __Matrix4f_transposeAvx(Matrix4f a, Matrix4f r);
static native void __Matrix4f_setAvx2(Matrix4f a, Matrix4f r);
static native void __Quaternionf_mulAvx(Quaternionf a, Quaternionf b, Quaternionf r);
static native void __Matrix4f_mul(Matrix4f a, Matrix4f b, Matrix4f r);
static native void __Matrix4f_invert(Matrix4f a, Matrix4f r);
static native void __Matrix4f_transpose(Matrix4f a, Matrix4f r);
static native void __Matrix4f_set(Matrix4f a, Matrix4f r);
static native void __Quaternionf_mul(Quaternionf a, Quaternionf b, Quaternionf r);
}
//#endif
8 changes: 4 additions & 4 deletions src/main/java/org/joml/Matrix4f.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ public Matrix4f identity() {
public Matrix4f set(Matrix4fc m) {
//#ifdef __HAS_JVMCI__
if (JvmciCode.canUseJvmci && JvmciCode.hasAvx2 && m instanceof Matrix4f) {
JvmciCode.__Matrix4f_setAvx2((Matrix4f) m, this);
JvmciCode.__Matrix4f_set((Matrix4f) m, this);
properties = m.properties();
return this;
}
Expand Down Expand Up @@ -1147,7 +1147,7 @@ else if ((right.properties() & PROPERTY_IDENTITY) != 0)
//#ifdef __HAS_JVMCI__
else if (JvmciCode.canUseJvmci && right instanceof Matrix4f) {
Matrix4f mright = (Matrix4f) right;
JvmciCode.__Matrix4f_mulAvx(this, mright, dest);
JvmciCode.__Matrix4f_mul(this, mright, dest);
dest.properties = properties & mright.properties & (PROPERTY_AFFINE | PROPERTY_ORTHONORMAL);
return dest;
}
Expand Down Expand Up @@ -2551,7 +2551,7 @@ else if ((properties & PROPERTY_ORTHONORMAL) != 0)
return invertOrthonormal(dest);
//#ifdef __HAS_JVMCI__
else if (JvmciCode.canUseJvmci) {
JvmciCode.__Matrix4f_invertAvx(this, dest);
JvmciCode.__Matrix4f_invert(this, dest);
dest.properties = properties & PROPERTY_AFFINE;
return dest;
}
Expand Down Expand Up @@ -2960,7 +2960,7 @@ public Matrix4f transpose(Matrix4f dest) {
return dest.identity();
//#ifdef __HAS_JVMCI__
else if (JvmciCode.canUseJvmci) {
JvmciCode.__Matrix4f_transposeAvx(this, dest);
JvmciCode.__Matrix4f_transpose(this, dest);
dest.properties = 0;
return dest;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joml/Quaternionf.java
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ public Quaternionf mul(Quaternionfc q) {
public Quaternionf mul(Quaternionfc q, Quaternionf dest) {
//#ifdef __HAS_JVMCI__
if (JvmciCode.canUseJvmci && q instanceof Quaternionf) {
JvmciCode.__Quaternionf_mulAvx(this, (Quaternionf) q, dest);
JvmciCode.__Quaternionf_mul(this, (Quaternionf) q, dest);
return dest;
}
//#endif
Expand Down

0 comments on commit 8bcc1b2

Please sign in to comment.