Исходный код СУБД 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
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
// This file contains platform-agnostic device discovery implementation.
 
#include "core/platform/device_discovery.h"
 
#include <sstream>
 
#include "core/common/cpuid_info.h"
#include "core/common/logging/logging.h"
 
namespace onnxruntime {
 
const std::unordered_set<OrtHardwareDevice>& DeviceDiscovery::GetDevices() {
  // assumption: devices don't change. we assume the machine must be shutdown to change cpu/gpu/npu devices.
  // technically someone could disable/enable a device in a running OS. we choose not to add complexity to support
  // that scenario.
  static std::unordered_set<OrtHardwareDevice> devices = []() {
    auto discovered_devices = DiscoverDevicesForPlatform();
 
    // log discovered devices
    for (const auto& ortdevice : discovered_devices) {
      std::ostringstream oss;
      oss << "Discovered OrtHardwareDevice {vendor_id:0x" << std::hex << ortdevice.vendor_id
          << ", device_id:0x" << ortdevice.device_id
          << ", vendor:" << ortdevice.vendor
          << ", type:" << std::dec << static_cast<int>(ortdevice.type)
          << ", metadata: [";
      for (auto& [key, value] : ortdevice.metadata.Entries()) {
        oss << key << "=" << value << ", ";
      }
      oss << "]}";
      LOGS_DEFAULT(INFO) << oss.str();
    }
 
    return discovered_devices;
  }();
 
  return devices;
}
 
OrtHardwareDevice DeviceDiscovery::GetCpuDeviceFromCPUIDInfo() {
  const auto& cpuid_info = CPUIDInfo::GetCPUIDInfo();
 
  OrtHardwareDevice cpu_device{};
  cpu_device.vendor = cpuid_info.GetCPUVendor();
  cpu_device.vendor_id = cpuid_info.GetCPUVendorId();
  cpu_device.device_id = 0;
  cpu_device.type = OrtHardwareDeviceType_CPU;
 
  return cpu_device;
}
 
}  // namespace onnxruntime