Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.
C
docs: every compute kernel of the corpus now runs on the Adreno -- 47 of 47
vcvkk7721358598c1
diff --git a/README.md b/README.mdindex 1e2fea8..76c80a4 100644--- a/README.md+++ b/README.md@@ -27,7 +27,7 @@|---|---|| Экран блокировки, разблокировка свайпом, домашний экран с полным набором значков (две страницы), стандартные обои iOS 16 | Сотовая сеть, Bluetooth || Системные жесты: свайп снизу — «домой» и переключатель приложений, свайп от левого края — «назад», Пункт управления | Без `gpu=1` (программный рендер; в QEMU всегда) часы экрана блокировки просто белые, без «вибрации» под цвет обоев, и верх обоев под ними не затемнён |-| Запуск приложений: Настройки (вглубь), Часы, Календарь, Фото, Заметки и др.; расширения приложений (виджеты «Погода» и «Календарь» на домашнем экране рисуют своё содержимое — на телефоне; в QEMU им не хватает скорости) | Metal у приложений (они рисуют через него сами; WebGL, видоискатель «Камеры», эффекты снимка). Но уже не «не предполагается»: наш передний конец читает шейдеры, которые Apple скомпилировала для Metal, и исполняет их на Adreno — 51 из 456 прошли на GPU телефона: 7 отрисовкой (шесть текстурных вернули точный тексель) и 44 вычислительных ядра диспатчем. 71 операция `air.*` сходится с LLVM на всех 45 697 случаях, 61 из них проверена на самом Adreno; слово состояния сэмплера не разобрано, то есть фильтрация и адресация самой Apple не проверены. См. `docs/air.md` |+| Запуск приложений: Настройки (вглубь), Часы, Календарь, Фото, Заметки и др.; расширения приложений (виджеты «Погода» и «Календарь» на домашнем экране рисуют своё содержимое — на телефоне; в QEMU им не хватает скорости) | Metal у приложений (они рисуют через него сами; WebGL, видоискатель «Камеры», эффекты снимка). Но уже не «не предполагается»: наш передний конец читает шейдеры, которые Apple скомпилировала для Metal, и исполняет их на Adreno — 54 из 456 прошли на GPU телефона: 7 отрисовкой (шесть текстурных вернули точный тексель) и все 47 вычислительных ядер корпуса диспатчем. 71 операция `air.*` сходится с LLVM на всех 45 697 случаях, 61 из них проверена на самом Adreno; слово состояния сэмплера не разобрано, то есть фильтрация и адресация самой Apple не проверены. См. `docs/air.md` || Сенсорный экран телефона (Goodix GT9916), мультитач, пробуждение касанием | Без `cpus=N` работает одно ядро процессора || Несколько ядер процессора (`cpus=8`: все семь, что не заняты загрузчиком; малые — после больших) | || Кнопки: на телефоне настоящие — питание (боковая кнопка iPhone) и громкость; в QEMU — клавишами | Зарядка под нашим ядром (телефон только разряжается) |@@ -542,7 +542,7 @@ P3 поверхности кадров копировались, и этого| транслируется в NIR и проходит `nir_validate` | 321 || компилируется ir3 в машинный код Adreno | 321 || совпадает с LLVM численно и **рисуется** (softpipe) | 255 |-| запущено на самом GPU телефона (Adreno 7c+ Gen 3, через `msm` в ядре): 7 отрисовкой, 44 диспатчем | **51** |+| запущено на самом GPU телефона (Adreno 7c+ Gen 3, через `msm` в ядре): 7 отрисовкой, 47 диспатчем | **54** |Это **все 321 точки входа** корпуса (остальные 135 модулей — библиотечные функции `air.visible`,не точки входа): 271 фрагментный шейдер, 47 вычислительных ядер и 3 вершинных. Смысл каждой@@ -640,14 +640,14 @@ P3 поверхности кадров копировались, и этогоСтрока таблицы «запущено на самом GPU телефона» этих модулей не считает: она про модули корпуса из456, а набор — сгенерированные, в корпус не входящие, и складывать два измерения нельзя. Сама строка-теперь **51** по другой причине: 7 фрагментных шейдеров отрисовкой и 44 вычислительных ядер+теперь **54** по другой причине: 7 фрагментных шейдеров отрисовкой и 47 вычислительных ядердиспатчем, множества не пересекаются — ядро не фрагментный шейдер. До прогона ядер там стояло 7, инекоторое время после него тоже, и это третий раз, когда именно эту цифру оставляет позади работа,которая её и сдвинула.Чего нет: 64-битное слово состояния семплера (`constexpr sampler`) не разобрано;-из 47 вычислительных ядер Apple 44 отправлены на Adreno, а три стали транслироваться позже-измерения и прогона ещё не видели;+все 47 вычислительных ядер Apple отправлены на Adreno, но сравнить их результат не с чем:+softpipe не выполняет 41 из них, так что «отправлено» — это не «посчитано верно»;`air.fast_pow` на Adreno даёт NaN при отрицательном основании, где softpipe даёт точное значение — постандарту это разрешено (`fast::` в Metal, как `native_` в OpenCL, вне своей области определения неопределены), но всякий шейдер корпуса, у которого основание может уйти ниже нуля, поведёт себя наdiff --git a/docs/air.md b/docs/air.mdindex 8290b75..faa4b1d 100644--- a/docs/air.md+++ b/docs/air.md@@ -23,7 +23,7 @@ Of the 456 modules of the device's system `.metallib` files (`tools/air/check.sh| translated to NIR, passing `nir_validate` | 321 || compiled by ir3 into Adreno machine code | 321 || numerically identical to LLVM's own execution, and drawn | 255 |-| **run on the phone's GPU** — 7 drawn, 44 dispatched | **51** |+| **run on the phone's GPU** — 7 drawn, 47 dispatched | **54** |And of the 119 distinct `air.*` operations those modules call (`tools/air/intrincheck.py`):@@ -343,33 +343,31 @@ functions and not entry points at all.`air_get` already materialises one in whichever builder asks, which was checked rather thanassumed.-- **Of Apple's own 47 kernels, 44 are dispatched on the Adreno and none crash.**+- **Of Apple's own 47 kernels, all 47 are dispatched on the Adreno and none crash.**`tools/air/kernelcheck.py` prints where each one stops, as a table whose rows are checkedagainst the total before it is printed:| | on softpipe | **on the Adreno** || --- | --- | --- |- | dispatched and read back | 6 | **44**, with 3 not yet run |+ | dispatched and read back | 6 | **47** || softpipe's `nir_to_tgsi`: scratch and intrinsics it lacks | 41 | — || a shuffle mask our reader would not decode (ours, now fixed) | 0 | 0 || **crashed `air_run`** (a defect here, not a limit) | 0 | **0** |- The three in the last-but-one row were refused when the Adreno column was measured, so that- column says 44 of 47 and not 47 of 47: they translate and ir3 compiles them now, and whether- they dispatch is a question for the next run rather than a figure to carry forward. Two of the- three read and write textures, which is the shape that crashed before the sampler fix, so the- run is worth more than a tick.+ `logs/170547-run.log`, 710 919 bytes with no truncation marker. The three that the shuffle-mask+ fix unblocked dispatched on the first run and read their images back; two of them bind six+ textures, which is well past where the sampler bug used to fault, so that fix is confirmed a+ second time by shaders it was not measured on.**The deferred question is answered: ir3 runs them.** 41 kernels stop at a software rasteriser- that has no scratch memory and lacks compute intrinsics; on the hardware 44 of the 47 dispatch- and read their results back, and every one of the 23 that bind an image is among them. The phone- replaced softpipe and the column that was never ours emptied. **All 47 now translate and compile- through ir3** — so does every other entry point of the corpus — and the only column with a gap- left in it is the one the phone fills.+ that has no scratch memory and lacks compute intrinsics; on the hardware every one of the 47+ dispatches and reads its result back, images and all. The phone replaced softpipe, and both+ columns that were ours — the harness's refusals and the frontend's — are empty.What the rows do **not** say is right. There is no executed reference for these kernelsanywhere: softpipe refuses 41 of them, which is why they came here, so a number out of the- Adreno has nothing on this machine to disagree with. 44 have been shown to *run*.+ Adreno has nothing on this machine to disagree with. 47 have been shown to *run*, which is a+ statement about capability and not about correctness.**The last row was blaming the shader for our own gap.** "A shuffle mask that is not constant"was impossible as written: LLVM requires a `shufflevector` mask to be constant, so the message