Skip to main content

InterGpuTransfer

Struct InterGpuTransfer 

Source
pub struct InterGpuTransfer { /* private fields */ }
Expand description

Inter-GPU data transfer manager.

Maintains a per-device “last submitted buffer” slot so that gather can perform real GPU→CPU readback. After dispatching work to device i, call set_device_buffer with the result buffer and its byte-size; then gather will DMA-read every registered buffer back to the host and return the raw bytes.

Implementations§

Source§

impl InterGpuTransfer

Source

pub fn new(manager: Arc<MultiGpuManager>) -> Self

Create a new inter-GPU transfer manager.

Source

pub fn set_device_buffer( &self, device_idx: usize, buffer: Arc<Buffer>, size_bytes: u64, ) -> GpuResult<()>

Register the GPU buffer produced by a compute pass on device_idx.

The buffer must have at least BufferUsages::COPY_SRC so that gather can issue a copy-to-staging command.

§Errors

Returns GpuError::InvalidBuffer when device_idx is out of range or the internal lock is poisoned.

Source

pub async fn copy_buffer( &self, src_device: usize, dst_device: usize, data: &[u8], ) -> GpuResult<()>

Copy data between GPUs via the host (staging).

§Errors

Returns an error if transfer fails or devices are invalid.

Source

pub async fn broadcast(&self, data: &[u8]) -> GpuResult<()>

Broadcast data to all GPUs.

§Errors

Returns an error if any transfer fails.

Source

pub async fn gather(&self, dst_device: usize) -> GpuResult<Vec<Vec<u8>>>

Gather data from every source device to dst_device.

For each source device i (where i != dst_device) that has had a buffer registered via set_device_buffer, this method performs a real GPU→CPU readback:

  1. Allocates a CPU-visible staging buffer on device i.
  2. Encodes a copy_buffer_to_buffer command from the registered source buffer into the staging buffer, then submits it to the device queue.
  3. Polls the device until the submission has completed (blocking wait).
  4. Maps the staging buffer for reading, copies the data, and unmaps it.

The returned Vec<Vec<u8>> contains one entry per source device (ordered by ascending device index, skipping dst_device). Devices that have no registered buffer produce an empty Vec<u8>.

§Errors

Returns an error when:

  • dst_device >= num_devices
  • the wgpu device poll fails
  • the staging buffer cannot be mapped (e.g., the source buffer is missing COPY_SRC usage)
  • an internal mutex is poisoned
Source

pub fn gather_blocking(&self, dst_device: usize) -> GpuResult<Vec<Vec<u8>>>

Blocking variant of gather.

Wraps the async gather in pollster::block_on so that callers in synchronous contexts (e.g., tests, CLI tools) do not need an async runtime.

§Errors

Propagates any error returned by gather.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more