blob: d8f01a9066710fdee41e8a479b11a385cd3d9bc7 [file] [log] [blame]
Pablo Tello7fad9b12018-03-14 17:55:27 +00001/*
Georgios Pinitase8291ac2020-02-26 09:58:13 +00002 * Copyright (c) 2018-2020 ARM Limited.
Pablo Tello7fad9b12018-03-14 17:55:27 +00003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/runtime/CPUUtils.h"
25
26#include "arm_compute/core/CPP/CPPTypes.h"
27#include "arm_compute/core/Error.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000028#include "support/StringSupport.h"
Pablo Tello7fad9b12018-03-14 17:55:27 +000029
Matthew Bentham758b5ba2020-03-05 23:37:48 +000030#include <algorithm>
Pablo Tello7fad9b12018-03-14 17:55:27 +000031#include <array>
32#include <cstdlib>
33#include <cstring>
Pablo Tello7fad9b12018-03-14 17:55:27 +000034#include <fstream>
35#include <map>
Pablo Tello7fad9b12018-03-14 17:55:27 +000036
37#ifndef BARE_METAL
Michalis Spyrou8e5174c2018-12-04 11:43:23 +000038/* C++ std::regex takes up a lot of space in the standalone builds */
39#include <regex.h>
Pablo Tello7fad9b12018-03-14 17:55:27 +000040#include <thread>
41#endif /* BARE_METAL */
42
43#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
44#include <sys/auxv.h>
45
46/* Get HWCAP bits from asm/hwcap.h */
47#include <asm/hwcap.h>
48#endif /* !BARE_METAL */
49
50/* Make sure the bits we care about are defined, just in case asm/hwcap.h is
51 * out of date (or for bare metal mode) */
52#ifndef HWCAP_ASIMDHP
Michalis Spyroubcfd09a2019-05-01 13:03:59 +010053#define HWCAP_ASIMDHP (1 << 10) // NOLINT
54#endif /* HWCAP_ASIMDHP */
Pablo Tello7fad9b12018-03-14 17:55:27 +000055
56#ifndef HWCAP_CPUID
Michalis Spyroubcfd09a2019-05-01 13:03:59 +010057#define HWCAP_CPUID (1 << 11) // NOLINT
58#endif /* HWCAP_CPUID */
Pablo Tello7fad9b12018-03-14 17:55:27 +000059
60#ifndef HWCAP_ASIMDDP
Michalis Spyroubcfd09a2019-05-01 13:03:59 +010061#define HWCAP_ASIMDDP (1 << 20) // NOLINT
62#endif /* HWCAP_ASIMDDP */
Pablo Tello7fad9b12018-03-14 17:55:27 +000063
64namespace
65{
66using namespace arm_compute;
67
68#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
Pablo Tello7fad9b12018-03-14 17:55:27 +000069
Anthony Barbier3efb3752018-07-20 15:30:46 +010070bool model_supports_dot(CPUModel model)
71{
72 switch(model)
73 {
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +010074 case CPUModel::GENERIC_FP16_DOT:
Anthony Barbier3efb3752018-07-20 15:30:46 +010075 case CPUModel::A55r1:
Anthony Barbier3efb3752018-07-20 15:30:46 +010076 return true;
77 default:
78 return false;
79 }
80}
81
82bool model_supports_fp16(CPUModel model)
83{
84 switch(model)
85 {
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +010086 case CPUModel::GENERIC_FP16:
87 case CPUModel::GENERIC_FP16_DOT:
Anthony Barbier3efb3752018-07-20 15:30:46 +010088 case CPUModel::A55r1:
Anthony Barbier3efb3752018-07-20 15:30:46 +010089 return true;
90 default:
91 return false;
92 }
93}
Georgios Pinitas18960692018-12-21 18:18:46 +000094
Pablo Tello7fad9b12018-03-14 17:55:27 +000095/* Convert an MIDR register value to a CPUModel enum value. */
96CPUModel midr_to_model(const unsigned int midr)
97{
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +010098 CPUModel model = CPUModel::GENERIC;
Pablo Tello7fad9b12018-03-14 17:55:27 +000099
100 // Unpack variant and CPU ID
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100101 const int implementer = (midr >> 24) & 0xFF;
102 const int variant = (midr >> 20) & 0xF;
103 const int cpunum = (midr >> 4) & 0xFFF;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000104
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100105 if(implementer == 0x41) // Arm CPUs
Pablo Tello7fad9b12018-03-14 17:55:27 +0000106 {
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100107 // Only CPUs we have code paths for are detected. All other CPUs can be safely classed as "GENERIC"
108 switch(cpunum)
109 {
110 case 0xd03: // A53
111 case 0xd04: // A35
112 model = CPUModel::A53;
113 break;
114 case 0xd05: // A55
115 if(variant != 0)
116 {
117 model = CPUModel::A55r1;
118 }
119 else
120 {
121 model = CPUModel::A55r0;
122 }
123 break;
124 case 0xd0a: // A75
125 if(variant != 0)
126 {
127 model = CPUModel::GENERIC_FP16_DOT;
128 }
129 else
130 {
131 model = CPUModel::GENERIC_FP16;
132 }
133 break;
134 case 0xd0b: // A76
Isabella Gottardibe2de402018-11-21 15:23:49 +0000135 case 0xd06:
136 case 0xd0c:
137 case 0xd0d:
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100138 model = CPUModel::GENERIC_FP16_DOT;
139 break;
140 default:
141 model = CPUModel::GENERIC;
142 break;
143 }
Pablo Tello7fad9b12018-03-14 17:55:27 +0000144 }
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100145 else if(implementer == 0x48)
Georgios Pinitas18960692018-12-21 18:18:46 +0000146 {
147 // Only CPUs we have code paths for are detected. All other CPUs can be safely classed as "GENERIC"
148 switch(cpunum)
149 {
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100150 case 0xd40: // A76
Georgios Pinitas18960692018-12-21 18:18:46 +0000151 model = CPUModel::GENERIC_FP16_DOT;
152 break;
153 default:
154 model = CPUModel::GENERIC;
155 break;
156 }
157 }
Pablo Tello7fad9b12018-03-14 17:55:27 +0000158
159 return model;
160}
161
Anthony Barbier3efb3752018-07-20 15:30:46 +0100162void populate_models_cpuid(std::vector<CPUModel> &cpusv)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000163{
164 // If the CPUID capability is present, MIDR information is provided in /sys. Use that to populate the CPU model table.
165 uint32_t i = 0;
166 for(auto &c : cpusv)
167 {
168 std::stringstream str;
169 str << "/sys/devices/system/cpu/cpu" << i++ << "/regs/identification/midr_el1";
170 std::ifstream file;
171 file.open(str.str(), std::ios::in);
172 if(file.is_open())
173 {
174 std::string line;
175 if(bool(getline(file, line)))
176 {
Georgios Pinitas9c2ec7e2018-11-12 17:07:18 +0000177 const uint32_t midr = support::cpp11::stoul(line, nullptr, support::cpp11::NumericBase::BASE_16);
178 c = midr_to_model(midr & 0xffffffff);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000179 }
180 }
181 }
182}
183
Anthony Barbier3efb3752018-07-20 15:30:46 +0100184void populate_models_cpuinfo(std::vector<CPUModel> &cpusv)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000185{
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000186 regex_t proc_regex;
187 regex_t imp_regex;
188 regex_t var_regex;
189 regex_t part_regex;
190 regex_t rev_regex;
191
192 memset(&proc_regex, 0, sizeof(regex_t));
193 memset(&imp_regex, 0, sizeof(regex_t));
194 memset(&var_regex, 0, sizeof(regex_t));
195 memset(&part_regex, 0, sizeof(regex_t));
196 memset(&rev_regex, 0, sizeof(regex_t));
197
198 int ret_status = 0;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000199 // If "long-form" cpuinfo is present, parse that to populate models.
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000200 ret_status |= regcomp(&proc_regex, R"(^processor.*([[:digit:]]+)$)", REG_EXTENDED);
201 ret_status |= regcomp(&imp_regex, R"(^CPU implementer.*0x(..)$)", REG_EXTENDED);
202 ret_status |= regcomp(&var_regex, R"(^CPU variant.*0x(.)$)", REG_EXTENDED);
203 ret_status |= regcomp(&part_regex, R"(^CPU part.*0x(...)$)", REG_EXTENDED);
204 ret_status |= regcomp(&rev_regex, R"(^CPU revision.*([[:digit:]]+)$)", REG_EXTENDED);
205 ARM_COMPUTE_UNUSED(ret_status);
206 ARM_COMPUTE_ERROR_ON_MSG(ret_status != 0, "Regex compilation failed.");
Pablo Tello7fad9b12018-03-14 17:55:27 +0000207
208 std::ifstream file;
209 file.open("/proc/cpuinfo", std::ios::in);
210
211 if(file.is_open())
212 {
213 std::string line;
214 int midr = 0;
215 int curcpu = -1;
216
217 while(bool(getline(file, line)))
218 {
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100219 std::array<regmatch_t, 2> match;
220 ret_status = regexec(&proc_regex, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000221 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000222 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000223 std::string id = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
Pablo Tello65f99822018-05-24 11:40:15 +0100224 int newcpu = support::cpp11::stoi(id, nullptr);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000225
226 if(curcpu >= 0 && midr == 0)
227 {
228 // Matched a new CPU ID without any description of the previous one - looks like old format.
229 return;
230 }
231
232 if(curcpu >= 0)
233 {
Anthony Barbier3efb3752018-07-20 15:30:46 +0100234 cpusv[curcpu] = midr_to_model(midr);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000235 }
236
237 midr = 0;
238 curcpu = newcpu;
239
240 continue;
241 }
242
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100243 ret_status = regexec(&imp_regex, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000244 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000245 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000246 std::string subexp = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
247 int impv = support::cpp11::stoi(subexp, nullptr, support::cpp11::NumericBase::BASE_16);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000248 midr |= (impv << 24);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000249
Pablo Tello7fad9b12018-03-14 17:55:27 +0000250 continue;
251 }
252
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100253 ret_status = regexec(&var_regex, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000254 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000255 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000256 std::string subexp = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
257 int varv = support::cpp11::stoi(subexp, nullptr, support::cpp11::NumericBase::BASE_16);
Anthony Barbier3efb3752018-07-20 15:30:46 +0100258 midr |= (varv << 20);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000259
Pablo Tello7fad9b12018-03-14 17:55:27 +0000260 continue;
261 }
262
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100263 ret_status = regexec(&part_regex, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000264 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000265 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000266 std::string subexp = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
267 int partv = support::cpp11::stoi(subexp, nullptr, support::cpp11::NumericBase::BASE_16);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000268 midr |= (partv << 4);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000269
Pablo Tello7fad9b12018-03-14 17:55:27 +0000270 continue;
271 }
272
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100273 ret_status = regexec(&rev_regex, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000274 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000275 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000276 std::string subexp = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
277 int regv = support::cpp11::stoi(subexp, nullptr);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000278 midr |= (regv);
279 midr |= (0xf << 16);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000280
Pablo Tello7fad9b12018-03-14 17:55:27 +0000281 continue;
282 }
283 }
284
285 if(curcpu >= 0)
286 {
Anthony Barbier3efb3752018-07-20 15:30:46 +0100287 cpusv[curcpu] = midr_to_model(midr);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000288 }
289 }
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000290
291 // Free allocated memory
292 regfree(&proc_regex);
293 regfree(&imp_regex);
294 regfree(&var_regex);
295 regfree(&part_regex);
296 regfree(&rev_regex);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000297}
298
299int get_max_cpus()
300{
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100301 int max_cpus = 1;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000302 std::ifstream CPUspresent;
303 CPUspresent.open("/sys/devices/system/cpu/present", std::ios::in);
304 bool success = false;
305
306 if(CPUspresent.is_open())
307 {
308 std::string line;
309
310 if(bool(getline(CPUspresent, line)))
311 {
312 /* The content of this file is a list of ranges or single values, e.g.
313 * 0-5, or 1-3,5,7 or similar. As we are interested in the
314 * max valid ID, we just need to find the last valid
315 * delimiter ('-' or ',') and parse the integer immediately after that.
316 */
317 auto startfrom = line.begin();
318
319 for(auto i = line.begin(); i < line.end(); ++i)
320 {
321 if(*i == '-' || *i == ',')
322 {
323 startfrom = i + 1;
324 }
325 }
326
327 line.erase(line.begin(), startfrom);
328
Pablo Tello65f99822018-05-24 11:40:15 +0100329 max_cpus = support::cpp11::stoi(line, nullptr) + 1;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000330 success = true;
331 }
332 }
333
334 // Return std::thread::hardware_concurrency() as a fallback.
335 if(!success)
336 {
337 max_cpus = std::thread::hardware_concurrency();
338 }
Pablo Tello7fad9b12018-03-14 17:55:27 +0000339 return max_cpus;
340}
341#endif /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
342
343} // namespace
344
345namespace arm_compute
346{
347void get_cpu_configuration(CPUInfo &cpuinfo)
348{
349#if !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__))
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100350 bool cpuid = false;
351 bool hwcaps_fp16_support = false;
352 bool hwcaps_dot_support = false;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000353
354 const uint32_t hwcaps = getauxval(AT_HWCAP);
355
356 if((hwcaps & HWCAP_CPUID) != 0)
357 {
358 cpuid = true;
359 }
360
361 if((hwcaps & HWCAP_ASIMDHP) != 0)
362 {
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100363 hwcaps_fp16_support = true;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000364 }
365
Pablo Tellodf3b5bb2018-10-09 10:51:51 +0100366#if defined(__aarch64__)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000367 if((hwcaps & HWCAP_ASIMDDP) != 0)
368 {
Anthony Barbier5a3ee4f2018-07-24 11:24:17 +0100369 hwcaps_dot_support = true;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000370 }
Pablo Tellodf3b5bb2018-10-09 10:51:51 +0100371#endif /* defined(__aarch64__) */
Pablo Tello7fad9b12018-03-14 17:55:27 +0000372
Pablo Tello7fad9b12018-03-14 17:55:27 +0000373 const unsigned int max_cpus = get_max_cpus();
374 cpuinfo.set_cpu_num(max_cpus);
Anthony Barbier3efb3752018-07-20 15:30:46 +0100375 std::vector<CPUModel> percpu(max_cpus, CPUModel::GENERIC);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000376 if(cpuid)
377 {
378 populate_models_cpuid(percpu);
379 }
380 else
381 {
382 populate_models_cpuinfo(percpu);
383 }
384 int j(0);
Georgios Pinitasecae3a12018-10-09 15:13:12 +0100385 // Update dot product and FP16 support if one of the CPUs support these features
386 // We assume that the system does not have mixed architectures
387 bool one_supports_dot = false;
388 bool one_supports_fp16 = false;
Pablo Tello7fad9b12018-03-14 17:55:27 +0000389 for(const auto &v : percpu)
390 {
Georgios Pinitas9c2ec7e2018-11-12 17:07:18 +0000391 one_supports_dot = one_supports_dot || model_supports_dot(v);
392 one_supports_fp16 = one_supports_fp16 || model_supports_fp16(v);
Anthony Barbier3efb3752018-07-20 15:30:46 +0100393 cpuinfo.set_cpu_model(j++, v);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000394 }
Georgios Pinitasecae3a12018-10-09 15:13:12 +0100395 cpuinfo.set_dotprod(one_supports_dot || hwcaps_dot_support);
396 cpuinfo.set_fp16(one_supports_fp16 || hwcaps_fp16_support);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000397#else /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
398 ARM_COMPUTE_UNUSED(cpuinfo);
399#endif /* !defined(BARE_METAL) && (defined(__arm__) || defined(__aarch64__)) */
400}
401
402unsigned int get_threads_hint()
403{
404 unsigned int num_threads_hint = 1;
405
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000406#if !defined(BARE_METAL)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000407 std::map<std::string, unsigned int> cpu_part_occurrence_map;
408
409 // CPU part regex
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000410 regex_t cpu_part_rgx;
411 memset(&cpu_part_rgx, 0, sizeof(regex_t));
Georgios Pinitasde6dbfe2018-12-24 15:02:55 +0000412 int ret_status = regcomp(&cpu_part_rgx, R"(.*CPU part.+/?\:[[:space:]]+([[:alnum:]]+).*)", REG_EXTENDED);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000413 ARM_COMPUTE_UNUSED(ret_status);
414 ARM_COMPUTE_ERROR_ON_MSG(ret_status != 0, "Regex compilation failed.");
Pablo Tello7fad9b12018-03-14 17:55:27 +0000415
416 // Read cpuinfo and get occurrence of each core
417 std::ifstream cpuinfo;
418 cpuinfo.open("/proc/cpuinfo", std::ios::in);
419 if(cpuinfo.is_open())
420 {
421 std::string line;
422 while(bool(getline(cpuinfo, line)))
423 {
Michalis Spyroubcfd09a2019-05-01 13:03:59 +0100424 std::array<regmatch_t, 2> match;
425 ret_status = regexec(&cpu_part_rgx, line.c_str(), 2, match.data(), 0);
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000426 if(ret_status == 0)
Pablo Tello7fad9b12018-03-14 17:55:27 +0000427 {
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000428 std::string cpu_part = line.substr(match[1].rm_so, (match[1].rm_eo - match[1].rm_so));
Pablo Tello7fad9b12018-03-14 17:55:27 +0000429 if(cpu_part_occurrence_map.find(cpu_part) != cpu_part_occurrence_map.end())
430 {
431 cpu_part_occurrence_map[cpu_part]++;
432 }
433 else
434 {
435 cpu_part_occurrence_map[cpu_part] = 1;
436 }
437 }
438 }
439 }
Michalis Spyrou8e5174c2018-12-04 11:43:23 +0000440 regfree(&cpu_part_rgx);
Pablo Tello7fad9b12018-03-14 17:55:27 +0000441
442 // Get min number of threads
443 auto min_common_cores = std::min_element(cpu_part_occurrence_map.begin(), cpu_part_occurrence_map.end(),
444 [](const std::pair<std::string, unsigned int> &p1, const std::pair<std::string, unsigned int> &p2)
445 {
446 return p1.second < p2.second;
447 });
448
449 // Set thread hint
450 num_threads_hint = cpu_part_occurrence_map.empty() ? std::thread::hardware_concurrency() : min_common_cores->second;
Georgios Pinitase8291ac2020-02-26 09:58:13 +0000451#endif /* !defined(BARE_METAL) */
Pablo Tello7fad9b12018-03-14 17:55:27 +0000452
453 return num_threads_hint;
454}
455
456} // namespace arm_compute