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

Doesn't work on macOS Monterey. #22

Open
nicholassm opened this issue Sep 11, 2023 · 6 comments
Open

Doesn't work on macOS Monterey. #22

nicholassm opened this issue Sep 11, 2023 · 6 comments

Comments

@nicholassm
Copy link

Hi,

I've tried the library successfully on Linux but on my development machine running macOS Monterey (version 12.6.3) it doesn't work with version 0.8.0 or 0.8.1 of this crate.

The Vec of available cores returned by core_affinity::get_core_ids() does contain the core I'm trying to pin to but the boolreturned from core_affinity::set_for_current(core_id) is false.

Are there any tricks I need to apply on Mac?

Kind regards,
Nicholas

@jeffutter
Copy link

I’ve noticed this on Sonoma on a Apple Silicon Mac as well. In fact tests on this repo catch the error:

running 4 tests
test macos::tests::test_macos_get_core_ids ... ok
test macos::tests::test_macos_set_for_current ... FAILED
test tests::test_get_core_ids ... ok
test tests::test_set_for_current ... FAILED

@jeffutter
Copy link

Seems like Apple Silicon may not support this call (and core pinning may be less useful on this architecture due to all cores sharing a unified cache?). So I guess I’ll just log a warning for now.

@nastynaz
Copy link

nastynaz commented May 1, 2024

Having the same issue on the M1 Max with Ventura 13.2.1. Is there any other way to achieve the same thing?

@cdolan
Copy link

cdolan commented May 10, 2024

Apple Silicon likely doesn't support thread affinity due to its heterogeneous architecture, which consists of performance and efficiency cores.

@ssh352
Copy link

ssh352 commented Sep 17, 2024

I have an Intel Mac, set_for_current always return false too.

" CPU binding is not supported on MacOS due to the lack of the necessary interface from Apple."

@azaslavsky
Copy link

Has anyone had any luck with a workaround? I would like to simulate a program running a single core machine for some testing. I know CPU affinity isn't an ideal way to do this (it is an affinity, not a guarantee, after all), but it would be nice at least for development-time experimentation, and I'd really like to avoid having to resort to a VM to make it happen.

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

6 participants