* Returns number of CPUs on system that are useful for math. */
| 188 | * Returns number of CPUs on system that are useful for math. |
| 189 | */ |
| 190 | int32_t cpu_get_num_math() { |
| 191 | #if defined(__x86_64__) && defined(__linux__) && !defined(__ANDROID__) |
| 192 | int n_cpu = sysconf(_SC_NPROCESSORS_ONLN); |
| 193 | if (n_cpu < 1) { |
| 194 | return cpu_get_num_physical_cores(); |
| 195 | } |
| 196 | if (is_hybrid_cpu()) { |
| 197 | cpu_set_t affinity; |
| 198 | if (!pthread_getaffinity_np(pthread_self(), sizeof(affinity), &affinity)) { |
| 199 | int result = cpu_count_math_cpus(n_cpu); |
| 200 | pthread_setaffinity_np(pthread_self(), sizeof(affinity), &affinity); |
| 201 | if (result > 0) { |
| 202 | return result; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | #endif |
| 207 | return cpu_get_num_physical_cores(); |
| 208 | } |
| 209 | |
| 210 | // Helper for setting process priority |
| 211 |
no test coverage detected