pub trait ComputeChannel<Server>:
Clone
+ Debug
+ Send
+ Syncwhere
Server: ComputeServer,{
Show 14 methods
// Required methods
fn read(
&self,
bindings: Vec<Binding>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send;
fn read_tensor(
&self,
bindings: Vec<BindingWithMeta>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send;
fn get_resource(
&self,
binding: Binding,
) -> BindingResource<<<Server as ComputeServer>::Storage as ComputeStorage>::Resource>;
fn create(&self, data: &[u8]) -> Handle;
fn create_tensor(
&self,
data: &[u8],
shape: &[usize],
elem_size: usize,
) -> (Handle, Vec<usize>);
fn empty(&self, size: usize) -> Handle;
fn empty_tensor(
&self,
shape: &[usize],
elem_size: usize,
) -> (Handle, Vec<usize>);
unsafe fn execute(
&self,
kernel: <Server as ComputeServer>::Kernel,
count: CubeCount,
bindings: Bindings,
mode: ExecutionMode,
);
fn flush(&self);
fn sync(&self) -> impl Future<Output = ()> + Send;
fn memory_usage(&self) -> MemoryUsage;
fn memory_cleanup(&self);
fn start_profile(&self);
fn end_profile(&self) -> ProfileDuration;
}
Expand description
The ComputeChannel trait links the ComputeClient to the ComputeServer while ensuring thread-safety
Required Methods§
Sourcefn read(
&self,
bindings: Vec<Binding>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send
fn read( &self, bindings: Vec<Binding>, ) -> impl Future<Output = Vec<Vec<u8>>> + Send
Given bindings, returns owned resources as bytes
Sourcefn read_tensor(
&self,
bindings: Vec<BindingWithMeta>,
) -> impl Future<Output = Vec<Vec<u8>>> + Send
fn read_tensor( &self, bindings: Vec<BindingWithMeta>, ) -> impl Future<Output = Vec<Vec<u8>>> + Send
Given bindings, returns owned resources as bytes
Sourcefn get_resource(
&self,
binding: Binding,
) -> BindingResource<<<Server as ComputeServer>::Storage as ComputeStorage>::Resource>
fn get_resource( &self, binding: Binding, ) -> BindingResource<<<Server as ComputeServer>::Storage as ComputeStorage>::Resource>
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 create_tensor(
&self,
data: &[u8],
shape: &[usize],
elem_size: usize,
) -> (Handle, Vec<usize>)
fn create_tensor( &self, data: &[u8], shape: &[usize], elem_size: usize, ) -> (Handle, Vec<usize>)
Given a resource as bytes and a shape, stores it and returns the tensor 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
Sourcefn empty_tensor(
&self,
shape: &[usize],
elem_size: usize,
) -> (Handle, Vec<usize>)
fn empty_tensor( &self, shape: &[usize], elem_size: usize, ) -> (Handle, Vec<usize>)
Reserves a tensor with shape
in the storage, and returns a handle to it
Sourceunsafe fn execute(
&self,
kernel: <Server as ComputeServer>::Kernel,
count: CubeCount,
bindings: Bindings,
mode: ExecutionMode,
)
unsafe fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Bindings, 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 memory_usage(&self) -> MemoryUsage
fn memory_usage(&self) -> MemoryUsage
Get the current memory usage of the server.
Sourcefn memory_cleanup(&self)
fn memory_cleanup(&self)
Ask the server to release memory that it can release.
Sourcefn start_profile(&self)
fn start_profile(&self)
Start a profile on the server. This allows you to profile kernels.
This will measure execution time either by measuring the ‘full’ execution time by synchronizing the execution at the start and the end of the profile, or ‘device’ time by using device timestamps. This function will handle any required synchronization.
Recursive profiling is not allowed and will panic.
Sourcefn end_profile(&self) -> ProfileDuration
fn end_profile(&self) -> ProfileDuration
End the profile and return a ProfileDuration
.
You can retrieve the Duration of the client profile asynchronously. This function will handle any required synchronization.
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.