mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Windows - Only set thread affinity on Server with auto affinity (#19318)
### Description Only set thread affinity on Server with auto affinity. Auto affinity = when API user does specify thread settings or affinity themselves. ### Motivation and Context On client best to let OS scheduler handle. On big (P-Core) / little (E-Core) CPU designs affinity overrides win32 Quality of Service (QoS) and has high power usage. Specifically on background workloads whose process is tagged QoS Utility (Background), this affinity setting overrides the OS scheduler that only wants to schedule on the E-Cores. Thus P-Cores waking up uses more energy than intended on client and users gets less battery life. Foreground AI workloads would be tagged QoS High and would run the ORT threads on all cores.
This commit is contained in:
parent
b84cb247e3
commit
3454f86e70
1 changed files with 10 additions and 0 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#include <versionhelpers.h>
|
||||
#endif
|
||||
#include <thread>
|
||||
#include "core/session/ort_apis.h"
|
||||
|
|
@ -98,7 +99,16 @@ CreateThreadPoolHelper(Env* env, OrtThreadPoolParams options) {
|
|||
}
|
||||
options.thread_pool_size = static_cast<int>(default_affinities.size());
|
||||
if (options.auto_set_affinity) {
|
||||
#ifdef _WIN32
|
||||
// Only set thread affinity on Server with auto affinity.
|
||||
// On client best to let OS scheduler handle.
|
||||
// On big (P-Core) / little (E-Core) CPU designs affinity overrides QoS and has high power usage
|
||||
if (IsWindowsServer()) {
|
||||
to.affinities = std::move(default_affinities);
|
||||
}
|
||||
#else
|
||||
to.affinities = std::move(default_affinities);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (options.thread_pool_size <= 1) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue