[CPU] Removed socket id=-1 workaround on macOS (#18779)

This commit is contained in:
Sun Xiaoxia 2023-08-11 06:38:21 +00:00 committed by GitHub
parent 2ed5e50bd1
commit 0ed1749ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -133,9 +133,7 @@ struct CPUStreamsExecutor::Impl {
const int concurrency,
const int core_type,
const int numa_node_id) {
_numaNodeId = (_impl->_usedNumaNodes.size() == 1 && _impl->_usedNumaNodes.at(0) == -1)
? -1 // macOS
: std::max(0, numa_node_id);
_numaNodeId = std::max(0, numa_node_id);
_socketId = get_socket_by_numa_node(_numaNodeId);
if (stream_type == STREAM_WITHOUT_PARAM) {
_taskArena.reset(new custom::task_arena{concurrency});

View File

@ -247,7 +247,7 @@ int get_num_numa_nodes() {
return cpu_info()._numa_nodes;
}
int get_num_sockets() {
return -1;
return cpu_info()._sockets;
}
void reserve_available_cpus(const std::vector<std::vector<int>> streams_info_table,
std::vector<std::vector<int>>& stream_processors,
@ -255,6 +255,12 @@ void reserve_available_cpus(const std::vector<std::vector<int>> streams_info_tab
void set_cpu_used(const std::vector<int>& cpu_ids, const int used) {}
int get_socket_by_numa_node(int numa_node_id) {
CPU& cpu = cpu_info();
for (size_t i = 0; i < cpu._proc_type_table.size(); i++) {
if (cpu._proc_type_table[i][PROC_NUMA_NODE_ID] == numa_node_id) {
return cpu._proc_type_table[i][PROC_SOCKET_ID];
}
}
return -1;
};

View File

@ -176,9 +176,7 @@ ExecNetwork::GraphGuard::Lock ExecNetwork::GetGraph() const {
{
std::lock_guard<std::mutex> lock{*_mutex.get()};
// disable weights caching if graph was created only once
// "socketId != -1" is the WA for MacOS, will remove later
auto weightsCache =
(_cfg.streamExecutorConfig._streams != 1 && socketId != -1) ? _socketWeights[socketId] : nullptr;
auto weightsCache = _cfg.streamExecutorConfig._streams != 1 ? _socketWeights[socketId] : nullptr;
auto isQuantizedFlag =
(_cfg.lpTransformsMode == Config::On) &&