Debian Codegraph @

src/core/components/gpu.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/components/gpu.cpp`/
2 // Copyright 2019 Juan Palacios <[email protected]>
3
4 #include "gpu.h"cxx . . $ `<file>/src/core/components/gpu.h`/
5
6 #include "controls/icontrol.h"cxx . . $ `<file>/src/core/components/controls/icontrol.h`/
7 #include "core/info/igpuinfo.h"cxx . . $ `<file>/src/core/info/igpuinfo.h`/
8 #include "sensors/isensor.h"cxx . . $ `<file>/src/core/components/sensors/isensor.h`/
9 #include <utility>
10
11 GPUcxx . . $ GPU#::GPUcxx . . $ GPU#GPU(3288d85259378b97).(stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IGPUInfocxx . . $ IGPUInfo#> &&info,
12 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IControlcxx . . $ IControl#>> &&controls,
13 stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ISensorcxx . . $ ISensor#>> &&sensors) noexcept
14 : id_cxx . . $ GPU#id_.(IGPUcxx . . $ IGPU#::ItemIDcxx . . $ IGPU#ItemID.)
15 , info_cxx . . $ GPU#info_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(info))
16 , controls_cxx . . $ GPU#controls_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(controls))
17 , sensors_cxx . . $ GPU#sensors_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(sensors))
18 {
19 key_cxx . . $ GPU#key_. =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). "GPU" +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(info_cxx . . $ GPU#info_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).indexcxx . . $ IGPUInfo#index(455f465bc33b4cdf).());
20 }
21
22 bool GPUcxx . . $ GPU#::activecxx . . $ GPU#active(50ce9a9e25b4a850).() const
23 {
24 return active_cxx . . $ GPU#active_.;
25 }
26
27 void GPUcxx . . $ GPU#::activatecxx . . $ GPU#activate(b45ddcbc8423892c).(bool active)
28 {
29 active_cxx . . $ GPU#active_. = active;
30 }
31
32 stdcxx . . $ std/::stringcxx . . $ std/string# const &GPUcxx . . $ GPU#::keycxx . . $ GPU#key(f4fff0029955a25f).() const
33 {
34 return key_cxx . . $ GPU#key_.;
35 }
36
37 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>>>
38 GPUcxx . . $ GPU#::componentInfocxx . . $ GPU#componentInfo(e6b143d762ee67dc).() const
39 {
40 stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>>> infocxx . . $ std/pair#pair(44d48473e6bc55c4).;
41
42 auto name(info_cxx . . $ GPU#info_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).infocxx . . $ IGPUInfo#info(3654cd48a63d288).(IGPUInfocxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).::Keyscxx . . $ IGPUInfo#Keys#::subdeviceNamecxx . . $ IGPUInfo#Keys#subdeviceName.));
43 if (!name.emptycxx . . $ std/__cxx11/basic_string#empty(3482b152b9333168).())
44 name.appendcxx . . $ std/__cxx11/basic_string#append(978ca1133b5f6e74).("\n");
45 name.appendcxx . . $ std/__cxx11/basic_string#append(978ca1133b5f6e74).("[GPU ").appendcxx . . $ std/__cxx11/basic_string#append(c0b47be1fddc0e75).(stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(3d81e17e7a87eecc).(info_cxx . . $ GPU#info_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).indexcxx . . $ IGPUInfo#index(455f465bc33b4cdf).())).appendcxx . . $ std/__cxx11/basic_string#append(978ca1133b5f6e74).("]");
46 info.firstcxx . . $ std/pair#first. =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). name;
47
48 auto infoKeys = info_cxx . . $ GPU#info_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).keyscxx . . $ IGPUInfo#keys(491c255a7e496038).();
49 for (auto &infoKey : infoKeys)
50 info.secondcxx . . $ std/pair#second..emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(infoKey, info_cxx . . $ GPU#info_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).infocxx . . $ IGPUInfo#info(3654cd48a63d288).(infoKey));
51
52 return infocxx . . $ std/pair#pair(59816e23a2f1b31c).;
53 }
54
55 void GPUcxx . . $ GPU#::initcxx . . $ GPU#init(49f6e7a06ebc5aa8).()
56 {
57 for (auto &control : controls_cxx . . $ GPU#controls_.)
58 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).initcxx . . $ IControl#init(49f6e7a06ebc5aa8).();
59 }
60
61 void GPUcxx . . $ GPU#::preInitcxx . . $ GPU#preInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
62 {
63 for (auto &control : controls_cxx . . $ GPU#controls_.)
64 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).preInitcxx . . $ IControl#preInit(151e9138769f295e).(ctlCmds);
65 }
66
67 void GPUcxx . . $ GPU#::postInitcxx . . $ GPU#postInit(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
68 {
69 for (auto &control : controls_cxx . . $ GPU#controls_.)
70 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).postInitcxx . . $ IControl#postInit(151e9138769f295e).(ctlCmds);
71 }
72
73 void GPUcxx . . $ GPU#::synccxx . . $ GPU#sync(151e9138769f295e).(ICommandQueuecxx . . $ ICommandQueue# &ctlCmds)
74 {
75 if (active_cxx . . $ GPU#active_.) {
76 // NOTE clean and sync commands generation cannot be interleaved.
77 // Interleaving them could cause conflicts between clean and sync
78 // commands of different controls, leading to an incorrect hardware
79 // state.
80 for (auto &control : controls_cxx . . $ GPU#controls_.)
81 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).cleancxx . . $ IControl#clean(151e9138769f295e).(ctlCmds);
82 for (auto &control : controls_cxx . . $ GPU#controls_.)
83 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).synccxx . . $ IControl#sync(151e9138769f295e).(ctlCmds);
84 }
85 }
86
87 void GPUcxx . . $ GPU#::updateSensorscxx . . $ GPU#updateSensors(b9a76d75a3ae6a25).(
88 stdcxx . . $ std/::unordered_mapcxx . . $ std/unordered_map#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::unordered_setcxx . . $ std/unordered_set#<stdcxx . . $ std/::stringcxx . . $ std/string#>> const &ignored)
89 {
90 for (auto &sensor : sensors_cxx . . $ GPU#sensors_.) {
91 if (ignored.countcxx . . $ std/unordered_map#count(b71ff106d381144b).(key_cxx . . $ GPU#key_.) > 0 && ignored.atcxx . . $ std/unordered_map#at(7589f80bac630479).(key_cxx . . $ GPU#key_.).countcxx . . $ std/unordered_set#count(2f4fc31398af827b).(sensor->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).IDcxx . . $ Item#ID(f4fff0029955a25f).()) > 0)
92 continue; // skip ignored sensors
93
94 sensor->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).updatecxx . . $ ISensor#update(49f6e7a06ebc5aa8).();
95 }
96 }
97
98 IGPUInfocxx . . $ IGPUInfo# const &GPUcxx . . $ GPU#::infocxx . . $ GPU#info(a7011a1aeb899f22).() const
99 {
100 return *cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).info_cxx . . $ GPU#info_.;
101 }
102
103 stdcxx . . $ std/::stringcxx . . $ std/string# const &GPUcxx . . $ GPU#::IDcxx . . $ GPU#ID(f4fff0029955a25f).() const
104 {
105 return id_cxx . . $ GPU#id_.;
106 }
107
108 void GPUcxx . . $ GPU#::importWithcxx . . $ GPU#importWith(94eddebf9440278).(Importablecxx . . $ Importable#::Importercxx . . $ Importable#Importer# &i)
109 {
110 auto importer = i.provideImportercxx . . $ Importable#Importer#provideImporter(c13a3bcac0db4745).(*this);
111 if (importer.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) {
112 auto &gpuImporter = dynamic_cast<IGPUcxx . . $ IGPU#::Importercxx . . $ ISysComponent#Importer# &>(importer->cxx . . $ std/optional#`operator->`(258ee1c9e0a18a5c).getcxx . . $ std/reference_wrapper#get(d426bc7b625886b7).());
113
114 activatecxx . . $ GPU#activate(b45ddcbc8423892c).(gpuImporter.provideActivecxx . . $ ISysComponent#Importer#provideActive(50ce9a9e25b4a850).());
115
116 for (auto &control : controls_cxx . . $ GPU#controls_.)
117 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).importWithcxx . . $ Importable#importWith(94eddebf9440278).(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).importer);
118 }
119 }
120
121 void GPUcxx . . $ GPU#::exportWithcxx . . $ GPU#exportWith(5b5c94ff60635419).(Exportablecxx . . $ Exportable#::Exportercxx . . $ Exportable#Exporter# &e) const
122 {
123 auto exporter = e.provideExportercxx . . $ Exportable#Exporter#provideExporter(3acccbde2694e33a).(*this);
124 if (exporter.has_valuecxx . . $ std/optional#has_value(3482b152b9333168).()) {
125 auto &gpuExporter = dynamic_cast<IGPUcxx . . $ IGPU#::Exportercxx . . $ IGPU#Exporter# &>(exporter->cxx . . $ std/optional#`operator->`(258ee1c9e0a18a5c).getcxx . . $ std/reference_wrapper#get(d426bc7b625886b7).());
126
127 gpuExporter.takeActivecxx . . $ ISysComponent#Exporter#takeActive(b45ddcbc8423892c).(activecxx . . $ GPU#active(50ce9a9e25b4a850).());
128 gpuExporter.takeInfocxx . . $ IGPU#Exporter#takeInfo(d732786494c3d26b).(infocxx . . $ GPU#info(a7011a1aeb899f22).());
129
130 for (auto const &sensor : sensors_cxx . . $ GPU#sensors_.)
131 gpuExporter.takeSensorcxx . . $ IGPU#Exporter#takeSensor(73745a8c6f82d10e).(*cxx . . $ std/unique_ptr#`operator*`(2fbe4a4c783c152d).sensor);
132
133 for (auto const &control : controls_cxx . . $ GPU#controls_.)
134 control->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).exportWithcxx . . $ Exportable#exportWith(5b5c94ff60635419).(*cxx . . $ std/optional#`operator*`(47e1a15210ec6306).exporter);
135 }
136 }