pub trait ComputeServer:
Send
+ Debug
+ Sized {
type Kernel: Send;
type Storage: ComputeStorage;
type Feature: Ord + Copy + Debug + Send + Sync;
// Required methods
fn read(
&mut self,
bindings: Vec<Binding>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send + 'static;
fn get_resource(&mut self, binding: Binding) -> BindingResource<Self>;
fn create(&mut self, data: &[u8]) -> Handle;
fn empty(&mut self, size: usize) -> Handle;
unsafe fn execute(
&mut self,
kernel: Self::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
kind: ExecutionMode,
);
fn flush(&mut self);
fn sync(&mut self) -> impl Future<Output = ()> + Send + 'static;
fn sync_elapsed(
&mut self,
) -> impl Future<Output = Result<Duration, TimestampsError>> + Send + 'static;
fn memory_usage(&self) -> MemoryUsage;
fn enable_timestamps(&mut self);
fn disable_timestamps(&mut self);
}
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 Storage: ComputeStorage
type Storage: ComputeStorage
The storage type defines how data is stored and accessed.
Required Methods§
Sourcefn read(
&mut self,
bindings: Vec<Binding>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send + 'static
fn read( &mut self, bindings: Vec<Binding>, ) -> impl Future<Output = Vec<Vec<u8>>> + Send + 'static
Given bindings, returns the owned resources as bytes.
Sourcefn get_resource(&mut self, binding: Binding) -> BindingResource<Self>
fn get_resource(&mut self, binding: Binding) -> BindingResource<Self>
Given a resource handle, returns the storage resource.
Sourcefn create(&mut self, data: &[u8]) -> Handle
fn create(&mut self, data: &[u8]) -> Handle
Given a resource as bytes, stores it and returns the memory handle.
Sourcefn empty(&mut self, size: usize) -> Handle
fn empty(&mut self, size: usize) -> Handle
Reserves size
bytes in the storage, and returns a handle over them.
Sourceunsafe fn execute(
&mut self,
kernel: Self::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
kind: ExecutionMode,
)
unsafe fn execute( &mut self, kernel: Self::Kernel, count: CubeCount, bindings: Vec<Binding>, kind: ExecutionMode, )
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 sync(&mut self) -> impl Future<Output = ()> + Send + 'static
fn sync(&mut self) -> impl Future<Output = ()> + Send + 'static
Wait for the completion of every task in the server.
Sourcefn sync_elapsed(
&mut self,
) -> impl Future<Output = Result<Duration, TimestampsError>> + Send + 'static
fn sync_elapsed( &mut self, ) -> impl Future<Output = Result<Duration, TimestampsError>> + Send + 'static
Wait for the completion of every task in the server.
Returns the (approximate) total amount of GPU work done since the last sync.
Sourcefn memory_usage(&self) -> MemoryUsage
fn memory_usage(&self) -> MemoryUsage
The current memory usage of the server.
Sourcefn enable_timestamps(&mut self)
fn enable_timestamps(&mut self)
Enable collecting timestamps.
Sourcefn disable_timestamps(&mut self)
fn disable_timestamps(&mut self)
Disable collecting timestamps.
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.