pub trait ComputeServer:
Send
+ Debug
+ ServerCommunication
+ DeviceService
+ 'staticwhere
Self: Sized,{
type Kernel: KernelMetadata;
type Info: Debug + Send + Sync;
type MemoryLayoutPolicy: MemoryLayoutPolicy;
type Storage: ComputeStorage;
Show 15 methods
// Required methods
fn initialize_memory(
&mut self,
memory: ManagedMemoryHandle,
size: u64,
stream_id: StreamId,
);
fn logger(&self) -> Arc<ServerLogger>;
fn utilities(&self) -> Arc<ServerUtilities<Self>>;
fn read(
&mut self,
descriptors: Vec<CopyDescriptor>,
stream_id: StreamId,
) -> DynFut<Result<Vec<Bytes>, ServerError>>;
fn write(
&mut self,
descriptors: Vec<(CopyDescriptor, Bytes)>,
stream_id: StreamId,
);
fn sync(&mut self, stream_id: StreamId) -> DynFut<Result<(), ServerError>>;
fn get_resource(
&mut self,
binding: Binding,
stream_id: StreamId,
) -> Result<ManagedResource<<Self::Storage as ComputeStorage>::Resource>, ServerError>;
unsafe fn launch(
&mut self,
kernel: Self::Kernel,
count: CubeCount,
bindings: KernelArguments,
kind: ExecutionMode,
stream_id: StreamId,
);
fn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>;
fn memory_usage(
&mut self,
stream_id: StreamId,
) -> Result<MemoryUsage, ServerError>;
fn memory_cleanup(&mut self, stream_id: StreamId);
fn start_profile(
&mut self,
stream_id: StreamId,
) -> Result<ProfilingToken, ServerError>;
fn end_profile(
&mut self,
stream_id: StreamId,
token: ProfilingToken,
) -> Result<ProfileDuration, ProfileError>;
fn allocation_mode(
&mut self,
mode: MemoryAllocationMode,
stream_id: StreamId,
);
// Provided method
fn staging(
&mut self,
_sizes: &[usize],
_stream_id: StreamId,
) -> Result<Vec<Bytes>, ServerError> { ... }
}Expand description
The compute server is responsible for handling resources and computations over resources.
Everything in the server is mutable, therefore it should be solely accessed through the
ComputeClient for thread safety.
Required Associated Types§
Sourcetype Kernel: KernelMetadata
type Kernel: KernelMetadata
The kernel type defines the computation algorithms.
Sourcetype MemoryLayoutPolicy: MemoryLayoutPolicy
type MemoryLayoutPolicy: MemoryLayoutPolicy
Manages how allocations are performed for a server.
Sourcetype Storage: ComputeStorage
type Storage: ComputeStorage
The storage type defines how data is stored and accessed.
Required Methods§
Sourcefn initialize_memory(
&mut self,
memory: ManagedMemoryHandle,
size: u64,
stream_id: StreamId,
)
fn initialize_memory( &mut self, memory: ManagedMemoryHandle, size: u64, stream_id: StreamId, )
Sourcefn logger(&self) -> Arc<ServerLogger>
fn logger(&self) -> Arc<ServerLogger>
Retrieve the server logger.
Sourcefn utilities(&self) -> Arc<ServerUtilities<Self>>
fn utilities(&self) -> Arc<ServerUtilities<Self>>
Retrieve the server utilities.
Sourcefn 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.
Sourcefn 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
Sourcefn sync(&mut self, stream_id: StreamId) -> DynFut<Result<(), ServerError>>
fn sync(&mut self, stream_id: StreamId) -> DynFut<Result<(), ServerError>>
Wait for the completion of every task in the server.
Sourcefn get_resource(
&mut self,
binding: Binding,
stream_id: StreamId,
) -> Result<ManagedResource<<Self::Storage as ComputeStorage>::Resource>, ServerError>
fn get_resource( &mut self, binding: Binding, stream_id: StreamId, ) -> Result<ManagedResource<<Self::Storage as ComputeStorage>::Resource>, ServerError>
Given a resource handle, returns the storage resource.
Sourceunsafe fn launch(
&mut self,
kernel: Self::Kernel,
count: CubeCount,
bindings: KernelArguments,
kind: ExecutionMode,
stream_id: StreamId,
)
unsafe fn launch( &mut self, kernel: Self::Kernel, count: CubeCount, bindings: KernelArguments, kind: ExecutionMode, stream_id: StreamId, )
Executes the kernel over the given memory handles.
Kernels have mutable access to every resource they are given and are responsible of determining which should be read or written.
§Safety
When executing with mode ExecutionMode::Unchecked, out-of-bound reads and writes can happen.
Sourcefn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>
fn flush(&mut self, stream_id: StreamId) -> Result<(), ServerError>
Flush all outstanding tasks in the server.
Sourcefn memory_usage(
&mut self,
stream_id: StreamId,
) -> Result<MemoryUsage, ServerError>
fn memory_usage( &mut self, stream_id: StreamId, ) -> Result<MemoryUsage, ServerError>
The current memory usage of the server.
Sourcefn 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.
Sourcefn start_profile(
&mut self,
stream_id: StreamId,
) -> Result<ProfilingToken, ServerError>
fn start_profile( &mut self, stream_id: StreamId, ) -> Result<ProfilingToken, ServerError>
Enable collecting timestamps.
Sourcefn 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.
Sourcefn 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.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.