Component: conformance; x86 macOS guest on the Linux Vulkan PCI pathway, rail macos-15.
Add a 290-case Metal battery, native Apple M4 oracle, split driver and translation ownership inventories, focused modes, boot manifests, artifact hashing, typed failure scoring, and catastrophic-run gates. This is test-only and changes no device behavior.
The API invariant is monotonic, oracle-backed compatibility: native results establish each Metal relation, while guest failures remain explicit debt owned by either translation or the device. Missing, duplicate, unexplained, and uncovered results fail the scorer.
Verification:
- Apple M4, macOS 15.6.1 build 24G90: full native oracle 290/290 PASS, zero skips.
- verdict unit tests: 5/5 PASS.
- run-native.sh and run-guest.sh: bash syntax clean.
- baseline file matches the final full native result byte-for-byte.
- current focused VM runs: integer clear and topology repeated clean; RGBA32Float clean with guest import on and off; indexed draw repeated with three classified driver failures and zero unexplained results.
- focused candidate boots loaded QEMU SHA-256 0b4ed961deaac18886b4e1ca8eb1db2a34c7e7f06e46b53652167e6dba61951d and static library SHA-256 512fa87458223053e3ca1a58e49501d28705f26b95984c211581d74ee91d195c from source fa29b2e527.
Not verified: there is no single complete 290-case guest run. The earlier 276-case full candidate emitted four stamp-wait timeouts and is not a passing validation. The consolidated macos-15 ledger is 184 pass, 77 classified driver failure, and 29 capability skip. Other guest rails and Apple-host backends were not run.
59 lines
2.4 KiB
Swift
59 lines
2.4 KiB
Swift
import Metal
|
|
import Foundation
|
|
|
|
// A concurrent compute encoder promises no ordering between dispatches except
|
|
// the dependency named here. Alternating the token makes every stale word a
|
|
// deterministic wrong answer after the first round.
|
|
func computeBarrierCase(resourceBarrier: Bool) {
|
|
let label = resourceBarrier ? "compute_barrier_resource" : "compute_barrier_scope_buffers"
|
|
let count = 8192
|
|
let bytes = count * MemoryLayout<UInt32>.size
|
|
let writePipe = pipeline("compute_barrier_write")
|
|
let readPipe = pipeline("compute_barrier_read")
|
|
|
|
guard let words = dev.makeBuffer(length: bytes, options: .storageModePrivate),
|
|
let verdict = dev.makeBuffer(length: bytes, options: .storageModeShared) else {
|
|
report(label, false, "resource creation failed")
|
|
return
|
|
}
|
|
|
|
for round in 0..<8 {
|
|
memset(verdict.contents(), 0, bytes)
|
|
var token: UInt32 = round.isMultiple(of: 2) ? 0x13579BDF : 0x2468ACE0
|
|
let cb = queue.makeCommandBuffer()!
|
|
let enc = cb.makeComputeCommandEncoder(dispatchType: .concurrent)!
|
|
enc.setComputePipelineState(writePipe)
|
|
enc.setBuffer(words, offset: 0, index: 0)
|
|
enc.setBytes(&token, length: MemoryLayout<UInt32>.size, index: 1)
|
|
enc.dispatchThreadgroups(
|
|
MTLSize(width: count / 64, height: 1, depth: 1),
|
|
threadsPerThreadgroup: MTLSize(width: 64, height: 1, depth: 1))
|
|
|
|
if resourceBarrier {
|
|
enc.memoryBarrier(resources: [words])
|
|
} else {
|
|
enc.memoryBarrier(scope: .buffers)
|
|
}
|
|
|
|
enc.setComputePipelineState(readPipe)
|
|
enc.setBuffer(words, offset: 0, index: 0)
|
|
enc.setBuffer(verdict, offset: 0, index: 1)
|
|
enc.setBytes(&token, length: MemoryLayout<UInt32>.size, index: 2)
|
|
enc.dispatchThreadgroups(
|
|
MTLSize(width: count / 64, height: 1, depth: 1),
|
|
threadsPerThreadgroup: MTLSize(width: 64, height: 1, depth: 1))
|
|
enc.endEncoding()
|
|
cb.commit()
|
|
cb.waitUntilCompleted()
|
|
|
|
let got = verdict.contents().bindMemory(to: UInt32.self, capacity: count)
|
|
if let bad = (0..<count).first(where: { got[$0] != 1 }) {
|
|
report(label, false,
|
|
"round=\(round) word=\(bad) got=\(got[bad]) want=1")
|
|
return
|
|
}
|
|
}
|
|
|
|
report(label, true, "8 alternating concurrent producer/consumer rounds were visible")
|
|
}
|