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>,
impl<Server, Channel> ComputeClient<Server, Channel>where
Server: ComputeServer,
Channel: ComputeChannel<Server>,
Sourcepub fn new(
channel: Channel,
properties: DeviceProperties<<Server as ComputeServer>::Feature>,
) -> ComputeClient<Server, Channel>
pub fn new( channel: Channel, properties: DeviceProperties<<Server as ComputeServer>::Feature>, ) -> ComputeClient<Server, Channel>
Create a new client.
Sourcepub async fn read_async(&self, bindings: Vec<Binding>) -> Vec<Vec<u8>>
pub async fn read_async(&self, bindings: Vec<Binding>) -> Vec<Vec<u8>>
Given bindings, returns owned resources as bytes.
Sourcepub async fn read_one_async(&self, binding: Binding) -> Vec<u8> ⓘ
pub async fn read_one_async(&self, binding: Binding) -> Vec<u8> ⓘ
Given a binding, returns owned resource as bytes.
Sourcepub fn get_resource(&self, binding: Binding) -> BindingResource<Server>
pub fn get_resource(&self, binding: Binding) -> BindingResource<Server>
Given a resource handle, returns the storage resource.
Sourcepub fn create(&self, data: &[u8]) -> Handle
pub fn create(&self, data: &[u8]) -> Handle
Given a resource, stores it and returns the resource handle.
Sourcepub fn empty(&self, size: usize) -> Handle
pub fn empty(&self, size: usize) -> Handle
Reserves size
bytes in the storage, and returns a handle over them.
Sourcepub fn execute(
&self,
kernel: <Server as ComputeServer>::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
)
pub fn execute( &self, kernel: <Server as ComputeServer>::Kernel, count: CubeCount, bindings: Vec<Binding>, )
Executes the kernel
over the given bindings
.
Sourcepub unsafe fn execute_unchecked(
&self,
kernel: <Server as ComputeServer>::Kernel,
count: CubeCount,
bindings: Vec<Binding>,
)
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.
Sourcepub async fn sync_elapsed(&self) -> Result<Duration, TimestampsError>
pub async fn sync_elapsed(&self) -> Result<Duration, TimestampsError>
Wait for the completion of every task in the server.
Sourcepub fn properties(
&self,
) -> &DeviceProperties<<Server as ComputeServer>::Feature>
pub fn properties( &self, ) -> &DeviceProperties<<Server as ComputeServer>::Feature>
Get the features supported by the compute server.
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get the current memory usage of this client.
Sourcepub async fn profile<O, Fut, Func>(&self, func: Func) -> O
pub async fn profile<O, Fut, Func>(&self, func: Func) -> O
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.
Sourcepub fn enable_timestamps(&self)
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>,
impl<S, C> Clone for ComputeClient<S, C>where
S: ComputeServer,
C: ComputeChannel<S>,
Source§fn clone(&self) -> ComputeClient<S, C>
fn clone(&self) -> ComputeClient<S, C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more