I followed the tutorial here for performing calculations on the GPU using Metal. I chose to rewrite the example using C++ and the metal-cpp library. The metal-cmake setup can be found in this repository along with other helpful examples.
The goal was to learn about how GPU computation pipelines work. In summary:
- Request a GPU device.
- Establish a library on the device that consists of compiled MSL.
- Use functions to create pipeline state.
- Get a command queue, command buffer, and command encoder.
- Use the encoder to load variables, pipeline state, and thread specification.
- Close the encoder and commit the buffer to the queue.
- Wait for your work to be scheduled and executed.