Skip to content

Latest commit

 

History

History
13 lines (7 loc) · 1.08 KB

README.md

File metadata and controls

13 lines (7 loc) · 1.08 KB

The GPGPU Function

| 👈 👆 | 🫵 🇺🇸 🇵🇹 |


The GPU function is written in the Metal Shading Language which is based on the C++14 standard. An elementary point is the data provision to the compute kernel for our GPGPU programming.

Almost looking like a C++ function, some keywords are Metal specific. Our GPU function is tagged with the kernel keyword, making the compute function public visible that runs on our GPU. The return value of a compute function is necessarily void, because the exchange with the calling CPU program takes place via the shared memory.

Information is given to the parameters using address space attributes. Immutable (read-only) data is marked with constant. However, parameters marked with device are both readable and writable.

And then there is thread_position_in_grid, which in this example gives us the index, similar to the running variable in a for loop.