pub struct MappedBuffer<T: Copy> { /* private fields */ }Expand description
A host-allocated, device-mapped (zero-copy) memory buffer.
The host memory is accessible from both CPU code and GPU kernels. GPU accesses traverse the PCIe bus, making this suitable for small or infrequently-accessed data where the overhead of explicit transfers is not justified.
§Status
This type is a placeholder. The allocation method currently returns
CudaError::NotSupported.
TODO: Add cu_mem_host_alloc (with CU_MEMHOSTALLOC_DEVICEMAP) and
cu_mem_host_get_device_pointer to DriverApi.
Implementations§
Source§impl<T: Copy> MappedBuffer<T>
impl<T: Copy> MappedBuffer<T>
Sourcepub fn alloc(_n: usize) -> CudaResult<Self>
pub fn alloc(_n: usize) -> CudaResult<Self>
Allocates a zero-copy host-mapped buffer of n elements.
§Errors
Currently always returns CudaError::NotSupported because the
required driver function pointers are not yet loaded.
TODO: Implement once cu_mem_host_alloc and
cu_mem_host_get_device_pointer are available in DriverApi.
Sourcepub fn as_device_ptr(&self) -> CUdeviceptr
pub fn as_device_ptr(&self) -> CUdeviceptr
Returns the raw device pointer for use in kernel parameters.
Sourcepub fn as_host_ptr(&self) -> *const T
pub fn as_host_ptr(&self) -> *const T
Returns a raw const pointer to the host-side data.