Skip to content

Conversation

@dgrove-oss
Copy link
Contributor

If pthread_getaffinity_np is available, then use the cpuset
of the current thread to determine the number of active cpus.

@MadCoder
Copy link
Contributor

why is that better?

@dgrove-oss
Copy link
Contributor Author

It gets the right answer if the program is being run under numactl with a restricted cpu set. sysconf doesn't consider scheduler affinity.

@MadCoder
Copy link
Contributor

I see, makes sense, could you please add a comment above to explain this shortly in the .c file ? because someone is bound to wonder at some point.

If pthread_getaffinity_np is available, then use the cpuset
of the current thread to determine the number of active cpus.
@dgrove-oss dgrove-oss force-pushed the hwconfig-respect-affinity branch from 7aeabe5 to e59638d Compare January 12, 2017 17:02
@dgrove-oss
Copy link
Contributor Author

good point; added a comment & squashed commit.

@MadCoder MadCoder merged commit 967876e into swiftlang:master Jan 12, 2017
@dgrove-oss dgrove-oss deleted the hwconfig-respect-affinity branch January 12, 2017 17:14
das pushed a commit that referenced this pull request Feb 21, 2017
consider affinity when computing active cpus on Linux

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
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

Successfully merging this pull request may close these issues.

3 participants