MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / midr_from_cpuid

Function midr_from_cpuid

src/common/cpuinfo/CpuInfo.cpp:91–109  ·  view source on GitHub ↗

Extract MIDR using CPUID information that are exposed to user-space * * @param[in] max_num_cpus Maximum number of possible CPUs * * @return std::vector A list of the MIDR of each core */

Source from the content-addressed store, hash-verified

89 * @return std::vector<uint32_t> A list of the MIDR of each core
90 */
91std::vector<uint32_t> midr_from_cpuid(uint32_t max_num_cpus)
92{
93 std::vector<uint32_t> cpus;
94 for (unsigned int i = 0; i < max_num_cpus; ++i)
95 {
96 std::stringstream str;
97 str << "/sys/devices/system/cpu/cpu" << i << "/regs/identification/midr_el1";
98 std::ifstream file(str.str(), std::ios::in);
99 if (file.is_open())
100 {
101 std::string line;
102 if (bool(getline(file, line)))
103 {
104 cpus.emplace_back(support::cpp11::stoul(line, nullptr, support::cpp11::NumericBase::BASE_16));
105 }
106 }
107 }
108 return cpus;
109}
110
111/** Extract MIDR by parsing the /proc/cpuinfo meta-data
112 *

Callers 1

buildMethod · 0.85

Calls 3

stoulFunction · 0.85
strMethod · 0.80
is_openMethod · 0.45

Tested by

no test coverage detected