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…

Что это такое?Исследовательский проект с микро­бенчмарками расширения Scalable Matrix Extension (SME) чипа Apple M4: он измеряет пиковую вычислительную производительность типичных матричных и векторных операций, а также скорости передачи данных в памяти.
Это готовое приложение или скорее лабораторный журнал с кодом?Это продолжающееся исследование: микро­бенчмарки на Swift плюс скрипты на Python, которые генерируют варианты тестов, собранные результаты в JSON и отчёты в R-Markdown, собираемые через Quarto.
Как мне самому запустить эти бенчмарки?Подключите M4 iPad Pro к своему Mac, установите XcodeGen (brew install xcodegen) и PyYAML, сгенерируйте и соберите тесты в Xcode, а затем запустите их — по умолчанию в однопоточном и многопоточном режимах, что может занять много времени.
Что должно быть установлено?M4 iPad Pro в режиме разработчика, подключённый к вашему Mac, Apple Xcode с Command Line Tools, XcodeGen, Python3 с PyYAML, а также Quarto с R/tidyverse, если нужны и готовые отчёты.
А можно запустить это на Mac с M4 вместо iPad?Пока нет — проект сейчас работает только на внешнем M4 iPad Pro. Автор планирует запускать тесты локально, когда появятся Mac с M4.
Что именно измеряют бенчмарки?Пиковую вычислительную производительность типичных матричных и векторных операций, а также скорости передачи данных в памяти разными способами — первые эксперименты охватывают микро­бенчмарки внешнего произведения (outer product).
По умолчанию тесты задействуют все ядра процессора?Да, запускаются и однопоточные, и многопоточные тесты, и это может занять много времени. Если нужны только пиковые показатели одного ядра, поставьте let multiCoreTests = false в src/tests.swift и пересоберите проект.
Проект уже завершён?Нет — автор планирует развивать его по мере тестирования новых аспектов железа, приветствуются пул-реквесты и комментарии.
Где можно почитать подробный разбор M4 SME?В README рекомендуют глубокое исследование команды Университета Йены, которая разрабатывает высокопроизводительную реализацию GEMM на M4 SME, — там это названо отличным материалом по теме.
Creator
tzakharko
Size
13.6 MB
Stars
245
Updated
CommitSep 02
Age
2y
Commits · 90 Days