| 16550 | } |
| 16551 | |
| 16552 | static void clear_numa_thread_affinity(void) { |
| 16553 | if (!ggml_is_numa()) { |
| 16554 | return; |
| 16555 | } |
| 16556 | |
| 16557 | size_t setsize = CPU_ALLOC_SIZE(g_state.numa.total_cpus); |
| 16558 | |
| 16559 | cpu_set_t * cpus = CPU_ALLOC(g_state.numa.total_cpus); |
| 16560 | CPU_ZERO_S(setsize, cpus); |
| 16561 | for (unsigned i = 0; i < g_state.numa.total_cpus; ++i) { |
| 16562 | CPU_SET_S(i, setsize, cpus); |
| 16563 | } |
| 16564 | |
| 16565 | int rv = pthread_setaffinity_np(pthread_self(), setsize, cpus); |
| 16566 | if (rv) { |
| 16567 | fprintf(stderr, "warning: pthread_setaffinity_np() failed: %s\n", |
| 16568 | strerror(rv)); |
| 16569 | } |
| 16570 | |
| 16571 | CPU_FREE(cpus); |
| 16572 | } |
| 16573 | #else |
| 16574 | // TODO: Windows etc. |
| 16575 | // (the linux implementation may also work on BSD, someone should test) |
no test coverage detected