Add VMMAllocatedMemoryResource for Virtual Memory Management APIs #972
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.
Add VMMAllocatedMemoryResource for Virtual Memory Management APIs
Summary
This PR implements a new
VMMAllocatedMemoryResource
class that provides access to CUDA's Virtual Memory Management (VMM) APIs through the cuda.core memory resource interface. This addresses the feature request for usingcuMemCreate
,cuMemMap
, and related APIs for advanced memory management scenarios. for #967Changes
Core Implementation
New
VMMAllocatedMemoryResource
class incuda/core/experimental/_memory.pyx
MemoryResource
abstract interfacecuMemCreate
,cuMemAddressReserve
,cuMemMap
,cuMemSetAccess
,cuMemUnmap
,cuMemAddressFree
,cuMemRelease
Device integration in
cuda/core/experimental/_device.py
Device.create_vmm_memory_resource()
convenience methodModule exports in
cuda/core/experimental/__init__.py
VMMAllocatedMemoryResource
to public APITesting & Examples
Comprehensive test suite in
tests/test_vmm_memory_resource.py
Working example in
examples/vmm_memory_example.py
Technical Details
Memory Management Flow
cuMemCreate
→cuMemAddressReserve
→cuMemMap
→cuMemSetAccess
cuMemUnmap
→cuMemAddressFree
→cuMemRelease
Key Features
cuMemGetAllocationGranularity
CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED
API Design
Testing
All tests pass on VMM-capable hardware:
Files Changed
cuda_core/cuda/core/experimental/_memory.pyx
- Core implementationcuda_core/cuda/core/experimental/_device.py
- Device integrationcuda_core/cuda/core/experimental/__init__.py
- Module exportscuda_core/tests/test_vmm_memory_resource.py
- Test suitecuda_core/examples/vmm_memory_example.py
- Usage example