JuliaRandom / Random123.jl

Julia implementation of Random123.
http://juliarandom.github.io/RandomNumbers.jl/stable/man/random123/
Other
18 stars 5 forks source link

ARM64 support #20

Closed sunoru closed 8 months ago

sunoru commented 10 months ago

Currently the implementation of AES-NI and ARM completely depends on the AES-NI instruction sets (llvm.x86.aesni.*) provided by Intel processors. As Apple Silicon becomes very popular, it would be very nice if ARM64 platforms can also be supported.

pthariensflame commented 10 months ago

I have a WIP branch doing the conversion, but tests are failing at the moment. Part of what makes this more difficult than it should be is that while both Arm(64) and x86(_64) have their own acceleration instructions for AES, those instructions do different things. (Arm breaks them into smaller and more flexible pieces than x86 does and omits the keygen facilities completely.)

Trying to rebuild the x86 versions from the Arm versions has indeed been done in projects like SIMD-Everywhere and SSE2NEON, but consulting those hasn't helped me make things work; the algorithms in this package rely on some pretty specific aspects of the x86 implementation it seems. The original C++ version of Random123 also doesn't support Arm intrinsics, so we'd be the first to try this.

pthariensflame commented 10 months ago

If you want to play around it with, the LLVM intrinsics for 64-bit Arm AES acceleration are llvm.aarch64.crypto.aes*, where the * is one of e, d, mc, or imc. Any 64-bit Arm machine with NIST crypto (FEAT_AES) enabled should execute those just fine; even a RasPi 4 or 5, or a legacy AWS Graviton 1 instance, would do.

EDIT: Or QEMU!

sunoru commented 10 months ago

Thank you so much! The suggestions look really helpful and I will also look into them.

pthariensflame commented 10 months ago

@sunoru See #21! 🎉