ControlBlock

Struct ControlBlock 

Source
#[repr(C, align(128))]
pub struct ControlBlock {
Show 18 fields pub is_active: u32, pub should_terminate: u32, pub has_terminated: u32, pub _pad1: u32, pub messages_processed: u64, pub messages_in_flight: u64, pub input_head: u64, pub input_tail: u64, pub output_head: u64, pub output_tail: u64, pub input_capacity: u32, pub output_capacity: u32, pub input_mask: u32, pub output_mask: u32, pub hlc_state: HlcState, pub last_error: u32, pub error_count: u32, pub _reserved: [u8; 24],
}
Expand description

Kernel control block (128 bytes, cache-line aligned).

This structure resides in GPU global memory and is accessed atomically by both host and device code for kernel lifecycle management.

§Memory Layout

The structure is carefully designed to minimize false sharing:

  • Frequently written fields are grouped together
  • Read-only fields are separated
  • Padding ensures proper alignment

Fields§

§is_active: u32

Kernel is actively processing messages (atomic bool).

§should_terminate: u32

Signal to terminate the kernel (atomic bool).

§has_terminated: u32

Kernel has completed termination (atomic bool).

§_pad1: u32

Reserved for alignment.

§messages_processed: u64

Total messages processed.

§messages_in_flight: u64

Messages currently being processed.

§input_head: u64

Input queue head pointer (producer writes).

§input_tail: u64

Input queue tail pointer (consumer reads).

§output_head: u64

Output queue head pointer (producer writes).

§output_tail: u64

Output queue tail pointer (consumer reads).

§input_capacity: u32

Input queue capacity (power of 2).

§output_capacity: u32

Output queue capacity (power of 2).

§input_mask: u32

Input queue mask (capacity - 1).

§output_mask: u32

Output queue mask (capacity - 1).

§hlc_state: HlcState

HLC state for this kernel.

§last_error: u32

Last error code (0 = no error).

§error_count: u32

Error count.

§_reserved: [u8; 24]

Reserved for future use.

Implementations§

Source§

impl ControlBlock

Source

pub const fn new() -> Self

Create a new control block with default values.

Source

pub fn with_capacities(input_capacity: u32, output_capacity: u32) -> Self

Create with specified queue capacities.

Capacities must be powers of 2.

Source

pub fn is_active(&self) -> bool

Check if the kernel is active.

Source

pub fn should_terminate(&self) -> bool

Check if termination was requested.

Source

pub fn has_terminated(&self) -> bool

Check if the kernel has terminated.

Source

pub fn input_queue_size(&self) -> u64

Get input queue size.

Source

pub fn output_queue_size(&self) -> u64

Get output queue size.

Source

pub fn input_queue_empty(&self) -> bool

Check if input queue is empty.

Source

pub fn output_queue_empty(&self) -> bool

Check if output queue is empty.

Source

pub fn input_queue_full(&self) -> bool

Check if input queue is full.

Source

pub fn output_queue_full(&self) -> bool

Check if output queue is full.

Trait Implementations§

Source§

impl Clone for ControlBlock

Source§

fn clone(&self) -> ControlBlock

Returns a duplicate 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 Debug for ControlBlock

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ControlBlock

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for ControlBlock

Auto Trait Implementations§

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

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

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

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

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

Deserializes using the given deserializer
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> LayoutRaw for T

Source§

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

Gets the layout of the type.
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.