Class: Ignis::Memory::CudaAsyncMemoryResource
- Inherits:
-
DeviceMemoryResource
- Object
- DeviceMemoryResource
- Ignis::Memory::CudaAsyncMemoryResource
- Defined in:
- lib/nvruby/memory/cuda_async_memory_resource.rb
Overview
Stream-ordered memory resource using cudaMallocAsync/cudaFreeAsync Uses CUDA’s built-in stream-ordered allocator (CUDA 11.2+) Optimal for workloads with many allocations on the same stream
Constant Summary collapse
- MEMPOOL_ATTR_REUSE_FOLLOW_EVENT_DEPENDENCIES =
cudaMemPoolAttr enum values
0x1- MEMPOOL_ATTR_REUSE_ALLOW_OPPORTUNISTIC =
0x2- MEMPOOL_ATTR_REUSE_ALLOW_INTERNAL_DEPENDENCIES =
0x3- MEMPOOL_ATTR_RELEASE_THRESHOLD =
0x4
Constants inherited from DeviceMemoryResource
DeviceMemoryResource::ALIGNMENT
Instance Attribute Summary
Attributes inherited from DeviceMemoryResource
Instance Method Summary collapse
-
#destroy! ⇒ void
Release the memory pool.
-
#initialize(device_index: nil, initial_pool_size: 0, release_threshold: 0) ⇒ CudaAsyncMemoryResource
constructor
A new instance of CudaAsyncMemoryResource.
-
#supports_streams? ⇒ Boolean
True - supports stream-ordered allocation.
Methods inherited from DeviceMemoryResource
#allocate, #deallocate, #inspect, #is_equal?, #to_s
Constructor Details
#initialize(device_index: nil, initial_pool_size: 0, release_threshold: 0) ⇒ CudaAsyncMemoryResource
Returns a new instance of CudaAsyncMemoryResource.
20 21 22 23 24 25 26 27 |
# File 'lib/nvruby/memory/cuda_async_memory_resource.rb', line 20 def initialize(device_index: nil, initial_pool_size: 0, release_threshold: 0) super(device_index: device_index) @initial_pool_size = initial_pool_size @release_threshold = release_threshold @pool_handle = nil setup_pool! end |
Instance Method Details
#destroy! ⇒ void
This method returns an undefined value.
Release the memory pool
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nvruby/memory/cuda_async_memory_resource.rb', line 36 def destroy! return unless @pool_handle @mutex.synchronize do if @pool_handle && !@pool_handle.null? CUDA::RuntimeAPI.cudaMemPoolDestroy(@pool_handle) @pool_handle = nil end end end |
#supports_streams? ⇒ Boolean
Returns true - supports stream-ordered allocation.
30 31 32 |
# File 'lib/nvruby/memory/cuda_async_memory_resource.rb', line 30 def supports_streams? true end |