---
title: "규칙 11.23: 대상과 오라클, TypeShade 셰이더 언어 설계 규칙과 그 근거, 출처, 검증 방식"
description: "TypeShade 언어 설계 규칙 11.23(대상과 오라클)입니다. A compiled program may carry more than one WGSL text of a compute entry (a variant)."
url: https://typeshade.dev/ko/reference/rules/11-23/
language: ko
---

# 규칙 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](https://typeshade.dev/ko/reference/rules/10-2/)); the runtime requests it where the adapter has it. The subgroup variant of a kernel function’s loop ([Rule 8.22](https://typeshade.dev/ko/reference/rules/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](https://typeshade.dev/ko/reference/rules/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](https://github.com/typeshade/typeshade/issues/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에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

- [`src/core/host-entry.ts:388`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-entry.ts#L388)
- [`src/core/host-kernel.ts:477`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-kernel.ts#L477)
- [`src/core/subgroup-probe.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/subgroup-probe.test.ts#L1)
- [`src/core/subgroup-probe.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/subgroup-probe.ts#L1)
- [`src/runtime/device.test.ts:1529`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/device.test.ts#L1529)
- [`src/runtime/device.ts:77`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/device.ts#L77)

## 설명하는 절

커밋 af54ddad5의 언어 문서에서 이 규칙을 설명하는 절입니다.

- [§65 A loop that runs as a kernel](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#65-a-loop-that-runs-as-a-kernel)
- [§69 Running a compiled program](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#69-running-a-compiled-program)

## 함께 보기

- [규칙 11.22](https://typeshade.dev/ko/reference/rules/11-22/) 테스트
- [규칙 11.27](https://typeshade.dev/ko/reference/rules/11-27/) 테스트
- [규칙 7.2](https://typeshade.dev/ko/reference/rules/7-2/)
- [규칙 8.22](https://typeshade.dev/ko/reference/rules/8-22/)
- [규칙 10.2](https://typeshade.dev/ko/reference/rules/10-2/)
- [설계 규칙](https://typeshade.dev/ko/reference/rules/)
- [오류 코드](https://typeshade.dev/ko/reference/errors/)

## 소스

커밋 af54ddad5의 규칙 원문:

- [`docs/language-design.md:1703`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1703) (설계 문서)
- [`reqs/rules/RULE-1123.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-1123.md) (추적 항목)
