3 ms·
From what I can tell reading this: the Accelerate framework from Apple seems to use custom instructions possibly unique to the M1 chip but potentially similar t
by ericlewis 6y ago
From what I can tell reading this: the Accelerate framework from Apple seems to use custom instructions possibly unique to the M1 chip but potentially similar to Intel AMX. Accelerate is, as I sort of understand it- a way to do advanced math in a very quick / power efficient way. It is touted as deeply integrated with Apple processors from the day it launched and (I think) even recommended to be used over SIMD and the sort (I could certainly be very wrong about this). It dove tails with some of the machine learning work Apple did as well, is portable among Apple systems, and can be assumed to be optimized.
Ninja edit: I’ve not seen how it was achieved until now, but a custom ISA extension isn’t wholly surprising.
Edit 2: as for why this is significant.. I’m not sure it is. It is interesting to know how Accelerate can pull off what it does though. IIRC there are other machine learning frameworks which take advantage of the neural engine- but Accelerate possibly doesn’t- despite having machine learning capabilities.
- Lammy 6y agoIt also means that any binaries built to use those instructions won't run on any non-Apple ARM64 CPUs, at least not easily. Sort of like how early-era Intel Hackintosh users had to have CPUs with SSE3 support or wait/hope for SSE2 patches.
- ericlewis 6y agoI’m relatively sure that Accelerate does work fine on intel processors and is still the recommended means of doing heavy math. But that could just be because they knew of this eventual future. I’m not sure what Accelerate does under the hood for intel machines. But I would assume perhaps falls back to whatever intel might support.
- giantrobot 6y agoSay hello to Function Multi-versioning [0]. You tell the compiler to build a version for each march defined in the attribute. When that function is called a quick CPU check (via CPUID) is performed and if there's a version specific to the current CPU that will run instead of the more general implementation. ICC has supported this for a long time and it's widely used in Intel's MKL. LLVM also supports FMV but uses a slightly different method to define it in code. IIRC there was an LLVM issue tracking work to support GCC's way of declaring FMV but I don't know if that landed yet. Since the function's signature is the same between the multiple implementations the caller doesn't need to change of their code to get a free boost from features like AVX2 or these M1 instructions. When an M2 comes out with better vector instructions or something and a new Accelerate framework is released, anyone using the framework get a free performance increase without recompiling anything. [0] https://lwn.net/Articles/691932/ https://lwn.net/Articles/691932/
- floatboth 6y agoAt least __attribute__((ifunc(..))) is common between clang and gcc. (E.g. no compiler conditionals are used in https://cgit.freebsd.org/src/tree/sys/arm64/include/ifunc.h https://cgit.freebsd.org/src/tree/sys/arm64/include/ifunc.h) The fancier high level stuff that automatically compiles multiple versions of a function, I'm not sure.
- saagarjha 6y agoNote that on ARM it is more annoying to get CPU capabilities as there is no straight cpuid equivalent.
- stephencanon 6y agoOn Apple platforms, CPU capabilities are cached on the commpage, so system libraries don’t even need to use cpuid on x86.