add openblas_getaffinity()

This commit is contained in:
Martin Kroeker 2022-07-27 19:15:18 +02:00 committed by GitHub
parent 8668571040
commit 30473b6a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -352,6 +352,20 @@ int openblas_setaffinity(int thread_idx, size_t cpusetsize, cpu_set_t* cpu_set)
return pthread_setaffinity_np(thread, cpusetsize, cpu_set); return pthread_setaffinity_np(thread, cpusetsize, cpu_set);
} }
int openblas_getaffinity(int thread_idx, size_t cpusetsize, cpu_set_t* cpu_set) {
const int active_threads = openblas_get_num_threads();
if (thread_idx < 0 || thread_idx >= active_threads) {
errno = EINVAL;
return -1;
}
pthread_t thread = (thread_idx == active_threads - 1)
? pthread_self()
: blas_threads[thread_idx];
return pthread_getaffinity_np(thread, cpusetsize, cpu_set);
}
#endif #endif
static void* blas_thread_server(void *arg){ static void* blas_thread_server(void *arg){