Repository navigation
Fix per-thread workspace overlap with user-supplied work[] (lwork > 0) - #1
Merged
Merged
Conversation
Port of xiaoyeli/superlu_mt#36 to the macro base file. When the caller supplies work[] (lwork > 0), each factorization thread allocates its private iwork/dwork from the TAIL of that stack in p@(pre)gstrf_WorkInit(), but p@(pre)gstrf_WorkFree() reset the whole TAIL (top2 = size) as soon as any one thread finished, releasing the work arrays of threads that were still running. A thread that started afterwards then got TAIL memory overlapping a live thread's marker[]/dense[] and overwrote them during its ifill()/@(pre)fill() initialization, producing spurious zero pivots (intermittent failures in p[cz]test_4_{10,19}_2_100000000_LA). Count the threads holding TAIL work arrays and reset the TAIL only when the last one frees its arrays. The added lines contain no precision macros, so the extracted p{s,d,c,z}memory.c match the files merged in superlu_mt exactly. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GsYX7J15S6uvtUoRMWYwi
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
Port of xiaoyeli/superlu_mt#36 (merged) to the macro base file
trunk/SRC/pxmemory.base, so the fix is not lost the next time the precision-dependent sources are regenerated.Problem
When the caller supplies
work[](lwork > 0), each factorization thread allocates its privateiwork/dworkfrom the TAIL of that stack inp@(pre)gstrf_WorkInit(). Butp@(pre)gstrf_WorkFree()reset the whole TAIL (stack.top2 = stack.size) as soon as any one thread finished, releasing the work arrays of threads still running. A thread that started afterwards then got TAIL memory overlapping a live thread'smarker[]/dense[]and overwrote them during itsifill()/@(pre)fill()initialization. The result was spurious zero pivots: the intermittent failures inp[cz]test_4_{10,19}_2_100000000_LAreported in xiaoyeli/superlu_mt#34.Fix
p@(pre)gstrf_WorkInit()counts the threads holding TAIL work arrays (nwork_users), under the existing stack lock.p@(pre)gstrf_WorkFree()resets the TAIL only when that count drops to 0.p@(pre)gstrf_SetupSpace()and the refactorization path inp@(pre)gstrf_MemInit().Verification
The
extracttool is not available in my environment, so I did not regenerate the.cfiles here. Instead I compared the added/removed lines of this diff against the diffs of all four merged files (SRC/p{s,d,c,z}memory.cin superlu_mt commit2d564a6): they are identical in every case. The changed lines contain no precision macros, so extraction will produce exactly the files already merged in superlu_mt. Stress-test results for the fix itself are in xiaoyeli/superlu_mt#36.Only
trunk/is changed, per the README. The copy underSuperLU_MT_base-branch/SRC/pxmemory.baseis left as is.🤖 Generated with Claude Code
https://claude.ai/code/session_017GsYX7J15S6uvtUoRMWYwi
Generated by Claude Code