Experimental reservation aware resource adapter and reservation - #174
Open
nirandaperera wants to merge 6 commits into
Open
Experimental reservation aware resource adapter and reservation#174nirandaperera wants to merge 6 commits into
nirandaperera wants to merge 6 commits into
Conversation
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
Signed-off-by: niranda perera <niranda.perera@gmail.com>
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.
[C++]Add experimental reservation-aware memory resource adaptorRelated to rapidsai/rapidsmpf#1142
Callers could only discover that a memory budget was exhausted at allocation time, with no way to claim a slice of it up front. This adds
cucascade::memory::experimental, where you reserve bytes against a limit and then allocate through that reservation, so an over-budget request is refused atreserve()rather than failing deep inside a cudf call. Ported from rapidsmpf and extended so that a single reservation type covers device, host, and host+device memory.reserve(size, allow_overbooking)yields amemory_reservationthat charges each allocation against itsbalance()and refunds the unspent remainder once the last reference dies. Overbooking is opt-in: permitted, the full size is granted and the shortfall reported byoverbooking(); refused, a zero-sized reservation comes back and throwsrmm::out_of_memoryon first use.device_adaptor,host_adaptor, andhost_device_adaptor— forward their upstream's accessibility to every reservation they grant, so a device adaptor cannot hand out host-usable memory.memory_reservationis one type no matter where its memory lives. To hand it to cudf or RMM, project it withas_device(),as_host(), oras_host_device(); each throwscucascade::logic_errorwhen the reservation lacks that accessibility, andaccessibility()lets callers branch without exceptions.limit(),current_allocated(),total_reserved(), andavailable()expose the budget, withget_main_record()for peak and allocation-count statistics. The adaptor is itself a memory resource, so allocations made directly through it are still tracked againstavailable(), just not capped.device_adaptor adaptor{any_device_resource{rmm::mr::cuda_memory_resource{}}, 1GB}; auto res = adaptor.reserve(4MB, allow_overbooking::NO); rmm::device_buffer buf{1MB, stream, res.as_device()}; assert(res.balance() == 4MB - 1MB); auto table = cudf::groupby(..., stream, res.as_device()); // all allocations are capped against res // The adaptor is a resource too: tracked against available(), but not capped. rmm::device_buffer scratch{1ull << 20, stream, adaptor};