Skip to main content

GpuExecutor

Struct GpuExecutor 

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

A high-performance WebGPU compute execution context with dynamic buffer pooling and pipeline caching.

Implementations§

Source§

impl GpuExecutor

Source

pub fn new() -> Option<Self>

Discovers and initialises the default GPU adapter and device.

Returns None if no compatible GPU hardware backend is available.

Source

pub fn execute_batch( &mut self, shader_src: &str, n_rows: usize, vars_cols: &[&[f64]], out: &mut [f64], ) -> Result<(), String>

Dispatches a high-throughput parallel compute job to the GPU using the compiled WGSL shader source.

Performs zero-allocation float array conversions at the CPU-GPU memory boundary using a pre-allocated conversion scratchpad, maintaining optimal cache locality.

§Panics

This function may panic if:

  • Internal WGPU calls fail unexpectedly (e.g., unwrap() on create_compute_pipeline).
  • A compute pipeline cannot be created.
  • A bind group cannot be created.
  • A command encoder cannot be created.
  • Submission of commands to the queue fails.
  • pollster::block_on encounters an error when polling the device.
  • bytemuck::cast_slice fails (indicating incorrect memory layout assumptions).
§Errors

Returns a String describing the error if execution fails due to:

  • Failure to fetch the compute pipeline from the cache.
  • Uninitialized output or staging buffers.
  • Staging buffer mapping fails or the GPU channel disconnects.

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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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