pub struct WgpuServer<C: WgpuCompiler> {
pub compilation_options: WgpuCompilationOptions,
/* private fields */
}Expand description
Wgpu compute server.
Fields§
§compilation_options: WgpuCompilationOptionsImplementations§
Source§impl<C: WgpuCompiler> WgpuServer<C>
impl<C: WgpuCompiler> WgpuServer<C>
Sourcepub fn load_cached_pipeline(
&mut self,
kernel_id: &KernelId,
definition: &KernelDefinition,
bindings: &KernelArguments,
mode: ExecutionMode,
) -> Result<Option<Result<(Arc<ComputePipeline>, CompilerInfo), (u64, KernelCacheKey)>>, CompilationError>
pub fn load_cached_pipeline( &mut self, kernel_id: &KernelId, definition: &KernelDefinition, bindings: &KernelArguments, mode: ExecutionMode, ) -> Result<Option<Result<(Arc<ComputePipeline>, CompilerInfo), (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.
pub fn create_module( &self, entrypoint_name: &str, cube_dim: CubeDim, repr: Option<AutoRepresentationRef<'_>>, source: &str, mode: ExecutionMode, ) -> Result<ShaderModule, CompilationError>
pub fn create_pipeline( &self, entrypoint_name: &str, repr: Option<AutoRepresentationRef<'_>>, module: ShaderModule, bindings: &KernelArguments, ) -> Arc<ComputePipeline> ⓘ
Source§impl<C: WgpuCompiler> WgpuServer<C>
impl<C: WgpuCompiler> WgpuServer<C>
Sourcepub 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>,
) -> Self
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>, ) -> Self
Create a new server.
Trait Implementations§
Source§impl<C: WgpuCompiler> ComputeServer for WgpuServer<C>
impl<C: WgpuCompiler> ComputeServer for WgpuServer<C>
Source§fn sync(&mut self, stream_id: StreamId) -> DynFut<Result<(), ServerError>>
fn sync(&mut self, stream_id: StreamId) -> DynFut<Result<(), ServerError>>
Returns the total time of GPU work this sync completes.
Source§type Storage = WgpuStorage
type Storage = WgpuStorage
The storage type defines how data is stored and accessed.
Source§type MemoryLayoutPolicy = ContiguousMemoryLayoutPolicy
type MemoryLayoutPolicy = ContiguousMemoryLayoutPolicy
Manages how allocations are performed for a server.
Source§fn staging(
&mut self,
_sizes: &[usize],
_stream_id: StreamId,
) -> Result<Vec<Bytes>, ServerError>
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,
)
fn initialize_memory( &mut self, memory: ManagedMemoryHandle, size: u64, stream_id: StreamId, )
Source§fn read(
&mut self,
descriptors: Vec<CopyDescriptor>,
stream_id: StreamId,
) -> DynFut<Result<Vec<Bytes>, ServerError>>
fn read( &mut self, descriptors: Vec<CopyDescriptor>, stream_id: StreamId, ) -> DynFut<Result<Vec<Bytes>, ServerError>>
Given bindings, returns the owned resources as bytes.
Source§fn write(
&mut self,
descriptors: Vec<(CopyDescriptor, Bytes)>,
stream_id: StreamId,
)
fn write( &mut self, descriptors: Vec<(CopyDescriptor, Bytes)>, stream_id: StreamId, )
Writes the specified bytes into the buffers given
Source§fn get_resource(
&mut self,
binding: Binding,
stream_id: StreamId,
) -> Result<ManagedResource<WgpuResource>, ServerError>
fn get_resource( &mut self, binding: Binding, stream_id: StreamId, ) -> Result<ManagedResource<WgpuResource>, ServerError>
Given a resource handle, returns the storage resource.
Source§unsafe fn launch(
&mut self,
kernel: Self::Kernel,
count: CubeCount,
args: KernelArguments,
mode: ExecutionMode,
stream_id: StreamId,
launch_mode: LaunchMode,
)
unsafe fn launch( &mut self, kernel: Self::Kernel, count: CubeCount, args: KernelArguments, mode: ExecutionMode, stream_id: StreamId, launch_mode: LaunchMode, )
Source§fn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>
fn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>
Flush all outstanding tasks in the server.
Source§fn start_profile(
&mut self,
stream_id: StreamId,
) -> Result<ProfilingToken, ServerError>
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>
fn end_profile( &mut self, stream_id: StreamId, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>
Disable collecting timestamps.
Source§fn memory_usage(
&mut self,
stream_id: StreamId,
) -> Result<MemoryUsage, ServerError>
fn memory_usage( &mut self, stream_id: StreamId, ) -> Result<MemoryUsage, ServerError>
Memory usage of the given stream.
Source§fn stream_ids(&self) -> Vec<StreamId>
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)
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)
fn allocation_mode(&mut self, mode: MemoryAllocationMode, stream_id: StreamId)
Update the memory mode of allocation in the server.
Source§fn configure_memory_pools(
&mut self,
config: MemoryConfiguration,
stream_id: StreamId,
) -> bool
fn configure_memory_pools( &mut self, config: MemoryConfiguration, stream_id: StreamId, ) -> bool
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>
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 itself needs no fresh device allocation — a device malloc inside
the capture is illegal. Read moreSource§fn begin_capture(&mut self, stream_id: StreamId) -> Result<(), ServerError>
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
as a single dispatch. Between this call and end_capture
the stream must not synchronize or allocate fresh device memory — call
graph_prepare and warm up first. Read moreSource§fn end_capture(&mut self, stream_id: StreamId) -> Result<GraphId, ServerError>
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)
fn replay(&mut self, graph: GraphId, stream_id: StreamId)
Replay the graph identified by
graph on stream_id — one dispatch that
re-runs the whole recorded launch sequence against its original buffers. Read moreSource§fn graph_destroy(&mut self, graph: GraphId, stream_id: StreamId)
fn graph_destroy(&mut self, graph: GraphId, stream_id: StreamId)
Release the graph identified by
graph, destroying its executable and
unpinning the buffers it retained. The backend must ensure any in-flight
replay on stream_id has completed first (replay returns at enqueue
time). A no-op by default and for an unknown id.Source§impl<C: Debug + WgpuCompiler> Debug for WgpuServer<C>
impl<C: Debug + WgpuCompiler> Debug for WgpuServer<C>
Source§impl<C: WgpuCompiler> DeviceService for WgpuServer<C>
impl<C: WgpuCompiler> DeviceService for WgpuServer<C>
Source§impl<C: WgpuCompiler> ServerCommunication for WgpuServer<C>
impl<C: WgpuCompiler> ServerCommunication for WgpuServer<C>
Source§const SERVER_COMM_ENABLED: bool = false
const SERVER_COMM_ENABLED: bool = false
Indicates whether server-to-server communication is enabled for this implementation.
Source§fn sync_collective(&mut self, stream_id: StreamId) -> Result<(), ServerError>
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>
fn comm_init(&mut self, device_ids: Vec<DeviceId>) -> Result<(), ServerError>
Initialize the communication between the devices in
device_ids. Read moreSource§fn all_reduce(
&mut self,
src: Binding,
dst: Binding,
dtype: ElemType,
stream_id: StreamId,
op: ReduceOperation,
device_ids: Vec<DeviceId>,
) -> Result<(), ServerError>
fn all_reduce( &mut self, src: Binding, dst: Binding, 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 moreAuto 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>
impl<C> Send for WgpuServer<C>
impl<C> Unpin for WgpuServer<C>where
C: Unpin,
impl<C> UnsafeUnpin for WgpuServer<C>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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