Skip to main content

Module copy_2d3d

Module copy_2d3d 

Source
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 functions cuMemcpy2D_v2 and cuMemcpy3D_v2 are not yet loaded in oxicuda-driver. The validation logic is fully functional, but actual copies return CudaError::NotSupported when a GPU driver is not available.

§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, &params)?;

Structs§

Memcpy2DParams
Parameters for a 2D (pitched) memory copy.
Memcpy3DParams
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).