4 ms·
Is this why my M1 MacBook Air can run the same R code at least 10x faster than my giant Linux tower?
by VeninVidiaVicii 3y ago
Is this why my M1 MacBook Air can run the same R code at least 10x faster than my giant Linux tower?
- microtonal 3y agoApple Silicon Macs have special matrix multiplication units (AMX) that can do matrix multiplication fast and with low energy requirements [1]. These AMX units can often beat matrix multiplication on AMD/Intel CPUs (especially those without a very large number of cores). Since a lot of linear algebra code uses matrix multiplication and using the AMX units is only a matter of linking against Accelerate (for its BLAS interface), a lot of software that uses BLAS is faster o Apple Silicon Macs. That said, the GPUs in your M1 Mac are faster than the AMX units and any reasonably modern NVIDIA GPU will wipe the floor with the AMX units or Apple Silicon GPUs in raw compute. However, a lot of software does not use CUDA by default and for small problem sets AMX units or CPUs with just AVX can be faster because they don't incur the cost of data transfers from main memory to GPU memory and vice versa. [1] Benchmarks: https://github.com/danieldk/gemm-benchmark#example-results https://github.com/danieldk/gemm-benchmark#example-results https://explosion.ai/blog/metal-performance-shaders https://explosion.ai/blog/metal-performance-shaders (scroll down a bit for AMX and MPS numbers)
- stephencanon 3y ago> That said, the GPUs in your M1 Mac are faster than the AMX units Not for double, which is what R mostly uses IIRC.
- microtonal 3y agoAh, thanks for the correction! I never use R, so I assumed that it uses/supports single-precision floating point.