Repository navigation
Conversation
Apply the MAX(GEMM_R, GEMM_PQ + 96) - GEMM_PQ safety floor from commits 146beed and 0944e9e (OpenMathLib#5981) to getrf_single.c, getrf_parallel.c, getrf_parallel_omp.c, lauum_L_single.c, and lauum_U_single.c so targets with GEMM_R <= MAX(GEMM_P, GEMM_Q) maintain a positive workspace margin and loop stride. Clamp the Windows ARM64 medium-matrix thread count in gesv.c to num_cpu_avail(4) so 1-thread execution avoids uninitialized pool.lock access and 2-thread or 3-thread execution avoids deadlocking in GETRF_PARALLEL. Add regression tests in utest/test_kernel_regress.c.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five LAPACK drivers compute
REAL_GEMM_RasGEMM_R - GEMM_PQwithout a positive floor, and[s/d/c/z]gesvon Windows ARM64 hardcodesargs.nthreads = 4for medium matrices without querying available threads. This pull request extends the#5981REAL_GEMM_Rfloor acrossgetrfandlauumand clamps the Windows ARM64gesvthread count tonum_cpu_avail(4).Root Cause and Changes
lapack/getrf/getrf_single.c,lapack/getrf/getrf_parallel.c,lapack/getrf/getrf_parallel_omp.c,lapack/lauum/lauum_L_single.c, andlapack/lauum/lauum_U_single.cdefineREAL_GEMM_Ras(GEMM_R - GEMM_PQ)and advance blocked panel loops byREAL_GEMM_R. On targets whereGEMM_R <= MAX(GEMM_P, GEMM_Q), such asGENERICbuilds withDEFAULT_GEMM_P = DEFAULT_GEMM_Q = DEFAULT_GEMM_R = 128(REAL_GEMM_R == 0), RISC-V L2-scaledGEMM_P, or LoongArch64 smallGEMM_R, the loop step becomes zero or negative and causes an infinite loop or out-of-bounds memory access. DefiningREAL_GEMM_Ras(MAX(GEMM_R, GEMM_PQ + 96) - GEMM_PQ)matches commits146beeda5and0944e9e7cinpotrf_{L,U}_single.c.interface/lapack/gesv.csetsargs.nthreads = 4unconditionally on_WIN64 && _M_ARM64when500 < m * m <= 1000(real) or300 < m * m <= 1000(complex). Whennum_cpu_avail(4)is1(OPENBLAS_NUM_THREADS=1),blas_thread_init()leavespool.lockuninitialized on Windows andGETRF_PARALLELcrashes inEnterCriticalSection(&pool.lock). Whennum_cpu_avail(4)is2or3,GETRF_PARALLELspins indefinitely waiting for four worker threads. Queryingnum_cpu_avail(4)first and cappingargs.nthreadsat4resolves both failures.Verification
dgesv_small_thread_clamp,zgesv_small_thread_clamp(N = 25,N * N = 625, testing 1 and 2 threads), anddlauum_blockedinutest/test_kernel_regress.c.openblas_utestlocally (82/82tests passing).