Expand description
2D and 3D memory copy operations for pitched and volumetric data.
GPU memory is often allocated as “pitched” 2D arrays where each row has padding bytes to satisfy alignment requirements. The standard 1D copy functions cannot handle this row padding — they would copy the padding bytes as if they were data.
This module provides:
Memcpy2DParams— parameters for 2D (row-padded) copies.Memcpy3DParams— parameters for 3D (volumetric, doubly-padded) copies.- Copy functions for host-to-device, device-to-host, and device-to-device transfers in 2D and 3D.
§Pitch vs Width
- pitch — total bytes per row including alignment padding.
- width — bytes of actual data per row to copy.
The pitch must be >= width for both source and destination.
§Status
The CUDA driver function cuMemcpy2D_v2 is now wired through
oxicuda-driver. All 2D copy variants (DtoD, HtoD, DtoH) build a
CUDA_MEMCPY2D descriptor and
invoke the driver entry point when available. cuMemcpy3D_v2 is
not yet loaded; the 3D copy still returns CudaError::NotSupported
when a driver is present but the symbol is missing.
§Example
use oxicuda_memory::copy_2d3d::{Memcpy2DParams, copy_2d_dtod};
use oxicuda_memory::DeviceBuffer;
let params = Memcpy2DParams {
src_pitch: 512,
dst_pitch: 512,
width: 480, // 480 bytes of data per row
height: 256, // 256 rows
};
let mut dst = DeviceBuffer::<u8>::alloc(512 * 256)?;
let src = DeviceBuffer::<u8>::alloc(512 * 256)?;
copy_2d_dtod(&mut dst, &src, ¶ms)?;Structs§
- Memcpy2D
Params - Parameters for a 2D (pitched) memory copy.
- Memcpy3D
Params - Parameters for a 3D (volumetric) memory copy.
Functions§
- copy_
2d_ dtod - Copies a 2D region between two device buffers (device-to-device).
- copy_
2d_ dtoh - Copies a 2D region from a device buffer to host memory.
- copy_
2d_ htod - Copies a 2D region from host memory to a device buffer.
- copy_
3d_ dtod - Copies a 3D region between two device buffers (device-to-device).