Reuse exactly-sized free blocks in the custom GPU allocator (#1225) - #1369
Merged
biochem-fan merged 1 commit intoSep 16, 2026
Merged
Conversation
…em#1225) _getFirstSuitedFree() skipped every free block whose size was equal to the requested size, so an exact fit was never returned. Three consequences: - the "curAlloc->size == size" branch in alloc() is unreachable, even though it is written to handle precisely that case; - a request the pool can satisfy exactly still fails, and alloc() aborts with ERRGPUCAOOM after exhausting its retry loop; - a freed block is never reused by a request of the same size, so the pool fragments under the common free-then-reallocate pattern. Requests are rounded up to alignmentSize before the search, which makes exact fits common rather than rare. The HIP port carries an identical copy of the function, so both are changed. Reported by @fengxiaoshuai.
Member
|
Thank you very much. I merged this into the |
Contributor
Author
|
@biochem-fan hey, quick one, is there any CUDA related work coming up in the repo? wanted to see if there's something in that area I could jump in on. |
Member
|
@arcusbuilds we have already did a big refactoring of the GPU code path but it is still being tested internally and not public yet. |
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.
Fixes #1225, reported by @fengxiaoshuai.
_getFirstSuitedFree()skips a free block whose size is exactly the requested size:That makes the
curAlloc->size == sizebranch inalloc()unreachable, and a request the pool can satisfy exactly instead aborts withCRITICAL(ERRGPUCAOOM). It also stops a freed block from being reused by a request of the same size, which fragments the pool. Since requests are rounded up toalignmentSizefirst, exact fits are common.Changed
<=to<. The HIP port has an identical copy of the function, so both are updated.Not compiled against CUDA/HIP here (the build workflow is CPU-only, so it does not cover these headers) — checked by running the free-list logic standalone with the CUDA calls stubbed out.