pub trait ComputeServer:
    Send
    + Debug
    + ServerCommunication
    + DeviceState
    + 'static
    + Sized {
    type Kernel: KernelMetadata;
    type Info: Debug + Send + Sync;
    type Storage: ComputeStorage;
Show 15 methods
    // Required methods
    fn create(
        &mut self,
        descriptors: Vec<AllocationDescriptor<'_>>,
        stream_id: StreamId,
    ) -> Result<Vec<Allocation>, IoError>;
    fn logger(&self) -> Arc<ServerLogger>;
    fn utilities(&self) -> Arc<ServerUtilities<Self>>;
    fn read<'a>(
        &mut self,
        descriptors: Vec<CopyDescriptor<'a>>,
        stream_id: StreamId,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, IoError>> + Send>>;
    fn write(
        &mut self,
        descriptors: Vec<(CopyDescriptor<'_>, &[u8])>,
        stream_id: StreamId,
    ) -> Result<(), IoError>;
    fn sync(
        &mut self,
        stream_id: StreamId,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn get_resource(
        &mut self,
        binding: Binding,
        stream_id: StreamId,
    ) -> BindingResource<<Self::Storage as ComputeStorage>::Resource>;
    unsafe fn execute(
        &mut self,
        kernel: Self::Kernel,
        count: CubeCount,
        bindings: Bindings,
        kind: ExecutionMode,
        stream_id: StreamId,
    );
    fn flush(&mut self, stream_id: StreamId);
    fn memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage;
    fn memory_cleanup(&mut self, stream_id: StreamId);
    fn start_profile(&mut self, stream_id: StreamId) -> ProfilingToken;
    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 create_with_data(
        &mut self,
        data: &[u8],
        stream_id: StreamId,
    ) -> Result<Handle, IoError> { ... }
}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 compute channel for thread safety.
Required Associated Types§
Sourcetype Kernel: KernelMetadata
 
type Kernel: KernelMetadata
The kernel type defines the computation algorithms.
Sourcetype Storage: ComputeStorage
 
type Storage: ComputeStorage
The storage type defines how data is stored and accessed.
Required Methods§
Sourcefn create(
    &mut self,
    descriptors: Vec<AllocationDescriptor<'_>>,
    stream_id: StreamId,
) -> Result<Vec<Allocation>, IoError>
 
fn create( &mut self, descriptors: Vec<AllocationDescriptor<'_>>, stream_id: StreamId, ) -> Result<Vec<Allocation>, IoError>
Reserves size bytes in the storage, and returns a handle over them.
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<'a>(
    &mut self,
    descriptors: Vec<CopyDescriptor<'a>>,
    stream_id: StreamId,
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, IoError>> + Send>>
 
fn read<'a>( &mut self, descriptors: Vec<CopyDescriptor<'a>>, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>, IoError>> + Send>>
Given bindings, returns the owned resources as bytes.
Sourcefn write(
    &mut self,
    descriptors: Vec<(CopyDescriptor<'_>, &[u8])>,
    stream_id: StreamId,
) -> Result<(), IoError>
 
fn write( &mut self, descriptors: Vec<(CopyDescriptor<'_>, &[u8])>, stream_id: StreamId, ) -> Result<(), IoError>
Writes the specified bytes into the buffers given
Sourcefn sync(
    &mut self,
    stream_id: StreamId,
) -> Pin<Box<dyn Future<Output = ()> + Send>>
 
fn sync( &mut self, stream_id: StreamId, ) -> Pin<Box<dyn Future<Output = ()> + Send>>
Wait for the completion of every task in the server.
Sourcefn get_resource(
    &mut self,
    binding: Binding,
    stream_id: StreamId,
) -> BindingResource<<Self::Storage as ComputeStorage>::Resource>
 
fn get_resource( &mut self, binding: Binding, stream_id: StreamId, ) -> BindingResource<<Self::Storage as ComputeStorage>::Resource>
Given a resource handle, returns the storage resource.
Sourceunsafe fn execute(
    &mut self,
    kernel: Self::Kernel,
    count: CubeCount,
    bindings: Bindings,
    kind: ExecutionMode,
    stream_id: StreamId,
)
 
unsafe fn execute( &mut self, kernel: Self::Kernel, count: CubeCount, bindings: Bindings, 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 memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage
 
fn memory_usage(&mut self, stream_id: StreamId) -> MemoryUsage
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) -> ProfilingToken
 
fn start_profile(&mut self, stream_id: StreamId) -> ProfilingToken
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.