onnxruntime
1c8a22ec - Improve logging and default affinity mask generation (#13338)

Commit
3 years ago
Improve logging and default affinity mask generation (#13338) ### Description Fix logging for affinity failures on Linux. Make `GetCpuCores()` consistently return the number of physical cores. Use `CpuInfo` library to correctly set affinities for Linux where supported. Make windows generate affinity masks as ordinals and convert them to masks at the setting site. Allow setting multiple logical processors affinity masks per thread. We continue to set all logical processors as thread affinity per physical core. ### Motivation and Context Error logging on Linux uses `pthread_self()` which does not return Thread ID. Fix default affinity mask generation on Windows. The following are the issues with Windows: - `GetThreadAffinityMasks()` returns bitmasks, but on other platforms it returns ordinals generated for the hardware concurrency - The maximum number of processors supported for requires a mask of 64-bits, but `size_t` type used is not always 64-bit - The masks returned per physical core may have multiple bits set, because the mask applies to several logical cores hosted by the physical core. In the past, customers complained that their threads jump from one core to another which adversely affects performance. The decision was made to stay this way. - 64-bit masks do not allow for logical processors with IDs that are outside of 0-63 range.
Author
Parents
Loading