Repository navigation
Description
Description
With an OpenMP-threaded OpenBLAS 0.3.31, zgemm3m never returns once OpenBLAS uses enough threads
(32 for the call below; 8 suffice for some other shapes).
The same call with zgemm returns normally. The caller is a plain serial program: there is no enclosing
OpenMP region, and all threading is OpenBLAS's own.
A single call reproduces it: zgemm3m('N','C', m=999, n=980, k=40) (attached zgemm3m_min.c).
Environment
- OpenBLAS 0.3.31 (system build),
openblas_get_config():
OpenBLAS 0.3.31 NO_AFFINITY USE_OPENMP SAPPHIRERAPIDS MAX_THREADS=128, LP64 - gcc 12.3.0 (the library and the test program), libgomp
- CPU: 2 x Intel Xeon 6952P (Granite Rapids), 192 cores, 6 NUMA domains
- Linux, Slurm, exclusive node; no
OMP_PROC_BIND/OMP_PLACESset
Reproducer
gcc -O2 zgemm3m_min.c -o zgemm3m_min -lopenblas
OMP_NUM_THREADS=8 ./zgemm3m_min # returns
OMP_NUM_THREADS=32 ./zgemm3m_min # never returns
OMP_NUM_THREADS=32 ./zgemm3m_min zgemm # same call with zgemm: returns
| OMP_NUM_THREADS | 1 | 2 | 4 | 8 | 32 | 32, with zgemm |
|---|---|---|---|---|---|---|
| result | returns | returns | returns | returns | hangs (killed after 20 s) | returns |
We first saw this in ZQUATEV (https://github.com/qsimulate-open/zquatev), which makes many zgemm3m calls
with small k. A second program (zgemm3m_hang.c) replays that application's 786 calls per pass, with a
watchdog that reports the first call that does not return:
| OMP_NUM_THREADS | zgemm3m | first call that hangs |
|---|---|---|
| 1 | OK (2358 calls, 5.9 s) | — |
| 8 | hang | ('N','C', m=240, n=240, k=60, lda=240, ldb=240, ldc=1000) |
| 32 | hang | ('N','C', m=999, n=980, k=40, lda=999, ldb=999, ldc=1000) (the very first call) |
| 64 | hang | same as 32 |
| 192 (capped to 128) | hang | ('N','T', m=200, n=200, k=20, lda=200, ldb=200, ldc=1000) |
32, with zgemm |
OK (2358 calls, 0.43 s) | — |
So it is not limited to one shape or transpose combination.
Backtraces (32 threads)
The calling thread, from zgemm3m_min (the original application gives the same stack):
#0 0x0000154a6e118fc7 in exec_blas () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#1 0x0000154a6e03a2e0 in gemm_driver () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#2 0x0000154a6e118afe in exec_threads () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#3 0x0000154a6e118e2d in exec_blas._omp_fn () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#4 0x0000154a6d6fe756 in GOMP_parallel (fn=0x154a6e118dc0 <exec_blas._omp_fn>, data=0x7ffd46369a00, num_threads=32, flags=0) at ../../../libgomp/parallel.c:178
#5 0x0000154a6e119085 in exec_blas () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#6 0x0000154a6e1170bb in gemm_thread_n () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#7 0x0000154a6e03a430 in zgemm3m_thread_nc () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#8 0x0000154a6de086bb in zgemm3m_ () from /softs/x86/openblas/lp64/gcc12.3//lib/libopenblas.so.0
#9 0x0000000000401288 in main ()
Top frames of all 32 threads: 2 are in exec_blas (the calling thread and one other), 30 wait in libgomp:
2 #0 exec_blas () from libopenblas.so.0
30 #0 futex_wait (val=0, addr=<optimized out>) at ../../../libgomp/config/linux/x86/futex.h:97
Full stack of the waiting threads (they have finished their part of the region and wait at its closing barrier):
#0 futex_wait (val=0, addr=<optimized out>) at ../../../libgomp/config/linux/x86/futex.h:97
#1 do_wait (val=0, addr=<optimized out>) at ../../../libgomp/config/linux/wait.h:67
#2 gomp_team_barrier_wait_end (bar=<optimized out>, state=0) at ../../../libgomp/config/linux/bar.c:112
#3 gomp_team_barrier_wait_final (bar=bar@entry=0x8a5ac0) at ../../../libgomp/config/linux/bar.c:136
#4 gomp_thread_start (xdata=<optimized out>) at ../../../libgomp/team.c:130
#5 start_thread () from /lib64/libc.so.6
#6 clone3 () from /lib64/libc.so.6
So zgemm3m_thread_nc goes through gemm_thread_n → exec_blas, which opens an OpenMP parallel region.
Inside it, gemm_driver calls exec_blas again (a nested call) in two of the threads, and these inner calls
never return, while the other 30 threads wait at the barrier. zgemm does not take this nested path.
Workaround: use zgemm instead of zgemm3m.
Questions: is this known or fixed after 0.3.31? Is zgemm3m with USE_OPENMP=1 expected to work?
Activity
martin-frbg commentedon Dec 3, 2026
Unfortunately still reproducible with the current develop branch despite a number of fixes that went in since 0.3.31, and it isn't immediately obvious to me where the crucial difference to the (apparently) well behaved zgemm lies.