bind core

This commit is contained in:
yefeng 2022-01-24 14:34:25 +08:00
parent 2aac7f0105
commit 633cb21740
3 changed files with 13 additions and 0 deletions

View File

@ -278,6 +278,11 @@ int CoreAffinity::InitHardwareCoreInfo() {
std::vector<int> CoreAffinity::GetCoreId(size_t thread_num, BindMode bind_mode) {
std::vector<int> bind_id;
#ifdef SERVER_INFERENCE
if (bind_mode == Power_NoBind) {
return bind_id;
}
#endif
#ifdef _WIN32
return bind_id;
#elif defined(BIND_CORE)

View File

@ -20,6 +20,9 @@
#include <vector>
#include <thread>
#ifdef SERVER_INFERENCE
#define BIND_CORE
#endif
#ifdef __ANDROID__
#define BIND_CORE
#include <sched.h>

View File

@ -61,6 +61,11 @@ void Worker::InitWorkerMask(const std::vector<int> &core_list, size_t workers_si
static uint32_t windows_core_index = 0;
core_id_ = windows_core_index++;
#elif defined(BIND_CORE)
#ifdef SERVER_INFERENCE
if (core_list.empty()) {
return;
}
#endif
cpu_set_t mask;
CPU_ZERO(&mask);
if (core_list.size() > 0) {