uarch-bench icon indicating copy to clipboard operation
uarch-bench copied to clipboard

OSX support

Open travisdowns opened this issue 7 years ago • 5 comments

Should be easy to support OSX, in fact perhaps it already works.

We don't have a solution for reading performance counters on OSX, and it isn't clear the effort required to port the libpfc counters to that platform. It seems like PAPI won't work, but maybe we can get a driver from PCM?

travisdowns avatar Jun 01 '17 23:06 travisdowns

Hi!

Although I'm not currently a macOS user, I've noticed that Processor Counter Monitor (PCM; an open source fork of the discontinued Intel Performance Counter Monitor) provides support: https://github.com/opcm/pcm

In particular, its setup docs make a mention of the bundled MacMSRDriver: https://github.com/opcm/pcm/tree/master/MacMSRDriver https://github.com/opcm/pcm/blob/master/MAC_HOWTO.txt

MattPD avatar Jun 02 '17 15:06 MattPD

Thanks @MattPD - I noticed the same thing: see for example the PCM link in the original comment which points to an Intel SWF thread describing how a user modified the mac driver. I probably wont' get to this for a while, first I'll add Linux support for libpfc, then Windows, then ...

travisdowns avatar Jun 02 '17 18:06 travisdowns

Just linking in some additional comments on OSX support in an otherwise unrelated merge request.

travisdowns avatar Feb 19 '18 22:02 travisdowns

Not sure this is relevant, but macOS supports so called diagnostic calls [1], and one of them, namely dgEnaPMC [2], enables RDPMC from user mode [3]. It can be called via inline assembly as demonstrated in [1], but requires a kernel flag. I haven't tried it yet, but it looks promising. Also, performance counters can be configured via the private kperf.framework. XNU's source contains a useful example [4].

[1] http://newosxbook.com/MOXiI.pdf, page 292 [2] https://github.com/apple/darwin-xnu/blob/main/osfmk/i386/Diagnostics.c#L304 [3] https://github.com/apple/darwin-xnu/blob/main/osfmk/i386/Diagnostics.c#L413 [4] https://github.com/apple/darwin-xnu/blob/main/tests/kpc.c#L120

shinderuk avatar Mar 14 '21 14:03 shinderuk

No, dgEnaPMC call won't help. On my machine cpu_pmc_control is a no-op, probably due to #if !MONOTONIC condition. And I couldn't find any other place in XNU's source, where CR4_PCE is set. Sorry for bothering.

shinderuk avatar Mar 14 '21 17:03 shinderuk