pub trait ComputeChannel<Server: ComputeServer>:
Clone
+ Debug
+ Send
+ Sync {
// Required methods
fn read(&self, binding: Binding) -> impl Future<Output = Vec<u8>> + Send;
fn get_resource(&self, binding: Binding) -> BindingResource<Server>;
fn create(&self, data: &[u8]) -> Handle;
fn empty(&self, size: usize) -> Handle;
unsafe fn execute(
&self,
kernel: Server::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
mode: ExecutionMode,
);
fn flush(&self);
fn sync(&self) -> impl Future<Output = ()> + Send;
fn sync_elapsed(&self) -> impl Future<Output = TimestampsResult> + Send;
fn memory_usage(&self) -> MemoryUsage;
fn enable_timestamps(&self);
fn disable_timestamps(&self);
}
Expand description
The ComputeChannel trait links the ComputeClient to the ComputeServer while ensuring thread-safety
Required Methods§
Sourcefn read(&self, binding: Binding) -> impl Future<Output = Vec<u8>> + Send
fn read(&self, binding: Binding) -> impl Future<Output = Vec<u8>> + Send
Given a binding, returns owned resource as bytes
Sourcefn get_resource(&self, binding: Binding) -> BindingResource<Server>
fn get_resource(&self, binding: Binding) -> BindingResource<Server>
Given a resource handle, return the storage resource.
Sourcefn create(&self, data: &[u8]) -> Handle
fn create(&self, data: &[u8]) -> Handle
Given a resource as bytes, stores it and returns the resource handle
Sourcefn empty(&self, size: usize) -> Handle
fn empty(&self, size: usize) -> Handle
Reserves size
bytes in the storage, and returns a handle over them
Sourceunsafe fn execute(
&self,
kernel: Server::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
mode: ExecutionMode,
)
unsafe fn execute( &self, kernel: Server::Kernel, count: CubeCount, bindings: Vec<Binding>, mode: ExecutionMode, )
Executes the kernel
over the given bindings
.
§Safety
When executing with mode ExecutionMode::Unchecked, out-of-bound reads and writes can happen.
Sourcefn sync(&self) -> impl Future<Output = ()> + Send
fn sync(&self) -> impl Future<Output = ()> + Send
Wait for the completion of every task in the server.
Sourcefn sync_elapsed(&self) -> impl Future<Output = TimestampsResult> + Send
fn sync_elapsed(&self) -> impl Future<Output = TimestampsResult> + Send
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
Get the current memory usage of the server.
Sourcefn enable_timestamps(&self)
fn enable_timestamps(&self)
Enable collecting timestamps.
Sourcefn disable_timestamps(&self)
fn disable_timestamps(&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.