CUB
|
A simple caching allocator for device memory allocations.
bin_growth
provided during construction. Unused device allocations within a larger bin cache are not reused for allocation requests that categorize to smaller bin sizes.bin_growth
^ min_bin
) are rounded up to (bin_growth
^ min_bin
).bin_growth
^ max_bin
) are not rounded up to the nearest bin and are simply freed when they are deallocated instead of being returned to a bin-cache.max_cached_bytes
, allocations for that device are simply freed when they are deallocated instead of being returned to their bin-cache.bin_growth
= 8min_bin
= 3max_bin
= 7max_cached_bytes
= 6MB - 1BDefinition at line 99 of file util_allocator.cuh.
Public Methods | |
CachingDeviceAllocator (unsigned int bin_growth, unsigned int min_bin, unsigned int max_bin, size_t max_cached_bytes, bool skip_cleanup=false) | |
Constructor. More... | |
CachingDeviceAllocator (bool skip_cleanup=false) | |
Default constructor. More... | |
cudaError_t | SetMaxCachedBytes (size_t max_cached_bytes) |
Sets the limit on the number bytes this allocator is allowed to cache per device. | |
cudaError_t | DeviceAllocate (void **d_ptr, size_t bytes, int device) |
Provides a suitable allocation of device memory for the given size on the specified device. | |
cudaError_t | DeviceAllocate (void **d_ptr, size_t bytes) |
Provides a suitable allocation of device memory for the given size on the current device. | |
cudaError_t | DeviceFree (void *d_ptr, int device) |
Frees a live allocation of device memory on the specified device, returning it to the allocator. | |
cudaError_t | DeviceFree (void *d_ptr) |
Frees a live allocation of device memory on the current device, returning it to the allocator. | |
cudaError_t | FreeAllCached () |
Frees all cached device allocations on all devices. | |
virtual | ~CachingDeviceAllocator () |
Destructor. | |
|
inline |
Constructor.
bin_growth | Geometric growth factor for bin-sizes |
min_bin | Minimum bin |
max_bin | Maximum bin |
max_cached_bytes | Maximum aggregate cached bytes per device |
skip_cleanup | Whether or not to skip a call to FreeAllCached() when the destructor is called. (Useful for preventing warnings when the allocator is declared at file/static/global scope: by the time the destructor is called on program exit, the CUDA runtime may have already shut down and freed all allocations.) |
Definition at line 252 of file util_allocator.cuh.
|
inline |
Default constructor.
Configured with:
bin_growth
= 8min_bin
= 3max_bin
= 7max_cached_bytes
= (bin_growth
^ max_bin
) * 3) - 1 = 6,291,455 byteswhich delineates five bin-sizes: 512B, 4KB, 32KB, 256KB, and 2MB and sets a maximum of 6,291,455 cached bytes per device
skip_cleanup | Whether or not to skip a call to FreeAllCached() when the destructor is called. (Useful for preventing warnings when the allocator is declared at file/static/global scope: by the time the destructor is called on program exit, the CUDA runtime may have already shut down and freed all allocations.) |
Definition at line 287 of file util_allocator.cuh.