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
impl GpuExecutor
Sourcepub fn new() -> Option<Self>
pub fn new() -> Option<Self>
Discovers and initialises the default GPU adapter and device.
Returns None if no compatible GPU hardware backend is available.
Sourcepub fn execute_batch(
&mut self,
shader_src: &str,
n_rows: usize,
vars_cols: &[&[f64]],
out: &mut [f64],
) -> Result<(), String>
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()oncreate_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_onencounters an error when polling the device.bytemuck::cast_slicefails (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§
impl Freeze for GpuExecutor
impl !RefUnwindSafe for GpuExecutor
impl Send for GpuExecutor
impl Sync for GpuExecutor
impl Unpin for GpuExecutor
impl UnsafeUnpin for GpuExecutor
impl !UnwindSafe for GpuExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more