CpuRuntime

Struct CpuRuntime 

pub struct CpuRuntime {
    node_id: u64,
    kernels: RwLock<RawRwLock, HashMap<KernelId, Arc<CpuKernel>>>,
    total_launched: AtomicU64,
    messages_sent: AtomicU64,
    messages_received: AtomicU64,
    shutdown: RwLock<RawRwLock, bool>,
    k2k_broker: Option<Arc<K2KBroker>>,
}
Expand description

CPU-based implementation of RingKernelRuntime.

This runtime executes kernels on the CPU, simulating GPU behavior. It’s primarily used for testing and as a fallback when no GPU is available.

Fields§

§node_id: u64§kernels: RwLock<RawRwLock, HashMap<KernelId, Arc<CpuKernel>>>§total_launched: AtomicU64§messages_sent: AtomicU64§messages_received: AtomicU64§shutdown: RwLock<RawRwLock, bool>§k2k_broker: Option<Arc<K2KBroker>>

Implementations§

§

impl CpuRuntime

pub async fn new() -> Result<CpuRuntime, RingKernelError>

Create a new CPU runtime.

pub async fn with_node_id(node_id: u64) -> Result<CpuRuntime, RingKernelError>

Create a CPU runtime with specific node ID.

pub async fn with_config( node_id: u64, enable_k2k: bool, ) -> Result<CpuRuntime, RingKernelError>

Create a CPU runtime with configuration options.

pub async fn with_k2k_config( node_id: u64, k2k_config: K2KConfig, ) -> Result<CpuRuntime, RingKernelError>

Create a CPU runtime with custom K2K configuration.

pub fn node_id(&self) -> u64

Get node ID.

pub fn is_shutdown(&self) -> bool

Check if runtime is shut down.

pub fn is_k2k_enabled(&self) -> bool

Check if K2K messaging is enabled.

pub fn k2k_broker(&self) -> Option<&Arc<K2KBroker>>

Get the K2K broker (if enabled).

Trait Implementations§

§

impl Drop for CpuRuntime

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl RingKernelRuntime for CpuRuntime

§

fn backend(&self) -> Backend

Get the backend type.
§

fn is_backend_available(&self, backend: Backend) -> bool

Check if a specific backend is available.
§

fn launch<'life0, 'life1, 'async_trait>( &'life0 self, kernel_id: &'life1 str, options: LaunchOptions, ) -> Pin<Box<dyn Future<Output = Result<KernelHandle, RingKernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, CpuRuntime: 'async_trait,

Launch a kernel.
§

fn get_kernel(&self, kernel_id: &KernelId) -> Option<KernelHandle>

Get a handle to an existing kernel.
§

fn list_kernels(&self) -> Vec<KernelId>

List all kernel IDs.
§

fn metrics(&self) -> RuntimeMetrics

Get runtime metrics.
§

fn shutdown<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), RingKernelError>> + Send + 'async_trait>>
where 'life0: 'async_trait, CpuRuntime: 'async_trait,

Shutdown the runtime and terminate all kernels.

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more