Struct ComputeClient

Source
pub struct ComputeClient<Server, Channel>
where Server: ComputeServer,
{ /* private fields */ }
Expand description

The ComputeClient is the entry point to require tasks from the ComputeServer. It should be obtained for a specific device via the Compute struct.

Implementations§

Source§

impl<Server, Channel> ComputeClient<Server, Channel>
where Server: ComputeServer, Channel: ComputeChannel<Server>,

Source

pub fn new( channel: Channel, properties: DeviceProperties<<Server as ComputeServer>::Feature>, ) -> ComputeClient<Server, Channel>

Create a new client.

Source

pub async fn read_async(&self, bindings: Vec<Binding>) -> Vec<Vec<u8>>

Given bindings, returns owned resources as bytes.

Source

pub fn read(&self, bindings: Vec<Binding>) -> Vec<Vec<u8>>

Given bindings, returns owned resources as bytes.

§Remarks

Panics if the read operation fails.

Source

pub async fn read_one_async(&self, binding: Binding) -> Vec<u8>

Given a binding, returns owned resource as bytes.

Source

pub fn read_one(&self, binding: Binding) -> Vec<u8>

Given a binding, returns owned resource as bytes.

§Remarks

Panics if the read operation fails.

Source

pub fn get_resource(&self, binding: Binding) -> BindingResource<Server>

Given a resource handle, returns the storage resource.

Source

pub fn create(&self, data: &[u8]) -> Handle

Given a resource, stores it and returns the resource handle.

Source

pub fn empty(&self, size: usize) -> Handle

Reserves size bytes in the storage, and returns a handle over them.

Source

pub fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Vec<Binding>, )

Executes the kernel over the given bindings.

Source

pub unsafe fn execute_unchecked( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Vec<Binding>, )

Executes the kernel over the given bindings without performing any bound checks.

§Safety

Without checks, the out-of-bound reads and writes can happen.

Source

pub fn flush(&self)

Flush all outstanding commands.

Source

pub async fn sync(&self)

Wait for the completion of every task in the server.

Source

pub async fn sync_elapsed(&self) -> Result<Duration, TimestampsError>

Wait for the completion of every task in the server.

Source

pub fn properties( &self, ) -> &DeviceProperties<<Server as ComputeServer>::Feature>

Get the features supported by the compute server.

Source

pub fn memory_usage(&self) -> MemoryUsage

Get the current memory usage of this client.

Source

pub async fn profile<O, Fut, Func>(&self, func: Func) -> O
where Fut: Future<Output = O>, Func: FnOnce() -> Fut,

When executing operation within the profile scope, you can call sync_elapsed safely even in multithreaded workloads. Creates a profiling scope that enables safe timing measurements in concurrent contexts.

Operations executed within this scope can safely call sync_elapsed() to measure elapsed time, even in multithreaded environments. The measurements are thread-safe and properly synchronized.

Source

pub fn enable_timestamps(&self)

Enable timestamp collection on the server for performance profiling.

This feature records precise timing data for server operations, which can be used for performance analysis and benchmarking.

§Warning

This should only be used during development and benchmarking, not in production, as it significantly impacts server throughput and performance. The overhead comes from frequent timestamp collection and storage.

§Example
server.enable_timestamps();
// Run your benchmarks/operations
let duration = server.sync_elapsed();

Trait Implementations§

Source§

impl<S, C> Clone for ComputeClient<S, C>
where S: ComputeServer, C: ComputeChannel<S>,

Source§

fn clone(&self) -> ComputeClient<S, C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Server, Channel> Debug for ComputeClient<Server, Channel>
where Server: Debug + ComputeServer, Channel: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Server, Channel> Freeze for ComputeClient<Server, Channel>
where Channel: Freeze,

§

impl<Server, Channel> !RefUnwindSafe for ComputeClient<Server, Channel>

§

impl<Server, Channel> Send for ComputeClient<Server, Channel>
where Channel: Send,

§

impl<Server, Channel> Sync for ComputeClient<Server, Channel>
where Channel: Sync,

§

impl<Server, Channel> Unpin for ComputeClient<Server, Channel>
where Channel: Unpin,

§

impl<Server, Channel> !UnwindSafe for ComputeClient<Server, Channel>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V