SharedGpuContext

Struct SharedGpuContext 

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

Shared GPU context for efficient resource management across all crates Now supports both single-GPU (legacy) and multi-GPU operations

Implementations§

Source§

impl SharedGpuContext

Source

pub async fn global() -> UnifiedGpuResult<&'static Self>

Get the global shared GPU context (singleton pattern) Note: This creates a new context each time for now. In production, this would be a proper singleton with atomic initialization.

Source

pub async fn with_multi_gpu() -> UnifiedGpuResult<Self>

Create a new shared GPU context with multi-GPU support

Source

pub fn device(&self) -> &Device

Get the device

Source

pub fn queue(&self) -> &Queue

Get the queue

Source

pub fn adapter_info(&self) -> &AdapterInfo

Get adapter info

Source

pub fn get_buffer( &self, size: u64, usage: BufferUsages, label: Option<&str>, ) -> Buffer

Get or create a buffer from the pool

Source

pub fn return_buffer(&self, buffer: Buffer, size: u64, usage: BufferUsages)

Return a buffer to the pool for reuse

Source

pub fn get_compute_pipeline( &self, shader_key: &str, shader_source: &str, entry_point: &str, ) -> UnifiedGpuResult<Arc<ComputePipeline>>

Get or create a compute pipeline from cache

Source

pub fn buffer_pool_stats(&self) -> BufferPoolStats

Get buffer pool statistics

Source

pub fn uptime(&self) -> Duration

Get uptime of this context

Source

pub fn get_optimal_workgroup( &self, operation: &str, data_size: usize, ) -> (u32, u32, u32)

Get optimal workgroup configuration for given operation type and data size

Source

pub fn get_workgroup_declaration( &self, operation: &str, data_size: usize, ) -> String

Generate optimized WGSL workgroup declaration for operation

Source

pub fn is_multi_gpu_enabled(&self) -> bool

Check if multi-GPU mode is enabled

Source

pub async fn device_count(&self) -> usize

Get the number of available GPU devices

Source

pub async fn get_device_info(&self) -> Vec<(DeviceId, String, String)>

Get information about all GPU devices

Source

pub async fn get_device(&self, device_id: DeviceId) -> Option<Arc<GpuDevice>>

Get a specific GPU device by ID

Source

pub async fn optimal_device_for_operation( &self, operation: &str, _data_size: usize, ) -> DeviceId

Get the optimal device for a specific operation

Source

pub async fn distribute_workload( &self, workload: Workload, ) -> UnifiedGpuResult<Vec<DeviceWorkload>>

Distribute a workload across multiple GPUs

Source

pub async fn execute_multi_gpu_workload( &self, workload_id: String, workload: Workload, ) -> UnifiedGpuResult<Vec<Vec<u8>>>

Execute a workload on multiple GPUs and aggregate results

Source

pub async fn get_gpu_utilization(&self) -> HashMap<DeviceId, f32>

Get real-time GPU utilization across all devices

Source

pub async fn get_multi_gpu_stats(&self) -> MultiGpuStats

Get performance statistics for multi-GPU operations

Source

pub async fn set_load_balancing_strategy( &self, _strategy: LoadBalancingStrategy, ) -> UnifiedGpuResult<()>

Set load balancing strategy for multi-GPU operations

Source

pub async fn add_gpu_device( &self, device: Arc<GpuDevice>, ) -> UnifiedGpuResult<()>

Add a new GPU device to the multi-GPU context (hot-plugging support)

Source

pub async fn remove_gpu_device( &self, device_id: DeviceId, ) -> UnifiedGpuResult<()>

Remove a GPU device from the multi-GPU context

Trait Implementations§

Source§

impl Clone for SharedGpuContext

Source§

fn clone(&self) -> SharedGpuContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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