규칙 11.23
11장, 대상과 오라클 테스트
A compiled program may carry more than one WGSL text of a compute entry (a variant). Every variant of an entry must write the same bits for every input, except where a rule records a divergence between them. The runtime must select a variant when it opens a device, from the device’s features and from a known-answer probe that runs the variant’s shape once on the device and compares what it wrote with the known answer; a variant whose probe fails, or whose feature the device lacks, must not be selected, and the device’s report must say what the probe saw and which text each kernel call ran. A feature a variant alone needs must not be in the module’s requiredFeatures (Rule 10.2); the runtime requests it where the adapter has it. The subgroup variant of a kernel function’s loop (Rule 8.22) is one: it needs subgroups, createDevice({ subgroups: 'off' }) keeps it off, DeviceInfo.subgroups is the probe’s observation and DeviceStatistics.variants the text each call ran.
규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.
근거
docs/compiler-owns-performance.md (sections 1 and 6): a program must become faster when the compiler improves with no change to its source, and a device difference belongs to the compiler and the runtime, so a faster form a device may lack is a text the runtime picks, as the emulated double’s flavor is picked (changes 0073 and 0085), and a probe selects it on a device with unknown signals and refuses it on one whose driver folds wrongly. A WGSL module that spells enable subgroups; does not compile on a device without the feature, so a branch inside one text cannot choose. The bits are held equal so that selection is invisible to the author; a divergence a rule records (an f32 sum, Rule 7.2) is kept out of every variant until the rule changes.
출처
changes/0119-subgroup-reduction-variant.md (sections 2 to 5, decisions O1, O3 and O4); docs/compiler-owns-performance.md; changes 0073 and 0085 (the flavor axis); #536.
검증 방식
테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.
컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.
src/core/subgroup-probe.ts (the probe’s text, its known answers and probeSubgroups), pinned by src/core/subgroup-probe.test.ts; createDevice and DeviceImpl in src/runtime/device.ts and gpuDevice in src/core/host-entry.ts (the probe at open, the option, the observation and the statistics), pinned by src/runtime/device.test.ts (a device that passes, fails, lacks the feature or keeps it off, and the default owner); textOf in src/core/host-kernel.ts (the dispatch’s choice); journeys/subgroup-folds/ (equal bits on a device that selects the variant).
커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.
설명하는 절
커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.
함께 보기
소스
커밋 af54ddad5의 규칙 원문:
docs/language-design.md:1703(설계 문서)reqs/rules/RULE-1123.md(추적 항목)