Skip to main content

Module peer_copy

Module peer_copy 

Source
Expand description

Peer-to-peer (P2P) memory copy operations for multi-GPU workloads.

This module provides functions to check, enable, and disable peer access between CUDA devices, as well as copy data between device buffers on different GPUs.

Peer access enables direct GPU-to-GPU memory transfers over PCIe or NVLink without staging through host memory, significantly improving transfer bandwidth in multi-GPU configurations.

§Example

use oxicuda_driver::device::Device;
use oxicuda_memory::peer_copy;

oxicuda_driver::init()?;
let dev0 = Device::get(0)?;
let dev1 = Device::get(1)?;

if peer_copy::can_access_peer(&dev0, &dev1)? {
    peer_copy::enable_peer_access(&dev0, &dev1)?;
    // Now D2D copies between dev0 and dev1 can go over NVLink/PCIe
    // peer_copy::copy_peer(&mut dst_buf, &dev1, &src_buf, &dev0)?;
}

Functions§

can_access_peer
Checks whether device can directly access memory on peer.
copy_peer
Copies data between device buffers on different GPUs (synchronous).
copy_peer_async
Copies data between device buffers on different GPUs (asynchronous).
disable_peer_access
Disables peer access from device’s primary context to peer’s primary context.
enable_peer_access
Enables peer access from device’s primary context to peer’s primary context.