Atomic

Struct Atomic 

Source
pub struct Atomic<'a, T: ?Sized> { /* private fields */ }
Expand description

To prevent the user from mixing use of Atomic operation and chunk-based access, we wrap the reference to the data to be modified in an Atomic struct. ensuring that the user cannot access the data without using atomic operations. If user wants to repurpose the data for non-atomic access, they need to drop the Atomic struct first and need a sync across all blocks. For now, sync across all blocks is not supported, we should reject such code in analysis. TODO: Avoid repurposing data for atomic or chunk-based access.

Implementations§

Source§

impl<'a, T> Atomic<'a, [T]>

Source

pub fn index(&'a self, i: usize) -> Atomic<'a, T>

Get a reference to the data inside the Atomic struct. This is unsafe because the user must ensure that no other thread is accessing the data at the same time.

Source§

impl<'a, T: ?Sized> Atomic<'a, T>

Atomic read-modify-write operation with kind defined in MLIR memref::atomic_rmw

Source

pub fn new(data: GpuGlobal<'a, T>) -> Atomic<'a, T>

Source

pub fn atomic_rmw<K: AtomicRMWKind>(&self, val: T) -> T
where T: Num,

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_addf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::AddF]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_addi(&self, val: T) -> T
where T: PrimInt,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::AddI]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_assign(&self, val: T) -> T
where T: Num,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::Assign]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_maximumf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MaximumF]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_maxs(&self, val: T) -> T
where T: Signed,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MaxS]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_maxu(&self, val: T) -> T
where T: Unsigned,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MaxU]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_minimumf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MinimumF]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_mins(&self, val: T) -> T
where T: Signed,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MinS]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_minu(&self, val: T) -> T
where T: Unsigned,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MinU]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_mulf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MulF]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_muli(&self, val: T) -> T
where T: PrimInt,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MulI]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_ori(&self, val: T) -> T
where T: PrimInt,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::OrI]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_andi(&self, val: T) -> T
where T: PrimInt,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::AndI]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_maxnumf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MaxNumF]>

Source§

impl<'a, T: Num> Atomic<'a, T>

Source

pub fn atomic_minnumf(&self, val: T) -> T
where T: Float,

Equivalent to: atomic_rmw::<[Atomic<'a, T>::MinNumF]>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Atomic<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for Atomic<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for Atomic<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Sync for Atomic<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for Atomic<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for Atomic<'a, T>
where T: RefUnwindSafe + ?Sized,

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HostToDev<T> for T

Source§

fn convert(self) -> T

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