Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "test/platform/windows/env.h"
#include <vector>
 
namespace onnxruntime {
namespace test {
 
/*
Mock cpu layout for windows
"global_processor_id" means "index" of a logical processor in the system,
"local_processor_id" refers to "index" of a logical processor in its belonging group,
the "local" here means group-local.
Unlike the definition of affinity API, the id here starts from 0, not 1.
E.g.
assume cpu_info is like:
{
{{0,1},{2,3}} // group 1 of two cores
{{0,1},{2,3}} // group 2 of two cores
}
then we will have eight logical processors with global id be like:
0,1,2,3,4,5,6,7
and local id be like:
0,1,2,3,0,1,2,3
*/
bool WindowsEnvTester::SetCpuInfo(const CpuInfo& cpu_info) {
  if (cpu_info.empty()) {
    return false;
  }
  cores_.clear();
  global_processor_info_map_.clear();
  int global_processor_id = 0;
  for (int group_id = 0; group_id < static_cast<int>(cpu_info.size()); ++group_id) {
    int local_processor_id = 0;
    for (int core_id = 0; core_id < static_cast<int>(cpu_info[group_id].size()); ++core_id) {
      onnxruntime::LogicalProcessors logical_processors;
      for (int i = 0; i < static_cast<int>(cpu_info[group_id][core_id].size()); ++i) {
        logical_processors.push_back(global_processor_id);
        global_processor_info_map_[global_processor_id] = {group_id, local_processor_id};
        local_processor_id++;
        global_processor_id++;
      }
      cores_.push_back(std::move(logical_processors));
    }
  }
  return true;
}
 
}  // namespace test
}  // namespace onnxruntime