| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/sysmodelfactory.cpp`/ |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "sysmodelfactory.h"cxx . . $ `<file>/src/core/sysmodelfactory.h`/ |
| 5 | |
| 6 | #include "common/fileutils.h"cxx . . $ `<file>/src/common/fileutils.h`/ |
| 7 | #include "common/stringutils.h"cxx . . $ `<file>/src/common/stringutils.h`/ |
| 8 | #include "components/controls/icontrol.h"cxx . . $ `<file>/src/core/components/controls/icontrol.h`/ |
| 9 | #include "components/controls/icpucontrolprovider.h"cxx . . $ `<file>/src/core/components/controls/icpucontrolprovider.h`/ |
| 10 | #include "components/controls/igpucontrolprovider.h"cxx . . $ `<file>/src/core/components/controls/igpucontrolprovider.h`/ |
| 11 | #include "components/cpu.h"cxx . . $ `<file>/src/core/components/cpu.h`/ |
| 12 | #include "components/cpuutils.h"cxx . . $ `<file>/src/core/components/cpuutils.h`/ |
| 13 | #include "components/gpu.h"cxx . . $ `<file>/src/core/components/gpu.h`/ |
| 14 | #include "components/sensors/icpusensorprovider.h"cxx . . $ `<file>/src/core/components/sensors/icpusensorprovider.h`/ |
| 15 | #include "components/sensors/igpusensorprovider.h"cxx . . $ `<file>/src/core/components/sensors/igpusensorprovider.h`/ |
| 16 | #include "components/sensors/isensor.h"cxx . . $ `<file>/src/core/components/sensors/isensor.h`/ |
| 17 | #include "info/cpuinfo.h"cxx . . $ `<file>/src/core/info/cpuinfo.h`/ |
| 18 | #include "info/gpuinfo.h"cxx . . $ `<file>/src/core/info/gpuinfo.h`/ |
| 19 | #include "info/ihwidtranslator.h"cxx . . $ `<file>/src/core/info/ihwidtranslator.h`/ |
| 20 | #include "info/iswinfo.h"cxx . . $ `<file>/src/core/info/iswinfo.h`/ |
| 21 | #include "isyscomponent.h"cxx . . $ `<file>/src/core/isyscomponent.h`/ |
| 22 | #include "isysexplorer.h"cxx . . $ `<file>/src/core/isysexplorer.h`/ |
| 23 | #include "sysmodel.h"cxx . . $ `<file>/src/core/sysmodel.h`/ |
| 24 | #include <algorithm> |
| 25 | #include <iterator> |
| 26 | #include <memory> |
| 27 | #include <optional> |
| 28 | #include <spdlog/spdlog.h> |
| 29 | #include <string_view> |
| 30 | #include <utility> |
| 31 | |
| 32 | SysModelFactorycxx . . $ SysModelFactory#::SysModelFactorycxx . . $ SysModelFactory#SysModelFactory(8f8ae85d037b43a3).( |
| 33 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISWInfocxx . . $ ISWInfo#> &&swInfo, |
| 34 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISysExplorercxx . . $ ISysExplorer#> &&sysExplorer, |
| 35 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IHWIDTranslatorcxx . . $ IHWIDTranslator#> &&hwIDTranslator, |
| 36 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUControlProvidercxx . . $ ICPUControlProvider#> &&cpuControlProvider, |
| 37 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUSensorProvidercxx . . $ ICPUSensorProvider#> &&cpuSensorProvider, |
| 38 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUControlProvidercxx . . $ IGPUControlProvider#> &&gpuControlProvider, |
| 39 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUSensorProvidercxx . . $ IGPUSensorProvider#> &&gpuSensorProvider, |
| 40 | ICPUInfocxx . . $ ICPUInfo#::IProviderRegistrycxx . . $ ICPUInfo#IProviderRegistry# const &cpuInfoProviderRegistry, |
| 41 | IGPUInfocxx . . $ IGPUInfo#::IProviderRegistrycxx . . $ IGPUInfo#IProviderRegistry# const &gpuInfoProviderRegistry) noexcept |
| 42 | : swInfo_cxx . . $ SysModelFactory#swInfo_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(swInfo)) |
| 43 | , sysExplorer_cxx . . $ SysModelFactory#sysExplorer_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sysExplorer)) |
| 44 | , hwidTranslator_cxx . . $ SysModelFactory#hwidTranslator_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(hwIDTranslator)) |
| 45 | , cpuControlProvider_cxx . . $ SysModelFactory#cpuControlProvider_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cpuControlProvider)) |
| 46 | , cpuSensorProvider_cxx . . $ SysModelFactory#cpuSensorProvider_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cpuSensorProvider)) |
| 47 | , gpuControlProvider_cxx . . $ SysModelFactory#gpuControlProvider_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(gpuControlProvider)) |
| 48 | , gpuSensorProvider_cxx . . $ SysModelFactory#gpuSensorProvider_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(gpuSensorProvider)) |
| 49 | , cpuInfoProviderRegistry_cxx . . $ SysModelFactory#cpuInfoProviderRegistry_.(cpuInfoProviderRegistry) |
| 50 | , gpuInfoProviderRegistry_cxx . . $ SysModelFactory#gpuInfoProviderRegistry_.(gpuInfoProviderRegistry) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISysModelcxx . . $ ISysModel#> SysModelFactorycxx . . $ SysModelFactory#::buildcxx . . $ SysModelFactory#build(72b1c0099a8a0571).() const |
| 55 | { |
| 56 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISysComponentcxx . . $ ISysComponent#>> componentscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 57 | |
| 58 | auto gpuInfo = createGPUInfocxx . . $ SysModelFactory#createGPUInfo(d64a7d00860b4521).(); |
| 59 | for (auto &info : gpuInfo) |
| 60 | components.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(createGPUcxx . . $ SysModelFactory#createGPU(e6192af7732a147f).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(info), *cxx . . $ std/__shared_ptr_access#`operator*`(d426bc7b625886b7).swInfo_cxx . . $ SysModelFactory#swInfo_.)); |
| 61 | |
| 62 | auto cpuInfo = createCPUInfocxx . . $ SysModelFactory#createCPUInfo(1f3da877e0e2f132).(); |
| 63 | for (auto &info : cpuInfo) |
| 64 | components.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(createCPUcxx . . $ SysModelFactory#createCPU(790d920059012b87).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(info), *cxx . . $ std/__shared_ptr_access#`operator*`(d426bc7b625886b7).swInfo_cxx . . $ SysModelFactory#swInfo_.)); |
| 65 | |
| 66 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<SysModelcxx . . $ SysModel#>(swInfo_cxx . . $ SysModelFactory#swInfo_., stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(components)); |
| 67 | } |
| 68 | |
| 69 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUInfocxx . . $ ICPUInfo#>> SysModelFactorycxx . . $ SysModelFactory#::createCPUInfocxx . . $ SysModelFactory#createCPUInfo(1f3da877e0e2f132).() const |
| 70 | { |
| 71 | auto cpuInfo = parseCPUInfocxx . . $ SysModelFactory#parseCPUInfo(1f3da877e0e2f132).(); |
| 72 | for (auto &info : cpuInfo) |
| 73 | info->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initializecxx . . $ ICPUInfo#initialize(9f043417cf7016f2).(cpuInfoProviderRegistry_cxx . . $ SysModelFactory#cpuInfoProviderRegistry_..cpuInfoProviderscxx . . $ ICPUInfo#IProviderRegistry#cpuInfoProviders(b09f5b0ca2a1a4eb).()); |
| 74 | |
| 75 | return cpuInfocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 76 | } |
| 77 | |
| 78 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUcxx . . $ ICPU#> |
| 79 | SysModelFactorycxx . . $ SysModelFactory#::createCPUcxx . . $ SysModelFactory#createCPU(790d920059012b87).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUInfocxx . . $ ICPUInfo#> &&cpuInfo, |
| 80 | ISWInfocxx . . $ ISWInfo# const &swInfo) const |
| 81 | { |
| 82 | // create CPU controls |
| 83 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IControlcxx . . $ IControl#>> controlscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 84 | auto &cpuControlProviders = cpuControlProvider_cxx . . $ SysModelFactory#cpuControlProvider_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cpuControlProviderscxx . . $ ICPUControlProvider#cpuControlProviders(e2df3a43ac2a4489).(); |
| 85 | for (auto const &provider : cpuControlProviders) { |
| 86 | auto newControls = provider->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).provideCPUControlscxx . . $ ICPUControlProvider#IProvider#provideCPUControls(4edd12f9a0f8bda3).(*cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).cpuInfo, swInfo); |
| 87 | controls.insertcxx . . $ std/vector#insert(134ef7853f0b3ebe).(controlscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..endcxx . . $ std/vector#end(55a6de06420d4903).(), stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newControls.begincxx . . $ std/vector#begin(55a6de06420d4903).()), |
| 88 | stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newControls.endcxx . . $ std/vector#end(55a6de06420d4903).())); |
| 89 | } |
| 90 | |
| 91 | // create CPU sensors |
| 92 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISensorcxx . . $ ISensor#>> sensorscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 93 | auto &cpuSensorProviders = cpuSensorProvider_cxx . . $ SysModelFactory#cpuSensorProvider_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cpuSensorProviderscxx . . $ ICPUSensorProvider#cpuSensorProviders(879fbe2534188278).(); |
| 94 | for (auto const &provider : cpuSensorProviders) { |
| 95 | auto newSensors = provider->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).provideCPUSensorscxx . . $ ICPUSensorProvider#IProvider#provideCPUSensors(f374f74f624b1d44).(*cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).cpuInfo, swInfo); |
| 96 | sensors.insertcxx . . $ std/vector#insert(134ef7853f0b3ebe).(sensorscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..endcxx . . $ std/vector#end(55a6de06420d4903).(), stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newSensors.begincxx . . $ std/vector#begin(55a6de06420d4903).()), |
| 97 | stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newSensors.endcxx . . $ std/vector#end(55a6de06420d4903).())); |
| 98 | } |
| 99 | |
| 100 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<CPUcxx . . $ CPU#>(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(cpuInfo), stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(controls), |
| 101 | stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sensors)); |
| 102 | } |
| 103 | |
| 104 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUInfocxx . . $ IGPUInfo#>> SysModelFactorycxx . . $ SysModelFactory#::createGPUInfocxx . . $ SysModelFactory#createGPUInfo(d64a7d00860b4521).() const |
| 105 | { |
| 106 | namespace fs = stdcxx . . $ std/::filesystem; |
| 107 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUInfocxx . . $ IGPUInfo#>> gpuInfocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 108 | |
| 109 | fs::pathcxx . . $ std/filesystem/__cxx11/path# sysBasePathcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).{"/sys/class/drm"}; |
| 110 | auto deviceNames = sysExplorer_cxx . . $ SysModelFactory#sysExplorer_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).rendererscxx . . $ ISysExplorer#renderers(c1a9bfb60daa162d).(); |
| 111 | for (auto const &deviceName : deviceNames) { |
| 112 | |
| 113 | auto sysPath = sysBasePath /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). deviceNamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d). /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). "device"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).; |
| 114 | auto devPath = fscxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).::pathcxx . . $ std/filesystem/__cxx11/path#("/dev/dri").appendcxx . . $ std/filesystem/__cxx11/path#append(d30197541d75bb9a).(deviceName); |
| 115 | auto vendor = parseVendorcxx . . $ SysModelFactory#parseVendor(b599fba3e6289874).(sysBasePath /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). deviceNamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d). /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). "device/vendor"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).); |
| 116 | int const gpuIndex = computeGPUIndexcxx . . $ SysModelFactory#computeGPUIndex(22cc3a531165f6b0).(deviceName); |
| 117 | |
| 118 | auto info = stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUInfocxx . . $ GPUInfo#>(vendor, gpuIndex, |
| 119 | GPUInfocxx . . $ IGPUInfo#Path#Path(df8cb93b336b884d).::Pathcxx . . $ IGPUInfo#Path#(sysPathcxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc)., devPathcxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).)); |
| 120 | info->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initializecxx . . $ GPUInfo#initialize(c158fff4aa1693ae).(gpuInfoProviderRegistry_cxx . . $ SysModelFactory#gpuInfoProviderRegistry_..gpuInfoProviderscxx . . $ IGPUInfo#IProviderRegistry#gpuInfoProviders(65c0b6f616266a45).(), |
| 121 | *cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).hwidTranslator_cxx . . $ SysModelFactory#hwidTranslator_.); |
| 122 | gpuInfo.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(info)); |
| 123 | } |
| 124 | |
| 125 | return gpuInfocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 126 | } |
| 127 | |
| 128 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUcxx . . $ IGPU#> |
| 129 | SysModelFactorycxx . . $ SysModelFactory#::createGPUcxx . . $ SysModelFactory#createGPU(e6192af7732a147f).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUInfocxx . . $ IGPUInfo#> &&gpuInfo, |
| 130 | ISWInfocxx . . $ ISWInfo# const &swInfo) const |
| 131 | { |
| 132 | // create GPU controls |
| 133 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IControlcxx . . $ IControl#>> controlscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 134 | auto &gpuControlProviders = gpuControlProvider_cxx . . $ SysModelFactory#gpuControlProvider_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).gpuControlProviderscxx . . $ IGPUControlProvider#gpuControlProviders(b98bd2901afb7b91).(); |
| 135 | for (auto const &provider : gpuControlProviders) { |
| 136 | auto newControls = provider->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).provideGPUControlscxx . . $ IGPUControlProvider#IProvider#provideGPUControls(9f099d614da39bf5).(*cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).gpuInfo, swInfo); |
| 137 | controls.insertcxx . . $ std/vector#insert(134ef7853f0b3ebe).(controlscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..endcxx . . $ std/vector#end(55a6de06420d4903).(), stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newControls.begincxx . . $ std/vector#begin(55a6de06420d4903).()), |
| 138 | stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newControls.endcxx . . $ std/vector#end(55a6de06420d4903).())); |
| 139 | } |
| 140 | |
| 141 | // create GPU sensors |
| 142 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISensorcxx . . $ ISensor#>> sensorscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 143 | auto &gpuSensorProviders = gpuSensorProvider_cxx . . $ SysModelFactory#gpuSensorProvider_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).gpuSensorProviderscxx . . $ IGPUSensorProvider#gpuSensorProviders(c1fd289087b7aeb5).(); |
| 144 | for (auto const &provider : gpuSensorProviders) { |
| 145 | auto newSensors = provider->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).provideGPUSensorscxx . . $ IGPUSensorProvider#IProvider#provideGPUSensors(61145f351ed4bd1d).(*cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).gpuInfo, swInfo); |
| 146 | sensors.insertcxx . . $ std/vector#insert(134ef7853f0b3ebe).(sensorscxx . . $ __gnu_cxx/__normal_iterator#__normal_iterator(459a7e7b9fbe7640)..endcxx . . $ std/vector#end(55a6de06420d4903).(), stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newSensors.begincxx . . $ std/vector#begin(55a6de06420d4903).()), |
| 147 | stdcxx . . $ std/::make_move_iteratorcxx . . $ std/make_move_iterator(7b29529569bae719).(newSensors.endcxx . . $ std/vector#end(55a6de06420d4903).())); |
| 148 | } |
| 149 | |
| 150 | return stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUcxx . . $ GPU#>(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(gpuInfo), stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(controls), |
| 151 | stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sensors)); |
| 152 | } |
| 153 | |
| 154 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUInfocxx . . $ ICPUInfo#>> SysModelFactorycxx . . $ SysModelFactory#::parseCPUInfocxx . . $ SysModelFactory#parseCPUInfo(1f3da877e0e2f132).() const |
| 155 | { |
| 156 | static constexpr stdcxx . . $ std/::string_viewcxx . . $ std/string_view# cpuIdStrcxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).{"processor"}; |
| 157 | |
| 158 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const basePathcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).{"/sys/devices/system/cpu"}; |
| 159 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ICPUInfocxx . . $ ICPUInfo#>> cpuInfocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 160 | |
| 161 | int value; |
| 162 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<int> cpuIdcxx . . $ std/optional#optional(ced63f7c635d850d).; |
| 163 | |
| 164 | auto cpuInfoLines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).("/proc/cpuinfo"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).); |
| 165 | for (auto const &line : cpuInfoLines) { |
| 166 | |
| 167 | if (line.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).()) { // push collected info |
| 168 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<int> physicalIdcxx . . $ std/optional#optional(ced63f7c635d850d).; |
| 169 | stdcxx . . $ std/::optionalcxx . . $ std/optional#<int> coreIdcxx . . $ std/optional#optional(ced63f7c635d850d).; |
| 170 | |
| 171 | auto physicalIdStr = Utilscxx . . $ Utils/::CPUcxx . . $ Utils/CPU/::parseProcCpuInfocxx . . $ Utils/CPU/parseProcCpuInfo(6ce55c29d0623432).(cpuInfoLines, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cpuId, |
| 172 | "physical id"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 173 | if (physicalIdStr.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() && |
| 174 | Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::toNumbercxx . . $ Utils/String/toNumber(c75d689ebd728b7b).<int>(value, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).physicalIdStr)) |
| 175 | physicalId =cxx . . $ std/optional#`operator=`(9571cd16f437681f). valuecxx . . $ std/optional#optional(e3f0d6382bd52f24).; |
| 176 | |
| 177 | auto coreIdStr = Utilscxx . . $ Utils/::CPUcxx . . $ Utils/CPU/::parseProcCpuInfocxx . . $ Utils/CPU/parseProcCpuInfo(6ce55c29d0623432).(cpuInfoLines, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cpuId, |
| 178 | "core id"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).); |
| 179 | if (coreIdStr.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() && |
| 180 | Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::toNumbercxx . . $ Utils/String/toNumber(c75d689ebd728b7b).<int>(value, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).coreIdStr)) |
| 181 | coreId =cxx . . $ std/optional#`operator=`(9571cd16f437681f). valuecxx . . $ std/optional#optional(e3f0d6382bd52f24).; |
| 182 | |
| 183 | if (cpuId.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() && physicalId.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).() && coreId.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) { |
| 184 | stdcxx . . $ std/::stringcxx . . $ std/string# cpuDircxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).{"cpu"}; |
| 185 | cpuDir.appendcxx . . $ std/__cxx11/basic_string#append(c0b47be1fddc0e75).(stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cpuId)); |
| 186 | auto executionUnitPath = basePath /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). cpuDircxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).; |
| 187 | |
| 188 | auto infoIt = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(cpuInfo.cbegincxx . . $ std/vector#cbegin(d1e1699016b9d7e6).(), cpuInfo.cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).(), |
| 189 | [=](auto const &info) { |
| 190 | return info->physicalId() == *cxx . . $ std/optional#`operator*`(a104ceb4a760916d).physicalId; |
| 191 | }); |
| 192 | if (infoIt != cpuInfo.cendcxx . . $ std/vector#cend(d1e1699016b9d7e6).()) |
| 193 | static_cast<CPUInfocxx . . $ CPUInfo# *>(infoIt->cxx . . $ __gnu_cxx/__normal_iterator#`operator->`(65c2ec7035a77d3e).getcxx . . $ std/unique_ptr#get(ea7391e9eeeaf20e).()) |
| 194 | ->addExecutionUnitcxx . . $ CPUInfo#addExecutionUnit(8bf9f90495c34065).( |
| 195 | ICPUInfocxx . . $ ICPUInfo#ExecutionUnit#ExecutionUnit(29dc65b71c02a3d9).::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cpuId, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).coreId, executionUnitPathcxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).)); |
| 196 | else { |
| 197 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<ICPUInfocxx . . $ ICPUInfo#::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#> unitscxx . . $ std/vector#vector(9619226211e5a241).{ |
| 198 | ICPUInfocxx . . $ ICPUInfo#ExecutionUnit#ExecutionUnit(29dc65b71c02a3d9).::ExecutionUnitcxx . . $ ICPUInfo#ExecutionUnit#(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).cpuId, *cxx . . $ std/optional#`operator*`(47e1a15210ec6306).coreId, executionUnitPathcxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).)}; |
| 199 | |
| 200 | cpuInfo.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).( |
| 201 | stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<CPUInfocxx . . $ CPUInfo#>(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).physicalId, stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(units))); |
| 202 | } |
| 203 | |
| 204 | physicalId =cxx . . $ std/optional#`operator=`(f6fa8f39d0f4a155). cpuId =cxx . . $ std/optional#`operator=`(f6fa8f39d0f4a155). coreId =cxx . . $ std/optional#`operator=`(38d427c8744fed4f). stdcxx . . $ std/::nulloptcxx . . $ std/nullopt.; |
| 205 | } |
| 206 | else { |
| 207 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Cannot parse some data from /proc/cpuinfo"); |
| 208 | return {cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | auto cpuIdIt = line.findcxx . . $ std/__cxx11/basic_string#find(f84f8bea57cb23bc).(cpuIdStr); |
| 213 | if (cpuIdIt != stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) { |
| 214 | auto indexPos = line.find_first_not_ofcxx . . $ std/__cxx11/basic_string#find_first_not_of(5ed402c22c298042).("\t: ", cpuIdStr.sizecxx . . $ std/basic_string_view#size(c9b1e749b64d5edc).()); |
| 215 | if (indexPos != stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos. && |
| 216 | Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::toNumbercxx . . $ Utils/String/toNumber(c75d689ebd728b7b).<int>(value, line.substrcxx . . $ std/__cxx11/basic_string#substr(d59a03e0b0717fa0).(indexPos))) { |
| 217 | cpuId =cxx . . $ std/optional#`operator=`(9571cd16f437681f). valuecxx . . $ std/optional#optional(e3f0d6382bd52f24).; |
| 218 | continue; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | return cpuInfocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 224 | } |
| 225 | |
| 226 | int SysModelFactorycxx . . $ SysModelFactory#::computeGPUIndexcxx . . $ SysModelFactory#computeGPUIndex(22cc3a531165f6b0).(stdcxx . . $ std/::stringcxx . . $ std/string# const &deviceRenderDName) const |
| 227 | { |
| 228 | auto const indexStr = Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::cleanPrefixcxx . . $ Utils/String/cleanPrefix(203b42cd324c6c40).(deviceRenderDName, |
| 229 | "renderD"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).); |
| 230 | int index = -1; |
| 231 | if (Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::toNumbercxx . . $ Utils/String/toNumber(c75d689ebd728b7b).<int>(index, indexStr)) |
| 232 | index -= 128; |
| 233 | else |
| 234 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Cannot compute GPU index for device {}.", deviceRenderDName); |
| 235 | return index; |
| 236 | } |
| 237 | |
| 238 | Vendorcxx . . $ Vendor# SysModelFactorycxx . . $ SysModelFactory#::parseVendorcxx . . $ SysModelFactory#parseVendor(b599fba3e6289874).(stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const &vendorPath) const |
| 239 | { |
| 240 | Vendorcxx . . $ Vendor# vendor{-1}; |
| 241 | |
| 242 | auto const lines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).(vendorPath); |
| 243 | if (!lines.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 244 | int dataValue; |
| 245 | if (Utilscxx . . $ Utils/::Stringcxx . . $ Utils/String/::toNumbercxx . . $ Utils/String/toNumber(c75d689ebd728b7b).<int>(dataValue, lines.frontcxx . . $ std/vector#front(af0004c3ce7cab93).(), 16)) |
| 246 | vendor = Vendorcxx . . $ Vendor#{dataValue}; |
| 247 | else |
| 248 | SPDLOG_DEBUGcxx . . $ `<external>/13613935168682455490/spdlog.h:311:13`!("Cannot parse vendor id from file {}.", vendorPath.c_str()); |
| 249 | } |
| 250 | |
| 251 | return vendor; |
| 252 | } |