Skip to main content

WgpuServer

Struct WgpuServer 

Source
pub struct WgpuServer<C: WgpuCompiler> {
    pub compilation_options: WgpuCompilationOptions,
    /* private fields */
}
Expand description

Wgpu compute server.

Fields§

§compilation_options: WgpuCompilationOptions

Implementations§

Source§

impl<C: WgpuCompiler> WgpuServer<C>

Source

pub fn load_cached_pipeline( &mut self, kernel_id: &KernelId, bindings: &KernelArguments, mode: ExecutionMode, ) -> Result<Option<Result<PipelineEntry, (u64, KernelCacheKey)>>, CompilationError>

Loads a cached kernel if present and creates the pipeline for it. Returns None if the cache isn’t enabled, Some(Ok(pipeline)) if a cache entry was found, and Some(Err(cache_key)) if the cache is enabled but doesn’t contain this kernel.

Source

pub fn create_module( &self, entrypoint_name: &str, cube_dim: CubeDim, source: ModuleSource<'_>, mode: ExecutionMode, ) -> Result<ShaderModule, CompilationError>

Source

pub fn create_pipeline( &self, entrypoint_name: &str, repr: Option<AutoRepresentationRef<'_>>, module: ShaderModule, bindings: &KernelArguments, ) -> Arc<ComputePipeline> ⓘ

Source§

impl<C: WgpuCompiler> WgpuServer<C>

Source

pub fn new( memory_properties: MemoryDeviceProperties, memory_config: MemoryConfiguration, compilation_options: WgpuCompilationOptions, device: Device, queue: Queue, tasks_max: usize, backend: Backend, timing_method: TimingMethod, utilities: ServerUtilities, ) -> Self

Create a new server.

Trait Implementations§

Source§

impl<C: Debug + WgpuCompiler> Debug for WgpuServer<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: WgpuCompiler> DeviceService for WgpuServer<C>

Source§

fn init(device_id: DeviceId) -> Self

Initializes the service. It is only called once per device.
Source§

fn utilities(&self) -> ServerUtilitiesHandle

Get the service utilities.
Source§

fn stage() -> DeviceServiceStage
where Self: Sized,

Which pipeline stage this service runs on. Read more
Source§

impl<C: WgpuCompiler> Server for WgpuServer<C>

Source§

fn sync( &mut self, handles: Vec<BufferBinding>, stream_id: StreamId, ) -> DynFut<Result<(), ServerError>>

Returns the total time of GPU work this sync completes.

Source§

fn logger(&self) -> Arc<ServerLogger> ⓘ

Retrieve the server logger.
Source§

fn utilities(&self) -> Arc<ServerUtilities> ⓘ

Retrieve the server utilities.
Source§

fn staging( &mut self, _sizes: &[usize], _stream_id: StreamId, ) -> Result<Vec<Bytes>, ServerError>

Reserves N Bytes of the provided sizes to be used as staging to load data.
Source§

fn initialize_memory( &mut self, memory: ManagedMemoryHandle, size: u64, stream_id: StreamId, )

Initializes memory on the given stream with the given size.
Source§

fn read( &mut self, descriptors: Vec<CopyDescriptor>, stream_id: StreamId, ) -> DynFut<Result<Vec<Bytes>, ServerError>>

Given bindings, returns the owned resources as bytes. Read more
Source§

fn write( &mut self, descriptors: Vec<(CopyDescriptor, Bytes)>, stream_id: StreamId, )

Writes the specified bytes into the buffers given
Source§

fn check( &mut self, handles: Vec<BufferBinding>, _stream_id: StreamId, ) -> Result<(), ServerError>

Whether the bytes the handles name can be trusted, right now and with no barrier: the claim check a read makes, without the read. Instant — enqueue-time failures only. A device fault needs sync, which drains first.
Source§

unsafe fn launch( &mut self, kernel: Box<dyn CubeKernel>, count: CubeCount, args: KernelArguments, stream_id: StreamId, launch_mode: LaunchMode, )

Executes the kernel over the given memory handles. Read more
Source§

fn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>

Flush all outstanding tasks in the server. Read more
Source§

fn start_profile( &mut self, stream_id: StreamId, ) -> Result<ProfilingToken, ServerError>

Enable collecting timestamps.
Source§

fn end_profile( &mut self, stream_id: StreamId, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>

Disable collecting timestamps.
Source§

fn abandon_profile(&mut self, stream_id: StreamId, token: ProfilingToken)

Drop the window token opened without measuring it, for a caller that will never close it with end_profile. Read more
Source§

fn memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage

Memory usage of the given stream.
Source§

fn memory_report(&mut self, stream_id: StreamId) -> MemoryReport

Structured per-pool report of the given stream’s main GPU memory: each pool’s shape, usage, and high-water marks, in allocation-routing order. The read side of a measured memory plan — see MemoryManagement::memory_report in cubecl-server.
Source§

fn stream_ids(&self) -> Vec<StreamId>

Stream ids the client should iterate to aggregate across the device. Read more
Source§

fn memory_cleanup(&mut self, stream_id: StreamId)

Ask the server to release memory that it can release.
Source§

fn allocation_mode(&mut self, mode: MemoryAllocationMode, stream_id: StreamId)

Update the memory mode of allocation in the server.
Source§

fn install_memory_pools( &mut self, config: MemoryConfiguration, stream_id: StreamId, ) -> Result<(), InstallMemoryPoolsError>

Install a new dynamic-pool layout for the device’s main GPU memory. Read more
Source§

fn graph_prepare(&mut self, stream_id: StreamId) -> Result<(), ServerError>

Prepare stream_id for an upcoming graph capture: route allocations into a stable pool and snapshot it, so every buffer allocated between here and end_capture can be pinned for the graph’s lifetime. Call this before the warmup run so the capture window reuses the slices warmup left in the pool rather than allocating its own — which a hardware-graph backend cannot do at all (a device malloc inside the capture is illegal there), and which on any backend would grow the memory a graph pins beyond what it replays against. Read more
Source§

fn begin_capture(&mut self, stream_id: StreamId) -> Result<(), ServerError>

Begin recording the launches issued on stream_id into a graph instead of executing them, so the sequence can later be replayed without paying the launch path again. Call graph_prepare and warm up first. Read more
Source§

fn end_capture(&mut self, stream_id: StreamId) -> Result<GraphId, ServerError>

Stop recording (see begin_capture), store the captured graph in the backend’s registry, and return its GraphId, ready to replay.
Source§

fn replay( &mut self, graph: GraphId, stream_id: StreamId, ) -> Result<(), ServerError>

Replay the graph identified by graph on stream_id, re-running the whole recorded launch sequence against its original buffers. A hardware graph replays as a single dispatch; a software graph re-encodes the recorded dispatches, which is still far cheaper than the launch path but stays O(n) in recorded launches. Read more
Source§

fn graph_destroy(&mut self, graph: GraphId, stream_id: StreamId)

Release the graph identified by graph, destroying whatever it recorded and unpinning the buffers it retained. Replay returns at enqueue time, so the backend must guarantee no in-flight replay can still read those buffers once they return to the pool — by syncing stream_id where nothing weaker will do (CUDA, HIP), or by relying on the queue ordering that already places a submitted replay ahead of any later write (wgpu). A no-op by default and for an unknown id.
Source§

impl<C: WgpuCompiler> ServerCommunication for WgpuServer<C>

Source§

fn sync_collective(&mut self, stream_id: StreamId) -> Result<(), ServerError>

Ensure that all queued collective operations have been executed. Read more
Source§

fn comm_init(&mut self, device_ids: Vec<DeviceId>) -> Result<(), ServerError>

Initialize the communication between the devices in device_ids. Read more
Source§

fn all_reduce( &mut self, src: BufferBinding, dst: BufferBinding, dtype: ElemType, stream_id: StreamId, op: ReduceOperation, device_ids: Vec<DeviceId>, ) -> Result<(), ServerError>

Performs an all_reduce operation on the input data and writes it to the output buffer. see https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/usage/collectives.html#allreduce Read more
Source§

fn send( &mut self, desc: CopyDescriptor, dtype: ElemType, stream_id: StreamId, device_id_dst: DeviceId, ) -> Result<(), ServerError>

Sends data from this server to a destination server. Read more
Source§

fn recv( &mut self, handle: Handle, dtype: ElemType, stream_id: StreamId, device_id_src: DeviceId, ) -> Result<(), ServerError>

Receive data from another server. Read more
Source§

impl<C: WgpuCompiler> ServerStorage for WgpuServer<C>

Source§

type Storage = WgpuStorage

The storage type defines how data is stored and accessed.
Source§

fn get_resource( &mut self, binding: BufferBinding, stream_id: StreamId, ) -> Result<ManagedResource<WgpuResource>, ServerError>

Given a resource handle, returns the storage resource. Read more
Source§

impl<C: WgpuCompiler> WriteScoped for WgpuServer<C>

Source§

type Streams = SchedulerMultiStream<ScheduledWgpuBackend>

The multi-stream driver the server keeps.
Source§

fn write_streams(&mut self) -> &mut Self::Streams

The driver, split-borrowed from the server so the scope can claim on the way in and settle on the way out while body holds the rest.
Source§

fn on_failure(&mut self, stream: StreamId, error: &ServerError)

Told about every failure a scope settles, so a measurement in flight on stream is invalidated wherever the failure happened. Read more
Source§

fn capturing(&mut self, stream: StreamId) -> Option<&mut StreamCapture>

The graph capture of the pooled stream stream folds onto, for a server that records captures. Defaults to None, for one that does not. Read more
Source§

fn write_set(&mut self) -> Vec<BufferBinding>

An empty write set for the caller to fill with what the work it is about to run writes. Read more

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for WgpuServer<C>

§

impl<C> !Sync for WgpuServer<C>

§

impl<C> !UnwindSafe for WgpuServer<C>

§

impl<C> Freeze for WgpuServer<C>
where PhantomData<C>: Freeze,

§

impl<C> Send for WgpuServer<C>
where PhantomData<C>: Send,

§

impl<C> Unpin for WgpuServer<C>
where PhantomData<C>: Unpin,

§

impl<C> UnsafeUnpin for WgpuServer<C>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

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

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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

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