I know Java is a secure language but when matrix calculations are needed, can I try something faster?
I am learning __asm{} in C++, Digital-Mars compiler and FASM. I want to do the same in Java. How can I inline assembly codes in functions? Is this even possible?
Something like this (a vectorized loop to clamp all elements of an array to a value without branching, using AVX support of CPU):
JavaAsmBlock(
# get pointers into registers somehow
# and tell Java which registers the asm clobbers somehow
vbroadcastss twenty_five(%rip), %ymm0
xor %edx,%edx
.Lloop: # do {
vmovups (%rsi, %rdx, 4), %ymm1
vcmpltps %ymm1, %ymm0, %ymm2
vblendvps %ymm2, %ymm0, %ymm1, %ymm1 # TODO: use vminps instead
vmovups %ymm1, (%rdi, %rdx, 4)
# TODO: unroll the loop a bit, and maybe handle unaligned output specially if that's common
add $32, %rdx
cmp %rcx, %rdx
jb .Lloop # } while(idx < count)
vzeroupper
);
System.out.println(var[0]);
I don't want to use a code-injector. I want to see the Intel or AT&T style x86 instructions.