Skip to content

Commit 30473b6

Browse files
authored
add openblas_getaffinity()
1 parent 8668571 commit 30473b6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

driver/others/blas_server.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,20 @@ int openblas_setaffinity(int thread_idx, size_t cpusetsize, cpu_set_t* cpu_set)
352352

353353
return pthread_setaffinity_np(thread, cpusetsize, cpu_set);
354354
}
355+
int openblas_getaffinity(int thread_idx, size_t cpusetsize, cpu_set_t* cpu_set) {
356+
const int active_threads = openblas_get_num_threads();
357+
358+
if (thread_idx < 0 || thread_idx >= active_threads) {
359+
errno = EINVAL;
360+
return -1;
361+
}
362+
363+
pthread_t thread = (thread_idx == active_threads - 1)
364+
? pthread_self()
365+
: blas_threads[thread_idx];
366+
367+
return pthread_getaffinity_np(thread, cpusetsize, cpu_set);
368+
}
355369
#endif
356370

357371
static void* blas_thread_server(void *arg){

0 commit comments

Comments
 (0)