Post

Replies

Boosts

Views

Activity

Generating Psuedorandom numbers very quickly using Swift?
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
625
Sep ’22
What is "Package Power" in Powermetrics?
I am using powermetrics to collect the cpu_power information. I have a small command-line utility that uses some blas functions in Accelerate and I'd like to quantify the energy consumption of the algorithm. My workflow is to start powermetrics, wait 1 second, start my program, and then stop powermetrics. During that 1 second waiting period, "Package Power" is: If GPU power is 0, Package power is exactly equal to CPU power even though DRAM power is not 0 If GPU power is not 0, Package power is usually (but not always) equal to CPU + GPU power even though DRAM power is not 0 When my algorithm is running, Package power is sometimes greater than the sum of everything else, but sometimes not. I've tried using powermetrics with other programs and am seeing similar results. It appears that whatever "Package Power" means, it does not include "DRAM Power". The man page doesn't have any information, and other internet searches turn up empty or are definitely wrong. Using blas functions on Apple Silicon could mean that the data is processed on one of the accelerator components rather than the traditional CPU cores and I'd really like to ensure I am capturing the energy usage without over or undercounting. Thanks in advance!
1
0
1.5k
Jun ’22