규칙 11.7
이 페이지에서

규칙 11.7

11장, 대상과 오라클 테스트

The CPU tier, which runs a host call of a module’s function and, where there is no GPU tier, the invocations of an entry a host calls and the pixels of a fragment entry a host draws (Rule 8.24), is the oracle’s generated code (generateModuleJs) at f32 precision, written into the module the bundler reads as module code, with no new Function, over the op library alone, typeshade/runtime/internal. The CPU tier holds a kernel function’s texture in memory of its own (change 0077): a CpuTexture of src/core/cpu-texture.ts, the texels of a 2D texture in row order as the bytes of its format, which device.texture() makes on a device with no WebGPU device and which an ImageData is copied into. Over such a texture textureLoad, textureStore and textureDimensions compute: a store converts the value as WebGPU converts it for the format (a float format keeps the f32, a unorm or snorm one clamps to its range and rounds to the nearest step, an integer one keeps the low bits), a load outside the texture reads the nearest texel inside and a store outside is dropped. Every other texture builtin, and any of these over a texture that is not in that memory, keeps the stub contract (GPU_STUBS).

규칙 본문과 그 아래 항목은 설계 문서에 적힌 컴파일러 원문이라 한국어 페이지에서도 영어로 둡니다.

근거

a host call computes what the GPU would, so it rounds as f32 does, which the default f64 algebra oracle is blind to by construction. The generated code computes each operation as the interpreter’s runtime helper does: a vector operation of a known width, on operands nothing can leave missing, is written one component at a time, each the scalar operation the helper applies to it (dot, length, distance, normalize and cross summed in the order their entries sum), and every other operation, one on an operand that may be missing (a helper’s discard, an element read past an array’s end) among them, calls the helper itself; src/core/cpu-codegen.test.ts holds the two to each other bit for bit in both precisions, so the tier is the oracle and not a fourth implementation (Rule 11.1). Building it with new Function at run time would need unsafe-eval, which a strict content security policy forbids, and would ship the IR and the generator; as module code it is minified with the application, and the application ships the op library only.

출처

change 0009 in changes/ (“The CPU tier’s precision”); src/core/oracle.ts (the 'f32' mode, “a correctly-rounding f32 machine over the same IR”); Rule 11.1.

검증 방식

테스트로 확인합니다. 테스트나 게이트 스크립트, CI 워크플로가 이 규칙을 가리키고, 아래 파일 가운데 하나라도 규칙을 더는 가리키지 않으면 추적 검사가 실패합니다.

컴파일러가 이 규칙을 적용하는 곳을 규칙이 직접 적은 내용입니다.

hostFace in src/compiler/ts/host-face.ts, which generates at precision: 'f32', and src/runtime/host/runtime.ts, what a generated module imports through typeshade/runtime/internal; pinned by src/compiler/ts/host-face.test.ts, where every call equals compileModule(m, { precision: 'f32' }) on inputs chosen so the f32 and f64 answers part, and the generated module holds no new Function. The texture memory is CpuTexture and cpuTextureCall in src/core/cpu-texture.ts, which the generated code’s gpuStub asks first (src/core/cpu-codegen-runtime.ts); pinned by src/core/cpu-texture.test.ts (each format’s conversion, the channels, the edge), by src/compiler/ts/host-kernel-texture.test.ts (a kernel call on a device of the CPU tier, each byte as the format rounds it) and by the import journey, whose CPU-tier run of invertImage gives each byte its WebGPU run gives (change 0077).

커밋 af54ddad5에서 이 규칙을 확인하는 파일입니다. 파일마다 규칙을 처음 가리키는 줄로 연결했습니다.

설명하는 절

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

함께 보기

소스

커밋 af54ddad5의 규칙 원문:

이 페이지 편집 문제 보고