Skip to content

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

air: the rule is truncation, and i2f truncates too; marker counts corrected

vcvkk5e1021002fc7
diff --git a/README.md b/README.md
index 3ca0f86..2c78aba 100644
--- a/README.md
+++ b/README.md
@@ -260,16 +260,23 @@ XL_SECS=900 XL_CMDLINE="touchscreen=1 cpufreq=1 bootcpu=7 cpus=8" ./xl run #
нашлись первые 27. `XL_FOLLOW` от этого не спасает: к моменту, когда он забирает журнал, середина уже
выброшена. И фильтр не спасает — он убирает строки, которых уже нет.
-**Проверять надо размер файла, а не длину окна и не флаги сборки.** Предел — ровно 1 466 58x байт
-(256 КБ + 1 МБ + строки-маркеры), и журнал такого размера обрезан по определению, сколько бы маркеров
-выброса в нём ни стояло (бывает и четыре). Журнал меньше этого — целый. Три прогона одного и того же
-набора на 225 модулей, все собранные с `QUIET=1`:
-
-| окно | размер журнала | модулей в журнале |
-| --- | --- | --- |
-| `XL_SECS=300` | 1 466 579 | 2 |
-| `XL_SECS=120` | 1 466 582 | 28 |
-| `XL_SECS=30` | 1 185 596 | **225** |
+**Проверять надо две вещи, и обе однозначны: размер файла и маркер по его точному тексту.** Предел —
+1 466 58x байт (256 КБ + 1 МБ + строка маркера), и журнал такого размера обрезан; маркер
+`the log between the first 256 KB and the last 1 MB was dropped` стоит в обрезанном журнале **ровно
+один раз** и в целом не стоит вовсе. Четыре прогона одного и того же набора на 225 модулей, все
+собранные с `QUIET=1`:
+
+| окно | размер журнала | маркеров | модулей в журнале |
+| --- | --- | --- | --- |
+| `XL_SECS=300` | 1 466 579 | 1 | 2 |
+| `XL_SECS=120` | 1 466 582 | 1 | 28 |
+| `XL_SECS=30` | 1 185 596 | 0 | **225** |
+| `XL_SECS=30` | 1 166 253 | 0 | **225** |
+
+**Грепать надо точный текст маркера, а не `was dropped`:** в ядре есть своя строка
+`buttons: reading the PMK8350's power-on block: the transfer was dropped`, и свободный греп считает
+её тоже — так получаются «2 маркера» в целом журнале и «4» в обрезанном, из чего можно заключить
+(и мы с другой сессией заключили), будто число маркеров ничего не значит. Оно значит: ноль или один.
Укладываться в предел помогают два рычага, и ни одного из них по отдельности не достаточно: короткое
окно (`XL_SECS`) и `QUIET=1` при сборке, который отправляет в никуда собственный поток launchd — те самые
@@ -538,8 +545,11 @@ P3 поверхности кадров копировались, и этого
по одной против эталона вне этого дерева, 71 из них совпадает с функциями C на каждом из 45 607 случаев,
47 — ещё и когда их **исполняет** softpipe, а не складывает оптимизатор (2 586 случаев), 10 атомиков и
барьер — на написанных для них ядрах, 13 текстурных операций — точно, по нескольким текселям каждая.
-**И все 78 прогнаны на самом Adreno телефона** (`logs/080952-run.log`, 20 октября): из 71 точно
-определённой операции **68 совпадают с C на каждом из 812 случаев, а 3 расходятся**. Заодно ответился
+**И все 78 прогнаны на самом Adreno телефона** (`logs/084315-run.log`, 20 октября): из 71 точно
+определённой операции **66 совпадают с C на каждом из 808 случаев, а 5 расходятся** — и все пять это
+преобразования целого в float: `air.convert.f.{f32,v2f32,v3f32}.u.*`, а после того как пул научился
+спрашивать про середины, ещё и знаковые `air.convert.f.{f32,v2f32}.s.*`, то есть `i2f` усекает так же,
+как `u2f`. Заодно ответился
открытый вопрос про узкие типы: 24 объявления с `i1`, `i8`, `i16`, `f16`, которые softpipe не может
исполнить вовсе (у TGSI регистры 32-битные), на Adreno исполнились и оказались среди совпавших — у ir3
настоящие 16-битные регистры, и они правы. Ни один модуль не отказался запускаться.
diff --git a/docs/air.md b/docs/air.md
index 07726e3..c751a6f 100644
--- a/docs/air.md
+++ b/docs/air.md
@@ -33,8 +33,8 @@ And of the 119 distinct `air.*` operations those modules call (`tools/air/intrin
| of those, exactly defined and agreeing on every case (45 607 cases) | 71 |
| of those, approximate, so measured against libm and nothing concluded | 7 |
| of those, also *run* by a Gallium driver rather than folded (softpipe, 2 586 cases) | 47 |
-| of those, run **on the phone's own Adreno** (812 cases) and agreeing there | 68 |
-| of those, **disagreeing on the Adreno** where every host engine agrees | 3 |
+| of those, run **on the phone's own Adreno** (808 cases) and agreeing there | 66 |
+| of those, **disagreeing on the Adreno** where every host engine agrees | 5 |
| the atomics and the barrier, against kernels written for them (`atomiccheck.py`) | 10 |
| texture operations verified exactly, on several texels each (`texopcheck.py`) | 13 |
| texture operations with a case softpipe cannot run: a 16-bit result | 7 |
@@ -55,9 +55,12 @@ functions and not entry points at all.
at all are exactly the ones where ir3 differs most from it.
On 20 October that stopped being true. All 78 declarations ran on the phone's own Adreno
- (`logs/080952-run.log`, section 4 item 4): **68 of the 71 exactly-defined ones agree with C on
- every one of 812 cases, and 3 disagree** — and the 3 are the whole point of having gone there,
- because every engine on this machine agrees with C about them.
+ (`logs/084315-run.log`, section 4 item 4): **66 of the 71 exactly-defined ones agree with C on
+ every one of 808 cases, and 5 disagree** — and the 5 are the whole point of having gone there,
+ because every engine on this machine agrees with C about them. All five are integer-to-float
+ conversions: `air.convert.f.{f32,v2f32,v3f32}.u.*` and, once the pool was sharpened to ask,
+ `air.convert.f.{f32,v2f32}.s.*` as well — `i2f` truncates exactly as `u2f` does, which the
+ earlier pool had no value to notice.
Two things that run went better than expected. The **24 narrow-type declarations** that softpipe
cannot run at all — `i1`, `i8`, `i16`, `f16`, where TGSI's 32-bit registers made a verdict
@@ -102,10 +105,23 @@ functions and not entry points at all.
the frontend is emitting the right opcode and a workaround there would hide a fault that belongs
to everything ir3 compiles.
- **A prediction that follows and has not been tested:** the port's OpenGL ES goes through the same
- ir3 and the same instruction, so a GLES shader converting a large `uint` to `float` on this phone
- should truncate identically. That would place the fault beyond this frontend entirely. It is one
- shader's worth of work and it has not been done.
+ **The prediction that followed has been tested and holds, by a peer session rather than here.**
+ The port's OpenGL ES goes through the same ir3 and the same instruction, so a GLES shader should
+ truncate identically — and `userland/src/u2f_test.c` (`RC=rc.u2f`) asks GLSL ES 3.0 the same
+ question through the same Mesa, with no AIR anywhere in it. Four of its six inputs disagree with
+ C on `freedreno; Adreno 7c+ Gen 3; OpenGL ES 3.2 Mesa 25.0.7`, and the two that agree are exactly
+ the two where truncation and rounding give the same answer — so agreement there is the absence of
+ a question, not a confirmation. **Everything ir3 compiles on this phone converts unsigned to
+ float by truncating, the window server's drawing included**, and this frontend is not party to
+ it: it is physically absent from that test.
+
+ **Which rule it is, as against merely "not round-to-nearest", is settled by one value.**
+ `0x01000003` is 2²⁴+3, half way between the representable 2²⁴+2 and 2²⁴+4; round-half-to-even and
+ round-half-away-from-zero both give 2²⁴+4, and the GPU gives 2²⁴+2. That is truncation and nothing
+ else. `0xFFFFFFFF` alone could never have shown this, and neither could `0x01000001`, the other
+ midpoint, where truncation and round-to-even happen to agree — which is why the pool carries both
+ and why one midpoint is not a test of a rounding rule. What remains unestablished is only whose
+ job the compensation is, and that still needs the a6xx ISA documentation.
- **`air.fast_pow` returns NaN on the Adreno for a negative base, where softpipe returns the exact
value.** `fast_pow(-0.5, 1)` is `-0.5` in C and on softpipe, and NaN on the phone. This is
diff --git a/tools/air/intrincheck.py b/tools/air/intrincheck.py
index f774288..f329240 100755
--- a/tools/air/intrincheck.py
+++ b/tools/air/intrincheck.py
@@ -1175,7 +1175,22 @@ def parse_runner_log(path):
def check_log(outdir, logpath, verbose):
"""Compare a runner log against the manifest. Where it ran is not our
business; what it computed is."""
- with open(os.path.join(outdir, "manifest.json")) as f:
+ # A log older than the manifest cannot have come from this suite, and
+ # comparing the two is worse than useless: the module ids are 0000.. in
+ # every suite, so an older log lines up perfectly and every expectation
+ # lands on a different operation's numbers. That produced a plausible
+ # "8 differ" with lines like "got 1 want 65535" before it was noticed to be
+ # nothing at all. Refused rather than warned, because the output of the
+ # mistake looks exactly like a finding.
+ mani = os.path.join(outdir, "manifest.json")
+ if os.path.getmtime(logpath) < os.path.getmtime(mani):
+ print("intrincheck: %s is older than %s, so it cannot be this suite's log "
+ "(every suite numbers its modules from 0000, so the ids would match "
+ "and the operations would not). Re-run the suite, or re-emit it if "
+ "the log is the one you mean."
+ % (os.path.basename(logpath), os.path.basename(mani)), file=sys.stderr)
+ return 1
+ with open(mani) as f:
manifest = json.load(f)
got, screen = parse_runner_log(logpath)
# TGSI's registers are 32-bit, so softpipe cannot run an operation on a