llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[llvm-mca] Warn the user or error if there is no accurate CPU model for selected -mcpu

Open ktkachov opened this issue 10 months ago • 4 comments

Currently if a user passes an -mcpu=option to simulate a certain instruction sequence MCA will use whatever scheduling model is specified for that CPU internally in LLVM. Usually if there is no accurate scheduling model added when a new -mcpu option is upstreamed a sensible default is selected. This is fine for instruction scheduling optimisations, but I would argue is unhelpful for MCA users and can lead to confusion.

For example, in aarch64 many CPUs default to Cortex-A510 scheduling in the absence of dedicated models, but silently simulating a Cortex-A510 in MCA when an unsuspecting user selects a different -mcpu option is unhelpful

ktkachov avatar Feb 05 '26 15:02 ktkachov

@llvm/issue-subscribers-tools-llvm-mca

Author: Kyrill Tkachov (ktkachov)

Currently if a user passes an -mcpu=option to simulate a certain instruction sequence MCA will use whatever scheduling model is specified for that CPU internally in LLVM. Usually if there is no accurate scheduling model added when a new -mcpu option is upstreamed a sensible default is selected. This is fine for instruction scheduling optimisations, but I would argue is unhelpful for MCA users and can lead to confusion.

For example, in aarch64 many CPUs default to Cortex-A510 scheduling in the absence of dedicated models, but silently simulating a Cortex-A510 in MCA when an unsuspecting user selects a different -mcpu option is unhelpful

llvmbot avatar Feb 05 '26 15:02 llvmbot

In many cases using processor A's scheduling model for -mcpu=B is actually intended. It is totally possible that A's scheduling model is "good enough" for processor B -- not just for instruction scheduling purposes but also on MCA simulation accuracy. In other words, it's possible that those processors which use Cortex-A510 scheduling model share the a really similar uArch with Cortex-A510 and creating a dedicated scheduling models for those processors might only lead to little MCA accuracy improvement.

The bottom line is: probably only the vendor knows whether a -mcpu uses an accurate scheduling model for MCA purposes. I think we can add another field in Processor to indicate this, and throw a warning to llvm-mca user as you suggested.

mshockwave avatar Feb 05 '26 22:02 mshockwave

I removed the "Bug" tag because this is not a bug -- this is a compromise / limitation

mshockwave avatar Feb 05 '26 22:02 mshockwave

In many cases using processor A's scheduling model for -mcpu=B is actually intended. It is totally possible that A's scheduling model is "good enough" for processor B -- not just for instruction scheduling purposes but also on MCA simulation accuracy. In other words, it's possible that those processors which use Cortex-A510 scheduling model share the a really similar uArch with Cortex-A510 and creating a dedicated scheduling models for those processors might only lead to little MCA accuracy improvement.

The bottom line is: probably only the vendor knows whether a -mcpu uses an accurate scheduling model for MCA purposes. I think we can add another field in Processor to indicate this, and throw a warning to llvm-mca user as you suggested.

That would be fine with me, I suppose the vendor adding support for their new -mcpu should make a conscious call on whether they're happy for MCA to reuse a different model for their new core

ktkachov avatar Feb 09 '26 10:02 ktkachov