TS8077
Front-end code KERNEL_WORKGROUP_REDUCES
A kernel function with @workgroup_size that has a loop which reduces (Rule 8.22). A reduction always runs in the tree of 256, so an attribute that asks for another size cannot be honored. The message names the function and the remedy.
The registry has no documentation comment for this constant, so the line above is written by this site from the messages the compiler raises it with.
The registry text and every compiler message on these pages are the compiler's own English.
Example
"use typeshade"
@workgroup_size([128])export function total(xs: array<f32>): f32 { let s = 0. for (let i: u32 = 0; i < xs.length; i++) { s += xs[i] } return s}Compiled at build time against the pinned compiler, this program gets:
TS8077 error, line 6: "total" has a loop that reduces, which always runs in workgroups of 256. Declare "total" without workgroup_size, or put the reduction in a function of its own.
How to fix it
The same program, corrected. It compiles with no diagnostic.
"use typeshade"
export function total(xs: array<f32>): f32 { let s = 0. for (let i: u32 = 0; i < xs.length; i++) { s += xs[i] } return s}The rule this enforces
- Rule 8.22 Test
- A kernel function is an exported function that is not an entry point, a function declaration, and takes at least one array with no size (
array<T>) or one 2D storage texture (texture_storage_2d<F, A>, change 0077), or returns an array with no size that its body makes (Rule 8.23, change 0114, S5); a sampled texture alone does not make one, so an exported helper that reads one stays a helper an entry calls; its candidate loops are theforandfor…ofstatements at the top level of its body, and no other loop is ever a candidate.
See also
Source
Where the compiler raises this code at commit af54ddad5, one line per file: