8 ms·
Apple added custom instructions on top of the ARM instruction set to do matrix operations. Matrix operations are used a lot in some algorithms, such as in comp
by vegetablepotpie 6y ago
Apple added custom instructions on top of the ARM instruction set to do matrix operations.
Matrix operations are used a lot in some algorithms, such as in computer graphics and machine learning and these instructions help those operations go faster.
Although the ARM ISA has a multiply and accumulate instruction, it would take many more instructions on a standard ARM core to compute a matrix with only standard instructions. That enables the M1 chip to be faster in this case when developers use these instructions in their applications.
- giantrobot 6y ago> That enables the M1 chip to be faster in this case when developers use these instructions in their applications. Or more typically the compiler will emit those instructions and everyone gets them for free.
- teknopaul 6y agoonly if the compiler knows they exist
- a1369209993 6y agoThat's actually generally not true WRT SIMD/vector instructions (see eg http://yosefk.com/blog/humans-and-compilers-need-each-other-the-vliw-simd-case.html http://yosefk.com/blog/humans-and-compilers-need-each-other-... which contrasts this with the more compiler-friendly VLIW case); they impose nontrivial requirements on data structures and ABI, so the application code needs to at least be aware of the possibility of vectorization, even if it's agnostic to whether the implementation actually uses it.
- 2wrist 6y agoSimilar to Altivec from the PowerPC days?
- floatboth 6y agoAltivec is regular SIMD like NEON or SSE/AVX
- floatingatoll 6y agoCorrection: ^when applications use these instructions; either as a result of use of a system API/framework, of the compiler optimizing code into these M1 instructions, or of the developer writing M1 assembler themselves. It is very likely that the majority of cases that use these instructions will be compiled by Xcode without the knowledge of developers that these instructions exist at all.
- ytch 6y agoApple might use these instruction in CoreML/Accelerate Framework and not integrated to LLVM as the author said: > This is an undocumented arm64 ISA extension present on the Apple M1. These instructions have been reversed from Accelerate (vImage, libBLAS, libBNNS, libvDSP and libLAPACK all use them), So we still cannot understand all of them from LLVM source code.
- floatingatoll 6y agoTo highlight where we're disconnected, my phrase: "cases that use these instructions will be compiled by Xcode" does not imply that Xcode comes equipped to translate user-provided code into these instructions; however, by use of Apple frameworks, Xcode could still regardless output binaries that use these instructions, without needing to provide us any manner to do so ourselves. I suspect most people aren't compiling framework-provided binary code into their binaries, using static or whatever it's called these days and so I believe those usages will end up reserved for the frameworks — but since someone is certain to try and consider 'the binary output of Xcode' to include any frameworks referenced by it if it supports their point, I'm taking care to cover all possible cases where output of those instructions could occur without a translation phase using LLVM or etc.
- ytch 6y agoThanks for your explanation, I didn't take this into account
- floatingatoll 6y ago