Add support for changing cpu affinity - #988
Conversation
CPU affinity mask allows to specify set of processors for each thread. This could be used in seveal ways: * limit cpu power to show how benchmark scales with machine size * bind threads to processors to eliminate noise from cpu scheduler Add mehods Processors(), ProcessorRange(), DenseProcessorRange() which define count of available processors similar to count of threads. Method BindThreadsToProcessors() pins each thread to exactly one processor. When count of threads bigger than count of processors then processors are distributed in round-robin order. Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
|
|
||
| #ifdef BENCHMARK_OS_WINDOWS | ||
| DWORD_PTR procmask, sysmask; | ||
|  |
There was a problem hiding this comment.
These symbols look out of place here and elsewhere
|
looks like our CI doesn't cover android or ppc or riscv, so we may need some followups to support these platforms. It might be worth being more explicit in your |
yes, this code sets the cpu affinity on mac |
|
Yes, macos has no API for true cpu-affinity. Only binding each thread to one cpu. Maybe this feature should be dropped in favor of equal functionality for all platforms. Or we could keep it for platforms where it works. Macos machines are not so big in comparison to usual linux servers. |
CPU affinity mask allows to specify set of processors for each thread.
This could be used in seveal ways:
Add mehods Processors(), ProcessorRange(), DenseProcessorRange() which
define count of available processors similar to count of threads.
Method BindThreadsToProcessors() pins each thread to exactly one processor.
When count of threads bigger than count of processors then processors are
distributed in round-robin order.
Signed-off-by: Konstantin Khlebnikov khlebnikov@yandex-team.ru