RingContext

Struct RingContext 

Source
pub struct RingContext<'a> {
    pub thread_id: ThreadId,
    pub block_id: BlockId,
    pub block_dim: Dim3,
    pub grid_dim: Dim3,
    /* private fields */
}
Expand description

GPU intrinsics facade for kernel handlers.

This struct provides access to GPU-specific operations like thread identification, synchronization, and atomic operations. The actual implementation varies by backend.

§Lifetime

The context is borrowed for the duration of the kernel handler execution.

Fields§

§thread_id: ThreadId

Thread identity within block.

§block_id: BlockId

Block identity within grid.

§block_dim: Dim3

Block dimensions.

§grid_dim: Dim3

Grid dimensions.

Implementations§

Source§

impl<'a> RingContext<'a>

Source

pub fn new( thread_id: ThreadId, block_id: BlockId, block_dim: Dim3, grid_dim: Dim3, clock: &'a HlcClock, kernel_id: u64, backend: ContextBackend, ) -> Self

Create a new context.

Source

pub fn thread_id(&self) -> ThreadId

Get thread ID within block.

Source

pub fn block_id(&self) -> BlockId

Get block ID within grid.

Source

pub fn global_thread_id(&self) -> GlobalThreadId

Get global thread ID across all blocks.

Source

pub fn warp_id(&self) -> WarpId

Get warp ID within block.

Source

pub fn lane_id(&self) -> u32

Get lane ID within warp (0-31).

Source

pub fn block_dim(&self) -> Dim3

Get block dimensions.

Source

pub fn grid_dim(&self) -> Dim3

Get grid dimensions.

Source

pub fn kernel_id(&self) -> u64

Get kernel ID.

Source

pub fn sync_threads(&self)

Synchronize all threads in the block.

All threads in the block must reach this barrier before any thread can proceed past it.

Source

pub fn sync_grid(&self)

Synchronize all threads in the grid (cooperative groups).

Requires cooperative kernel launch support.

Source

pub fn sync_warp(&self)

Synchronize threads within a warp.

Source

pub fn thread_fence(&self, scope: FenceScope)

Memory fence at the specified scope.

Source

pub fn fence_thread(&self)

Thread-scope fence (compiler barrier).

Source

pub fn fence_block(&self)

Block-scope fence.

Source

pub fn fence_device(&self)

Device-scope fence.

Source

pub fn fence_system(&self)

System-scope fence (CPU+GPU visible).

Source

pub fn now(&self) -> HlcTimestamp

Get current HLC timestamp.

Source

pub fn tick(&self) -> HlcTimestamp

Generate a new HLC timestamp (advances clock).

Source

pub fn update_clock(&self, received: &HlcTimestamp) -> Result<HlcTimestamp>

Update clock with received timestamp.

Source

pub fn atomic_add(&self, ptr: &AtomicU64, val: u64, order: MemoryOrder) -> u64

Atomic add and return old value.

Source

pub fn atomic_cas( &self, ptr: &AtomicU64, expected: u64, desired: u64, success: MemoryOrder, failure: MemoryOrder, ) -> Result<u64, u64>

Atomic compare-and-swap.

Source

pub fn atomic_exchange( &self, ptr: &AtomicU64, val: u64, order: MemoryOrder, ) -> u64

Atomic exchange.

Source

pub fn warp_shuffle<T: Copy>(&self, value: T, src_lane: u32) -> T

Warp shuffle - get value from another lane.

Returns the value from the specified source lane.

Source

pub fn warp_shuffle_down<T: Copy>(&self, value: T, delta: u32) -> T

Warp shuffle down - get value from lane + delta.

Source

pub fn warp_shuffle_up<T: Copy>(&self, value: T, delta: u32) -> T

Warp shuffle up - get value from lane - delta.

Source

pub fn warp_shuffle_xor<T: Copy>(&self, value: T, mask: u32) -> T

Warp shuffle XOR - get value from lane XOR mask.

Source

pub fn warp_ballot(&self, predicate: bool) -> u32

Warp ballot - get bitmask of lanes where predicate is true.

Source

pub fn warp_all(&self, predicate: bool) -> bool

Warp all - check if predicate is true for all lanes.

Source

pub fn warp_any(&self, predicate: bool) -> bool

Warp any - check if predicate is true for any lane.

Source

pub fn k2k_send( &self, _target_kernel: u64, _envelope: &MessageEnvelope, ) -> Result<()>

Send message to another kernel (K2K).

This is a placeholder; actual implementation requires runtime support.

Source

pub fn k2k_try_recv(&self) -> Result<MessageEnvelope>

Try to receive message from K2K queue.

Trait Implementations§

Source§

impl<'a> Debug for RingContext<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for RingContext<'a>

§

impl<'a> RefUnwindSafe for RingContext<'a>

§

impl<'a> Send for RingContext<'a>

§

impl<'a> Sync for RingContext<'a>

§

impl<'a> Unpin for RingContext<'a>

§

impl<'a> UnwindSafe for RingContext<'a>

Blanket Implementations§

§

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

§

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.
§

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
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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

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.
§

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.