OpenMathLib / OpenMathLib/OpenBLAS
Inquiry and Suggestions Regarding OpenBLAS Code Flow with OpenMP
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 7.6k
- Fork
- 1.7k
- Merge medio
- 1g 3h
- PR unite (30g)
- 42
Descrizione
Hello,
I've been delving into the OpenBLAS codebase, specifically focusing on the gemm_driver function in level3_thread.c with the #USE_OPENMP=1 flag enabled. I've come across a section in the code where a lock is used in the Pthreads and Win32 backend before initializing and assigning the blasqueue. The lock is released only after the exec_blas call is completed.
My current understanding is :
- In the case of Pthreads The thread pool is initialized (POSIX), and when a BLAS call is made, the thread pool is utilized to execute it, after which the threads go back to sleep. The use of locks ensures that only one exec_blas call can be executed at a time.
- If I use a thread pool with
No_of_threads < nthreads(number of queue partitions) defined in level3_thread.c, I encounter a deadlock within the inner_threads function. - There seems to be significant busy-waiting (NOP) inside the inner_thread function call for thread synchronization.
I have a few questions and want to seek suggestions from the community:
-
I noticed that OpenMP locking mechanisms like omp_set_lock are not used, and instead, busy-waiting is implemented inside the exec_blas function in blas_server_omp.c using max_parallel_number. Could you please provide insights into this choice?
-
The inner_thread function appears to encounter deadlock when used with fewer threads. I tested this in OpenMP by creating a parallel region inside exec_blas in line 437 - blas_server_omp.c with a fixed number of threads less than nthreads. Could you shed some light on the reasons behind this behavior?
-
Considering the busy-waiting in the code, have there been considerations for putting threads to sleep or employing other synchronization methods to enhance efficiency?
I would appreciate clarification on these points.
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
Inizia tracciando gemm_driver in driver/level3/level3_thread.c ed exec_blas e inner_thread in driver/others/blas_server_omp.c. Riproduci il deadlock segnalato con meno thread OpenMP delle partizioni della coda, quindi confronta i percorsi di locking e busy-waiting. Il lavoro sarà completato quando saranno disponibili una spiegazione confermata e una modifica alla sincronizzazione chiaramente circoscritta oppure un esito di documentazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- hpc, performance
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 20/100