1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
14 namespace MKLDNNPlugin {
27 class CpuInfoInterface {
29 virtual ~CpuInfoInterface() {}
31 virtual const char *getFirstLine() = 0;
33 virtual const char *getNextLine() = 0;
36 class CpuInfo : public CpuInfoInterface {
42 virtual const char *getFirstLine();
44 virtual const char *getNextLine();
47 const char *fileContentBegin;
48 const char *fileContentEnd;
49 const char *currentLine;
51 void loadContentFromFile(const char *fileName);
53 void loadContent(const char *content);
55 void parseLines(char *content);
58 class CollectionInterface {
60 virtual ~CollectionInterface() {}
61 virtual unsigned getTotalNumberOfSockets() = 0;
64 class Collection : public CollectionInterface {
66 explicit Collection(CpuInfoInterface *cpuInfo);
68 virtual unsigned getTotalNumberOfSockets();
69 virtual unsigned getTotalNumberOfCpuCores();
70 virtual unsigned getNumberOfProcessors();
73 CpuInfoInterface &cpuInfo;
74 unsigned totalNumberOfSockets;
75 unsigned totalNumberOfCpuCores;
76 std::vector<Processor> processors;
77 Processor *currentProcessor;
79 Collection(const Collection &collection);
81 Collection &operator=(const Collection &collection);
85 void parseCpuInfoLine(const char *cpuInfoLine);
87 void parseValue(const char *fieldName, const char *valueString);
89 void appendNewProcessor();
91 bool beginsWith(const char *lineBuffer, const char *text) const;
93 unsigned parseInteger(const char *text) const;
95 void collectBasicCpuInformation();
97 void updateCpuInformation(const Processor &processor,
98 unsigned numberOfUniquePhysicalId);
100 #endif // #ifndef __APPLE__
102 } // namespace MKLDNNPlugin