Task 1 of 6
Kernels don't reach out and grab data — data is handed to them
as arguments, and every thread sees the same arguments. What differs between threads is
exactly one thing: this.thread.x, the index of the output cell this thread owns.
Here data is a 64-number array. The kernel below runs 64 times — once per
output cell — and each run should pick out its own element.
data that belongs to this thread.data into the kernel as an argument (already wired up)this.thread.x — no loops over the array2With output: [64] there are 64 threads, numbered
this.thread.x = 0…63. Thread 7 should read data[7].
The whole kernel body is a single statement:
return data[this.thread.x] * 2;
threadIdx, WebGPU compute shaders get
bound buffers plus global_invocation_id. Same shape, different spelling.
This page is an interactive exercise — the editor, the GPU runner and your saved progress need JavaScript. The text above is the full brief.