m4-sme-exploration README

The project's README from github.com/tzakharko/m4-sme-exploration. As one markdown file: README.md.

Exploring SME performance of Apple M4

Introduction

The 2024 iPad Pro, featuring the Apple M4 chip, is the first device available to the public that supports ARM's scalable matrix extension (SME). Although Apple has included a matrix accelerator in its devices since 2019, it used a proprietary instruction set called AMX[^1]. The developers had to use Apple-provided numerical frameworks to take advantage of the hardware. The M4 chip with SME changes this by allowing programmers to write low-level code that directly targets the matrix hardware, bringing potential performance improvements to scientific and machine learning algorithms.

My investigation aims to explore the M4 SME hardware and study the SME instruction set. I am particularly interested in how these features can be used to accelerate vector operations. The initial experiments study the peak compute throughput for common matrix and vector operations and the memory transfer rates using various methods. My methodology relies on generating multiple variants of microbenchmark code over a wide range of parameters and studying the results (see the Python code in tools/ for how the benchmarks are generated). I expect to extend this project as new aspects of the hardware are tested. Pull requests and commentary are welcome!

Another in-depth investigation of M4 SME is provided by a team at the University of Jena, who are building a high-performance GEMM implementation [^2]. It is an excellent read if you are interested in the topic.

[^1]: https://github.com/corsix/amx - description of Apple proprietary AMX extensions [^2]: https://scalable.uni-jena.de/opt/sme/

Contents

Running the tests

Requirements

Note: this project currently only runs on an external M4 iPad Pro. As M4 Macs are expected to be available soon, it would be desirable to run these tests locally. Pull requests are welcome!

Building and running

After downloading or cloning the project, perform the following steps

# setup a paired M4 iPad and the code signing information
./setup
# compile the project and install it on the iPad
make build
# run the tests — this will take a while!
make run
# copy the benchmark results
make copy_results

After the testing is done, the generated JSON reports are copied from the iPad and placed in the results/ folder. If you have R and Quarto installed, you can also build the R-Markdown reports using make reports.

By default, both single-core and multi-core tests are executed. This can take a long time. If you are only interested in peak single-core rates, you can change the second line in src/tests.swift from let multiCoreTests = true to false and rebuild.

m4-sme-exploration (tzakharko/m4-sme-exploration)

Searching Database…

这是什么?一个研究项目,针对苹果 M4 芯片的可扩展矩阵扩展(SME)进行微基准测试,测量常见矩阵和向量运算的峰值计算吞吐量以及内存传输速率。
那它是一个完成的应用,还是更像是带代码的实验记录?这是一项持续进行的研究:Swift 微基准测试,加上用来生成测试变体的 Python 脚本,并收集 JSON 结果,通过 Quarto 渲染成 R Markdown 报告。
我自己怎么运行这些基准测试?把一台 M4 iPad Pro 与你的 Mac 配对,安装 XcodeGen(brew install xcodegen)和 PyYAML,在 Xcode 中生成并构建测试,然后运行——默认会跑单核和多核测试,可能需要很长时间。
我需要安装哪些东西?一台已与你的 Mac 配对并开启开发者模式的 M4 iPad Pro、带 Command Line Tools 的 Apple Xcode、XcodeGen、带 PyYAML 的 Python3,如果你还想查看渲染好的报告,还需要 Quarto 和 R/tidyverse。
我可以在 M4 Mac 上运行而不是 iPad 吗?目前还不行——这个项目现在只能在外接的 M4 iPad Pro 上运行。作者计划等 M4 Mac 上市后在本地运行这些测试。
这些基准测试具体测的是什么?常见矩阵和向量运算的峰值计算吞吐量,以及用各种方法测得的内存传输速率——最初的实验涵盖了外积(outer-product)微基准测试。
测试默认会使用所有 CPU 核心吗?会,单核和多核测试都会运行,而且可能耗时很长。如果你只想要单核峰值速率,可以在 src/tests.swift 中把 let multiCoreTests = false 改掉然后重新构建。
这个项目做完了吗?还没有——作者预计会随着硬件新方面的测试不断扩展它,欢迎提交 pull request 和发表评论。
在哪里可以看到关于 M4 SME 的更深入分析?README 推荐了耶拿大学(Jena)一个团队做的深入研究,他们正在基于 M4 SME 构建高性能 GEMM 实现,并称这是一篇关于该主题的精彩读物。
Creator
tzakharko
Size
13.6 MB
Stars
245
Updated
CommitSep 02
Age
2y
Commits · 90 Days