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
cpuref says what it did NOT cover: all 255 agreeing shaders are plain LLVM IR
vcvkk8481c4ac333f
diff --git a/docs/air.md b/docs/air.mdindex 0733e71..53a238a 100644--- a/docs/air.md+++ b/docs/air.md@@ -229,6 +229,21 @@ Three references, each independent of the translator:With the wrapper, only `void(const void *, void *)` crosses into C and the question does notarise.+ **And what those 255 do not cover: not one `air.*` function.** Every one of them is plain+ LLVM IR, so the agreement is a strong statement about the reader, the interface mapping+ (buffers to the right UBO index, result fields to the right render targets in the right order)+ and the instruction translation — and no statement at all about `air_intrinsics.c`. The+ shaders that do call `air.*` are exactly the ones this check cannot judge: the texture ones+ have a varying for a parameter, the math-heavy ones are compute kernels or `air.visible`+ library functions. So **all ~50 operations in `air_intrinsics.c` are unverified**, including+ two whose meaning is a guess and marked `UNVERIFIED` in the code (`air.fast_exp`: natural+ `exp` or `exp2`? and `air.fast_round`: away from zero or to even?). What would settle them is+ a shader whose intrinsic result is observable through a device buffer, compared the same way+ — which needs the buffer-readback half of this tool, i.e. M4's acceptance test. Writing C+ implementations of the `air.*` functions for the CPU side would *not* settle them: those+ implementations would encode the same beliefs as the translator, and a reference that agrees+ with you by construction is not a reference.+What it cannot decide, and says so rather than passing: a shader with a non-buffer argument —a varying, `air.position`, a thread id — because what is in it is the GPU's business (19 inAppleMetalGLRenderer, all of them the texture ones), and a compute kernel, which returnsdiff --git a/tools/air/cpuref.py b/tools/air/cpuref.pyindex 8b5292b..a6d8abe 100755--- a/tools/air/cpuref.py+++ b/tools/air/cpuref.py@@ -388,7 +388,7 @@ def compare(theirs, ours, tol):def run_all(args):"""Every function of a .metallib, with a count at the end."""b, header, funcs = metallib.parse(args.file)- agree = differ = skipped = 0+ agree = differ = skipped = with_air = 0for f in funcs:name = f.get("name")if not name:@@ -422,11 +422,33 @@ def run_all(args):differ += 1else:agree += 1+ if calls_air(b, header, f):+ with_air += 1print("agree %-44s %s" % (name, " ".join(theirs[:4])))print("\ncpuref: %d agree with LLVM, %d differ, %d could not be compared (of %d)"% (agree, differ, skipped, len(funcs)))+ # Which part of the frontend this actually exercised. A shader that calls+ # no air.* checks the reader, the interface and the instructions, and says+ # nothing whatever about air_intrinsics.c.+ print("cpuref: of the %d that agree, %d call an air.* function; %d are plain LLVM IR, "+ "so they test the reader, the interface and the instructions but no intrinsic"+ % (agree, with_air, agree - with_air))return 1 if differ else 0+def calls_air(b, header, f):+ """Does this module declare any air.* function?"""+ bc, _ = metallib.bitcode_of(b, header, f)+ with tempfile.TemporaryDirectory() as work:+ p = os.path.join(work, "m.bc")+ with open(p, "wb") as fp:+ fp.write(bc)+ try:+ ll = disassemble(p)+ except subprocess.CalledProcessError:+ return False+ return bool(re.search(r"^declare[^@\n]*@air\.", ll, re.M))++if __name__ == "__main__":sys.exit(main())