| 1 | // SPDX-License-Identifier: GPL-3.0-or-latercxx . . $ `<file>/src/core/info/amd/gpuinfouniqueid.cpp`/ |
| 2 | // Copyright 2022 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "gpuinfouniqueid.h"cxx . . $ `<file>/src/core/info/amd/gpuinfouniqueid.h`/ |
| 5 | |
| 6 | #include "common/fileutils.h"cxx . . $ `<file>/src/common/fileutils.h`/ |
| 7 | #include "core/info/infoproviderregistry.h"cxx . . $ `<file>/src/core/info/infoproviderregistry.h`/ |
| 8 | #include <algorithm> |
| 9 | #include <cctype> |
| 10 | #include <utility> |
| 11 | |
| 12 | namespace AMDcxx . . $ AMD/ { |
| 13 | class GPUInfoUniqueIDDataSourcecxx . . $ AMD/GPUInfoUniqueIDDataSource# |
| 14 | : public IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const> |
| 15 | { |
| 16 | public: |
| 17 | stdcxx . . $ std/::stringcxx . . $ std/string# sourcecxx . . $ AMD/GPUInfoUniqueIDDataSource#source(219584694fe2b248).() const override |
| 18 | { |
| 19 | return "unique_id"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 20 | } |
| 21 | |
| 22 | bool readcxx . . $ AMD/GPUInfoUniqueIDDataSource#read(6aed87d900484a21).(stdcxx . . $ std/::stringcxx . . $ std/string# &data, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const &path) override |
| 23 | { |
| 24 | auto const filePath = path /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). sourcecxx . . $ std/filesystem/__cxx11/path#path(2f6c7066048c5333).(); |
| 25 | if (Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::isFilePathValidcxx . . $ Utils/File/isFilePathValid(c53a6ef3278968b1).(filePath)) { |
| 26 | auto const lines = Utilscxx . . $ Utils/::Filecxx . . $ Utils/File/::readFileLinescxx . . $ Utils/File/readFileLines(951e54d16e2206f).(filePath); |
| 27 | if (!lines.emptycxx . . $ std/vector#empty(3482b152b9333168).()) { |
| 28 | data =cxx . . $ std/__cxx11/basic_string#`operator=`(c0b47be1fddc0e75). lines.frontcxx . . $ std/vector#front(af0004c3ce7cab93).(); |
| 29 | return true; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return false; |
| 34 | } |
| 35 | }; |
| 36 | } // namespace AMD |
| 37 | |
| 38 | AMDcxx . . $ AMD/::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#GPUInfoUniqueID(50e9a1d442764874).( |
| 39 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<IDataSourcecxx . . $ IDataSource#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# const>> |
| 40 | &&dataSource) noexcept |
| 41 | : dataSource_cxx . . $ AMD/GPUInfoUniqueID#dataSource_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(dataSource)) |
| 42 | { |
| 43 | } |
| 44 | |
| 45 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> |
| 46 | AMDcxx . . $ AMD/::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#::provideInfocxx . . $ AMD/GPUInfoUniqueID#provideInfo(5b65f7e996e13d80).(Vendorcxx . . $ Vendor# vendor, int, IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &path, |
| 47 | IHWIDTranslatorcxx . . $ IHWIDTranslator# const &) const |
| 48 | { |
| 49 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#>> infocxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 50 | |
| 51 | if (vendor == Vendorcxx . . $ Vendor#::AMDcxx . . $ Vendor#AMD.) { |
| 52 | stdcxx . . $ std/::stringcxx . . $ std/string# datacxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 53 | if (dataSource_cxx . . $ AMD/GPUInfoUniqueID#dataSource_.->cxx . . $ std/unique_ptr#`operator->`(ea7391e9eeeaf20e).readcxx . . $ IDataSource#read(ad81cd1bcc32f58b).(data, path.syscxx . . $ IGPUInfo#Path#sys.)) { |
| 54 | stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(data.cbegincxx . . $ std/__cxx11/basic_string#cbegin(a865d278ca20c908).(), data.cendcxx . . $ std/__cxx11/basic_string#cend(a865d278ca20c908).(), data.begincxx . . $ std/__cxx11/basic_string#begin(fd29ebd65481b919).(), ::toupper); |
| 55 | info.emplace_backcxx . . $ std/vector#emplace_back(a1bcdfdabc3a37df).(IGPUInfocxx . . $ IGPUInfo#::Keyscxx . . $ IGPUInfo#Keys#::uniqueIDcxx . . $ IGPUInfo#Keys#uniqueID., stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(data)); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return infocxx . . $ std/vector#vector(6f559d22b039ccdb).; |
| 60 | } |
| 61 | |
| 62 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::stringcxx . . $ std/string#> |
| 63 | AMDcxx . . $ AMD/::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#::provideCapabilitiescxx . . $ AMD/GPUInfoUniqueID#provideCapabilities(da28437f5803dad2).(Vendorcxx . . $ Vendor#, int, |
| 64 | IGPUInfocxx . . $ IGPUInfo#::Pathcxx . . $ IGPUInfo#Path# const &) const |
| 65 | { |
| 66 | return {cxx . . $ std/vector#vector(49f6e7a06ebc5aa8).}; |
| 67 | } |
| 68 | |
| 69 | bool AMDcxx . . $ AMD/::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#::registered_cxx . . $ AMD/GPUInfoUniqueID#registered_. = |
| 70 | InfoProviderRegistrycxx . . $ InfoProviderRegistry#::addcxx . . $ InfoProviderRegistry#add(2c04d579dc484cde).(stdcxx . . $ std/unique_ptr#unique_ptr(8bcafd3b0b660df8).::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<AMDcxx . . $ AMD/::GPUInfoUniqueIDcxx . . $ AMD/GPUInfoUniqueID#>( |
| 71 | stdcxx . . $ std/::make_uniquecxx . . $ std/make_unique(5cd499e8540a10bb).<GPUInfoUniqueIDDataSourcecxx . . $ AMD/GPUInfoUniqueIDDataSource#>())); |