Lesson 1 — Vector addition

The GPU data-parallel hello world: given two arrays a and b of the same length, produce a third array c where every element is the sum of the corresponding elements. Mathematically, c[i] = a[i] + b[i] for every index i.

On a GPU this is trivially parallel: thread i reads a[i] and b[i], adds them, and writes the result to c[i]. No thread depends on another thread's output.

Your task

The kernel below reads buffers a and b and is supposed to write their sum into c. Replace the (* TODO *) with the correct expression, then click Run on my GPU.

Click "Run on my GPU" to execute your kernel.
Hint

Use the float addition operator +. (note the dot — OCaml uses +. for floats and + for ints). Access array elements with a.(i).