1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Workflow compute builtin namespace test.
struct Params
count: uint
scale: float
end
struct DataBuffer
values: [64]float
end
group sim = 0
buffer params: Params
buffer data: DataBuffer
end
shared scratch: [64]float
compute main @workgroup_size(64, 1, 1)
do
let idx = work.local_index
let gid = work.global_id.x
let lid = work.local_id.x
let group_x = work.group_id.x
if gid < params.count then
scratch[idx] = data.values[idx] * params.scale
barrier()
data.values[idx] = scratch[idx] + float(lid + group_x)
end
end