MPSMatrix wastes time calling getenv() over and over

I Instrument's CPU Profiling tool I've noticed that a significant portion (22.5%) of the CPU-side overhead related to MPS matrix multiplication (GEMM) is in a call to getenv(). Please see attached screenshot.

It seems unnecessary to perform this same check over and over, as whatever hack that needs this should be able to perform the getenv() only once and cache the result for future use.

Replies

Hi, I agree this seems excessive. Thanks for finding this, do you mind filing a bug report on feedback assistant with a sample project that reproduces this issue? Also post the feedback ID here so we can track it. Thank you!

Hi,

please see https://feedbackassistant.apple.com/feedback/13367810 .

I was unable to attach anything to the Issue, the attachment form gives a HTTP 403 error code, but it should be easy to reproduce from the steps provided.

Thank you! Jacob

  • Yes, I see the small sample code you provided, which seems easy enough to replicate internally. I’ve moved this to the Metal Performance Shaders team to take a look at. Thanks!

Add a Comment