* Returns number of CPUs on system that are useful for math. */
| 173 | * Returns number of CPUs on system that are useful for math. |
| 174 | */ |
| 175 | int32_t cpu_get_num_math() { |
| 176 | #if defined(__x86_64__) && defined(__linux__) && !defined(__ANDROID__) |
| 177 | int n_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
| 178 | if (n_cpu < 1) { |
| 179 | return cpu_get_num_physical_cores(); |
| 180 | } |
| 181 | if (is_hybrid_cpu()) { |
| 182 | cpu_set_t affinity; |
| 183 | if (!pthread_getaffinity_np(pthread_self(), sizeof(affinity), &affinity)) { |
| 184 | int result = cpu_count_math_cpus(n_cpu); |
| 185 | pthread_setaffinity_np(pthread_self(), sizeof(affinity), &affinity); |
| 186 | if (result > 0) { |
| 187 | return result; |
| 188 | } |
| 189 | } |
| 190 | } |
| 191 | #endif |
| 192 | return cpu_get_num_physical_cores(); |
| 193 | } |
| 194 | |
| 195 | // Helper for setting process priority |
| 196 |
no test coverage detected