OpenMathLib / OpenMathLib/OpenBLAS
It seems impossible to pin the threads
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 7.6k
- Fork
- 1.7k
- Merge medio
- 1g 3h
- PR unite (30g)
- 42
Descrizione
I have tried many methods to pin OpenBLAS threads (for microbenchmark purpose), but none of the implied methods work. I have tried every combination of:
NO_AFFINITY=1orNO_AFFINITY=0OPENBLAS_NUM_THREADSGOTOBLAS_MAIN_FREE,OPENBLAS_MAIN_FREEopenblas_set_num_threadsbefore any call, right before set affinity, and after set affinity.openblas_setaffinitywithcpuset_tthat are known to be correct on other microbenchmarks.- Whether I pin the main thread or not.
No matter what I do, OpenBLAS uses more threads than I allow it, except in the one case of setting OPENBLAS_NUM_THREADS. It seems like it just automatically increases the amount of threads to use all hyperthreads on the physical cores, sometimes more.
How exactly does the OpenBlas thread affinity work? Am I supposed to set NO_AFFINITY to 1 or 0? Does openblas_set_num_threads have any effects in run time?
Here's my config:
OpenBLAS 0.3.30 NO_AFFINITY HASWELL MAX_THREADS=28
This is how I pin the threads (using hwloc):
for (int i = 0; i < threads; ++i) {
int core = i;
int ht = pin_offset;
hwloc_obj_t core_obj = hwloc_get_obj_by_type(topo, HWLOC_OBJ_CORE, core);
if (!core_obj) {
fprintf(stderr, "Failed to get core\n");
exit(1);
}
hwloc_obj_t ht_obj = hwloc_get_obj_below_by_type(topo, HWLOC_OBJ_CORE,
core, HWLOC_OBJ_PU, ht);
if (!ht_obj) {
fprintf(stderr, "Failed to get thread\n");
exit(1);
}
fprintf(stderr, "Logical core [%d:%d] is physical [%d:%d]\n", core, ht,
core_obj->os_index, ht_obj->os_index);
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
hwloc_cpuset_to_glibc_sched_affinity(topo, ht_obj->cpuset, &cpu_set,
sizeof(cpu_set));
if (openblas_setaffinity(i, sizeof(cpu_set_t), &cpu_set)) {
perror("openblas_setaffinity()");
exit(1);
}
}
Is this a bug? A misuse? I have no idea.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Iniziare riproducendo la segnalazione con OpenBLAS 0.3.30 e la configurazione hwloc mostrata, concentrandosi su openblas_setaffinity e openblas_set_num_threads. Verificare come interagiscono NO_AFFINITY, OPENBLAS_NUM_THREADS e le chiamate di affinità nella configurazione segnalata. Il lavoro è completo quando si determina se il comportamento è dovuto a un uso improprio o a un bug e si documenta il comportamento previsto dell’affinità dei thread, oppure si identifica un difetto riproducibile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- performance
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 35/100