pub trait ComputeChannel<Server>:
Clone
+ Debug
+ Send
+ Syncwhere
Server: ComputeServer,{
Show 14 methods
// Required methods
fn read(
&self,
bindings: Vec<Binding>,
) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>;
fn read_tensor(
&self,
bindings: Vec<BindingWithMeta>,
) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>;
fn sync(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
fn get_resource(
&self,
binding: Binding,
) -> BindingResource<<<Server as ComputeServer>::Storage as ComputeStorage>::Resource>;
fn create(&self, data: &[u8]) -> Handle;
fn create_tensors(
&self,
data: Vec<&[u8]>,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>;
fn empty(&self, size: usize) -> Handle;
fn empty_tensors(
&self,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>;
unsafe fn execute(
&self,
kernel: <Server as ComputeServer>::Kernel,
count: CubeCount,
bindings: Bindings,
mode: ExecutionMode,
logger: Arc<ServerLogger>,
);
fn flush(&self);
fn memory_usage(&self) -> MemoryUsage;
fn memory_cleanup(&self);
fn start_profile(&self) -> ProfilingToken;
fn end_profile(
&self,
token: ProfilingToken,
) -> Result<ProfileDuration, ProfileError>;
}
Expand description
The ComputeChannel trait links the ComputeClient to the ComputeServer while ensuring thread-safety
Required Methods§
Sourcefn read(
&self,
bindings: Vec<Binding>,
) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>
fn read( &self, bindings: Vec<Binding>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>
Given bindings, returns owned resources as bytes
Sourcefn read_tensor(
&self,
bindings: Vec<BindingWithMeta>,
) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>
fn read_tensor( &self, bindings: Vec<BindingWithMeta>, ) -> Pin<Box<dyn Future<Output = Vec<Vec<u8>>> + Send>>
Given bindings, returns owned resources as bytes
Sourcefn sync(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>
fn sync(&self) -> Pin<Box<dyn Future<Output = ()> + Send>>
Wait for the completion of every task in the server.
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_tensors(
&self,
data: Vec<&[u8]>,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>
fn create_tensors( &self, data: Vec<&[u8]>, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(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_tensors(
&self,
shape: Vec<&[usize]>,
elem_size: Vec<usize>,
) -> Vec<(Handle, Vec<usize>)>
fn empty_tensors( &self, shape: Vec<&[usize]>, elem_size: Vec<usize>, ) -> Vec<(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,
logger: Arc<ServerLogger>,
)
unsafe fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Bindings, mode: ExecutionMode, logger: Arc<ServerLogger>, )
Executes the kernel
over the given bindings
.
Optionally returns some debug information about the compilation to be logged.
§Safety
When executing with mode ExecutionMode::Unchecked, out-of-bound reads and writes can happen.
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) -> ProfilingToken
fn start_profile(&self) -> ProfilingToken
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.
Sourcefn end_profile(
&self,
token: ProfilingToken,
) -> Result<ProfileDuration, ProfileError>
fn end_profile( &self, token: ProfilingToken, ) -> Result<ProfileDuration, ProfileError>
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.