Hello,
There is some Metal sample code that is written in Objective-C (https://developer.apple.com/documentation/metal/performing_calculations_on_a_gpu). I wanted to implement this in Swift, but am running into a major performance issue.
The sample code fills two large buffers with pseudorandom data, and does so very quickly (a fraction of a second for ~14 million elements) using the rand() function. In my Swift version, I have tried many methods for generating data, but they all take between 6 and 10 seconds for the same ~14 million elements (the rand() function is not available in Swift) on my M1 Pro.
Surely there must be some method in Swift that can approximate the general speed of rand(). I'm more than willing to trade randomness for speed!
Any ideas?
6
0
788