![]() |
cuLite v0.3.1
A lite CUDA C++ Interface
|
Memory management and allocation strategies for GPU computing. More...
Functions | |
| alloc_t | culite::detect_allocation_type (const void *ptr) |
| Detects the allocation type of a given memory pointer. | |
| void * | culite::device_alloc (std::size_t size) |
| Allocates memory on the device. | |
| void | culite::device_free (void *ptr) noexcept |
| Frees a block of memory on the device. | |
| template<typename T> | |
| T * | culite::device_alloc_t (std::size_t n) |
| Allocates typed memory on the device. | |
| void * | culite::pinned_alloc (std::size_t size) |
| Allocates page-locked (pinned) host memory. | |
| void | culite::pinned_free (void *ptr) noexcept |
| Frees a block of pinned host memory. | |
| template<typename T> | |
| T * | culite::pinned_alloc_t (std::size_t n) |
| Allocates typed pinned host memory. | |
| void | culite::auto_free (void *ptr) |
| Automatically detects and frees memory based on allocation type. | |
Memory management and allocation strategies for GPU computing.
Allocators handle the lifecycle of memory on the device. This module provides specialized routines for standard device allocation, unified memory (managed) access, and pinned host memory to optimize data transfer throughput between the CPU and GPU.
Classes:
| alloc_t culite::detect_allocation_type | ( | const void * | ptr | ) |
Detects the allocation type of a given memory pointer.
This function queries the CUDA runtime to determine the allocation type of the provided pointer. It identifies whether the memory is allocated on the device, pinned on the host, managed (unified memory), or unregistered (unknown origin).
| [in] | ptr | Pointer to the memory whose allocation type is to be detected. |
| void * culite::device_alloc | ( | std::size_t | size | ) |
Allocates memory on the device.
This function reserves a block of memory of the specified size on the underlying device.
| [in] | size | The number of bytes to allocate. |
nullptr if the allocation fails.
|
noexcept |
Frees a block of memory on the device.
This function releases the memory previously allocated by device_alloc. If ptr is nullptr, no action is performed.
| [in] | ptr | Pointer to the device memory to be freed. |
noexcept and is guaranteed not to throw exceptions during the deallocation process. | T * culite::device_alloc_t | ( | std::size_t | n | ) |
Allocates typed memory on the device.
This function reserves a block of memory for n elements of type T on the underlying device.
| T | The type of elements to allocate. |
| [in] | n | The number of elements to allocate. |
nullptr if the allocation fails. | void * culite::pinned_alloc | ( | std::size_t | size | ) |
Allocates page-locked (pinned) host memory.
Reserves a block of host memory that is page-locked and accessible to the device.
| [in] | size | The number of bytes to allocate. |
nullptr if the allocation fails.
|
noexcept |
Frees a block of pinned host memory.
Releases the memory previously allocated by pinned_alloc. If ptr is nullptr, no action is performed.
| [in] | ptr | Pointer to the pinned host memory to be freed. |
noexcept and is guaranteed not to throw exceptions during the deallocation process. | T * culite::pinned_alloc_t | ( | std::size_t | n | ) |
Allocates typed pinned host memory.
This function reserves a block of host memory for n elements of type T that is page-locked and accessible to the device.
| T | The type of elements to allocate. |
| [in] | n | The number of elements to allocate. |
nullptr if the allocation fails. | void culite::auto_free | ( | void * | ptr | ) |
Automatically detects and frees memory based on allocation type.
This function detects the allocation type of the given pointer (device memory, pinned host memory, or managed memory) and automatically calls the appropriate deallocation function. If ptr is nullptr or if the allocation type is unregistered (unknown origin), no action is performed.
| [in] | ptr | Pointer to the memory to be freed. |