iosobjective-cswiftmetalkitmetal-performance-shaders

How to use compute function in Metal API in iOS for Multiplication


I am new to Metal API in iOS. So my question is, how to use Metal compute function for Multiplication, for instance,

let say we are having two float[] arrays of length 2048, we want to multiplicate corresponding elements together forming another array of floats[] of 2048

like this

res[i] = a[i] * b[i];

With a[] and b[] an array of 2048 floats

and res[] another array of 2048 floats

The next step is to perform that "operation", 2048 times.

Can someone please help me with this.

if possible, I need to do this in Objective-c, but I can read swift as well.

Thank you in advance.


Solution

  • This tutorial : https://machinethink.net/blog/mps-matrix-multiplication/ As well as This one: https://www.youtube.com/watch?v=lSofOJrFsJ4&ut=

    Really helped me out!