CpuModule
인터페이스, CPU 오라클 분류
The shape both CPU backends return, so a caller can compile with compileModuleJs and fall back to compileModule without touching call sites.
import type { CpuModule } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
interface CpuModule { fns: Record<string, (...args: CpuValue[]) => CpuValue>; setBinding(name: string, value: CpuValue): void; dispatch(entry: string, workgroups: WorkgroupCount): DispatchReport;}설명
fns is a table of the
module’s declared functions by name, each taking its parameters positionally in declaration
order. setBinding supplies a storage or uniform binding’s value before a function that
reads it runs. The two backends return the same value for the same call:
compileModuleJs(m).fns.f(args) and compileModule(m).fns.f(args) agree under Object.is,
element for element.
인스턴스 속성
인스턴스 메서드
setBinding(name: string, value: CpuValue): voidSupply a storage or uniform binding’s value by its declared name, before invoking a function that reads it.
dispatch(entry: string, workgroups: WorkgroupCount): DispatchReportRun a
@computeentry overworkgroupsworkgroups of its declared size (one number for a 1-D grid, or the three counts), every invocation of a workgroup in lockstep at eachworkgroupBarrier()/storageBarrier(), with the builtin parameters (global_invocation_id,local_invocation_id,local_invocation_index,workgroup_id,num_workgroups) filled in (roadmap 0.2 item 5). Workgroup memory starts zero for each workgroup and a per-invocation variable at its initializer for each invocation; the bindings are the onessetBindingsupplied, arrays written in place. Throws when the invocations of one workgroup disagree about a barrier, naming its line and the counts. A kernel with no barrier may also be run one invocation at a time throughfns.
관련 가이드
함께 보기
소스
src/core/oracle.ts, 130행, 커밋 c66579bf 기준