|
6 | 6 | * LICENSE file in the root directory of this source tree. |
7 | 7 | */ |
8 | 8 |
|
| 9 | +#include <c10/util/irange.h> |
9 | 10 | #include <executorch/extension/threadpool/cpuinfo_utils.h> |
10 | 11 |
|
11 | 12 | #include <fstream> |
@@ -84,7 +85,7 @@ bool populate_available_cpu_mids() { |
84 | 85 | cpu_midrs->resize(num_possible_cores); |
85 | 86 | const std::string kMidrFilePathPrefix = "/sys/devices/system/cpu/cpu"; |
86 | 87 | const std::string kMidrFilePathSuffix = "/regs/identification/midr_el1"; |
87 | | - for (int32_t i = 0; i < num_possible_cores; ++i) { |
| 88 | + for (const auto i : c10::irange(num_possible_cores)) { |
88 | 89 | std::string midr_file_path = |
89 | 90 | kMidrFilePathPrefix + std::to_string(i) + kMidrFilePathSuffix; |
90 | 91 | ET_LOG(Info, "Reading file %s", midr_file_path.c_str()); |
@@ -115,7 +116,7 @@ uint32_t _get_num_performant_cores() { |
115 | 116 | ET_LOG(Info, "CPU info and manual query on # of cpus dont match."); |
116 | 117 | return 0; |
117 | 118 | } |
118 | | - for (int32_t i = 0; i < cpu_midrs->size(); ++i) { |
| 119 | + for (const auto i : c10::irange(cpu_midrs->size())) { |
119 | 120 | uint32_t masked_midr = (*cpu_midrs)[i] & RIVISION_MASK; |
120 | 121 | switch (masked_midr) { |
121 | 122 | case CPUINFO_ARM_MIDR_CORTEX_A520: |
@@ -148,7 +149,7 @@ uint32_t get_num_performant_cores() { |
148 | 149 | uint32_t num_possible_cores = cpuinfo_get_processors_count(); |
149 | 150 | uint32_t num_non_performant_core = 0; |
150 | 151 | if (uarch_count > 1) { |
151 | | - for (int32_t i = 0; i < uarch_count; ++i) { |
| 152 | + for (const auto i : c10::irange(uarch_count)) { |
152 | 153 | const struct cpuinfo_uarch_info* uarch_info = cpuinfo_get_uarch(i); |
153 | 154 | if (is_non_performant_core(uarch_info)) { |
154 | 155 | num_non_performant_core += uarch_info->processor_count; |
|
0 commit comments