Skip to main content

vectorized_copy

Function vectorized_copy 

Source
pub unsafe fn vectorized_copy(
    src_ptrs: *mut *mut c_void,
    dst_ptrs: *mut *mut c_void,
    copy_size_bytes: usize,
    num_pairs: i32,
    stream: cudaStream_t,
) -> cudaError_t
Expand description

Launch vectorized copy between arbitrary device-visible pointer pairs.

This kernel automatically selects optimal vectorization (4/8/16 bytes) based on pointer alignment. It is useful for copying between non-contiguous memory regions where each pair has the same copy size.

Both source and destination pointers may refer to any device-visible memory, including device allocations (cudaMalloc) and pinned host memory (cudaMallocHost / cudaHostAlloc). CUDA unified addressing resolves the actual location at runtime.

§Arguments

  • src_ptrs - Device-accessible pointer to array of source pointers (each pointing to device-visible memory)
  • dst_ptrs - Device-accessible pointer to array of destination pointers (each pointing to device-visible memory)
  • copy_size_bytes - Size of each copy in bytes (same for all pairs)
  • num_pairs - Number of pointer pairs to copy
  • stream - CUDA stream for async execution

§Safety

  • All pointers in the src/dst arrays must be valid device-visible pointers (device memory or pinned host memory)
  • Each pointer must have at least copy_size_bytes bytes accessible
  • The pointer arrays themselves must be in device memory with at least num_pairs entries
  • stream must be a valid CUDA stream handle