Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for asymmetric CPU cores #2557

Open
huoyaoyuan opened this issue Apr 9, 2024 · 3 comments
Open

Better support for asymmetric CPU cores #2557

huoyaoyuan opened this issue Apr 9, 2024 · 3 comments

Comments

@huoyaoyuan
Copy link
Member

When running benchmark on my Raptor Lake processor, I find the time of each iteration shifts between two values if I switch the console window to background.

This is probably due to the "smart" scheduling for P/E cores of Windows. I've also heard that thread affinity API getting ignored by the system in some situations.

It would also be interesting to see the results on E-cores. To be more general, there can be a configuration to set thread affinity for benchmarks. This can also help benchmarking for arbitrary core counts.

@timcassell
Copy link
Collaborator

We already support --affinity command line arg and Job.WithAffinity config option. Does that do what you need?

I've also heard that thread affinity API getting ignored by the system in some situations.

If that's true, that would be an issue for runtime or the OS, not BDN.

@huoyaoyuan
Copy link
Member Author

We already support --affinity command line arg and Job.WithAffinity config option. Does that do what you need?

--affinity 1 and --affinity 65536 give me significant comparison of P/E cores.

Is there more handy way to compare different affinities? Job is just heavier to use. I can't find affinity setting in attributes.

@timcassell
Copy link
Collaborator

I don't think there is another built-in way to do it. You could create your own attribute to do it, though.

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
public class AffinitizedJobAttribute : JobConfigBaseAttribute
{
    // Add whatever other settings you need.
    public AffinitizedJobAttribute(int affinity) : base(Job.Default.WithAffinity((IntPtr) affinity)) { }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants