Skip to main content

Atomic

Struct Atomic 

Source
pub struct Atomic<Inner: CubePrimitive> {
    pub val: Inner,
}
Expand description

An atomic numerical type wrapping a normal numeric primitive. Enables the use of atomic operations, while disabling normal operations. In WGSL, this is a separate type - on CUDA/SPIR-V it can theoretically be bitcast to a normal number, but this isn’t recommended.

Fields§

§val: Inner

Implementations§

Source§

impl<Inner: CubePrimitive<Scalar: Numeric>> Atomic<Inner>

Source

pub fn load(&self) -> Inner

Load the value of the atomic.

Source

pub fn store(&self, value: Inner)

Store the value of the atomic.

Source

pub fn swap(&self, value: Inner) -> Inner

Atomically stores the value into the atomic and returns the old value.

Source

pub fn fetch_add(&self, value: Inner) -> Inner

Atomically add a number to the atomic variable. Returns the old value.

Source

pub fn fetch_sub(&self, value: Inner) -> Inner

Atomically subtracts a number from the atomic variable. Returns the old value.

Source

pub fn fetch_max(&self, value: Inner) -> Inner

Atomically sets the value of the atomic variable to max(current_value, value). Returns the old value.

Source

pub fn fetch_min(&self, value: Inner) -> Inner

Atomically sets the value of the atomic variable to min(current_value, value). Returns the old value.

Source

pub fn __expand_load( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Load the value of the atomic.

Source

pub fn __expand_store( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, )

Store the value of the atomic.

Source

pub fn __expand_swap( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Atomically stores the value into the atomic and returns the old value.

Source

pub fn __expand_fetch_add( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Atomically add a number to the atomic variable. Returns the old value.

Source

pub fn __expand_fetch_sub( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Atomically subtracts a number from the atomic variable. Returns the old value.

Source

pub fn __expand_fetch_max( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Atomically sets the value of the atomic variable to max(current_value, value). Returns the old value.

Source

pub fn __expand_fetch_min( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Atomically sets the value of the atomic variable to min(current_value, value). Returns the old value.

Source§

impl<Inner: CubePrimitive<Scalar: Int>> Atomic<Inner>

Source

pub fn compare_exchange_weak(&self, cmp: Inner, value: Inner) -> Inner

Compare the value at pointer to cmp and set it to value only if they are the same. Returns the old value of the pointer before the store.

§Tip

Compare the returned value to cmp to determine whether the store was successful.

Source

pub fn fetch_and(&self, value: Inner) -> Inner

Executes an atomic bitwise and operation on the atomic variable. Returns the old value.

Source

pub fn fetch_or(&self, value: Inner) -> Inner

Executes an atomic bitwise or operation on the atomic variable. Returns the old value.

Source

pub fn fetch_xor(&self, value: Inner) -> Inner

Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.

Source

pub fn __expand_compare_exchange_weak( scope: &Scope, this: &<Self as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Compare the value at pointer to cmp and set it to value only if they are the same. Returns the old value of the pointer before the store.

§Tip

Compare the returned value to cmp to determine whether the store was successful.

Source

pub fn __expand_fetch_and( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Executes an atomic bitwise and operation on the atomic variable. Returns the old value.

Source

pub fn __expand_fetch_or( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Executes an atomic bitwise or operation on the atomic variable. Returns the old value.

Source

pub fn __expand_fetch_xor( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.

Trait Implementations§

Source§

impl<Inner: Clone + CubePrimitive> Clone for Atomic<Inner>

Source§

fn clone(&self) -> Atomic<Inner>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Inner: Copy + CubePrimitive> Copy for Atomic<Inner>

Source§

impl<Inner: CubePrimitive> CubeDebug for Atomic<Inner>

Source§

fn set_debug_name(&self, scope: &Scope, name: &'static str)

Set the debug name of this type’s expansion. Should do nothing for types that don’t appear at runtime
Source§

impl<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>

Source§

type Scalar = <Inner as CubePrimitive>::Scalar

Source§

type Size = Const<1>

Source§

type WithScalar<S: Scalar> = Atomic<S>

Source§

fn as_type_native() -> Option<Type>

Native or static element type.
Source§

fn __expand_as_type(scope: &Scope) -> Type

Source§

fn as_type_native_unchecked() -> Type

Native or static element type.
Source§

fn size() -> Option<usize>

Only native element types have a size.
Source§

fn from_expand_elem(elem: Value) -> Self::ExpandType

Source§

fn from_const_value(_value: ConstantValue) -> Self

Source§

fn as_type() -> Type

Return the element type to use on GPU.
Source§

fn size_bits() -> Option<usize>

Only native element types have a size.
Source§

fn size_bits_unchecked() -> usize

Only native element types have a size.
Source§

fn into_lit_unchecked(self) -> Self

Source§

fn supported_uses<R: Runtime>(client: &ComputeClient<R>) -> EnumSet<TypeUsage>

Source§

fn type_size() -> usize

Source§

fn type_size_bits() -> usize

Source§

fn packing_factor() -> usize

Source§

fn vector_size() -> usize

Source§

fn __expand_type_size(scope: &Scope) -> usize

Source§

fn __expand_type_size_bits(scope: &Scope) -> usize

Source§

fn __expand_packing_factor(scope: &Scope) -> usize

Source§

fn __expand_vector_size(scope: &Scope) -> usize

Source§

impl<Inner: CubePrimitive> CubeType for Atomic<Inner>

Source§

impl<Inner: Eq + CubePrimitive> Eq for Atomic<Inner>

Source§

impl<Inner: Hash + CubePrimitive> Hash for Atomic<Inner>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Inner: CubePrimitive> NativeAssign for Atomic<Inner>

Source§

fn elem_init_mut(scope: &Scope, elem: Value) -> Value

Source§

impl<Inner: PartialEq + CubePrimitive> PartialEq for Atomic<Inner>

Source§

fn eq(&self, other: &Atomic<Inner>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Inner: PartialEq + CubePrimitive> StructuralPartialEq for Atomic<Inner>

Auto Trait Implementations§

§

impl<Inner> Freeze for Atomic<Inner>
where Inner: Freeze,

§

impl<Inner> RefUnwindSafe for Atomic<Inner>
where Inner: RefUnwindSafe,

§

impl<Inner> Send for Atomic<Inner>

§

impl<Inner> Sync for Atomic<Inner>

§

impl<Inner> Unpin for Atomic<Inner>
where Inner: Unpin,

§

impl<Inner> UnsafeUnpin for Atomic<Inner>
where Inner: UnsafeUnpin,

§

impl<Inner> UnwindSafe for Atomic<Inner>
where Inner: UnwindSafe,

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> Assign for T
where T: CubePrimitive,

Source§

fn __expand_assign_method(&mut self, _scope: &Scope, value: T)

Assign value to self in scope.
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<P> Cast for P
where P: CubePrimitive,

Source§

fn cast_from<From>(_value: From) -> P
where From: CubePrimitive,

Source§

fn __expand_cast_from<From: CubePrimitive>( scope: &Scope, value: NativeExpand<From>, ) -> <Self as CubeType>::ExpandType

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneExpand for T
where T: Clone,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> NativeCubeType for T
where T: CubeType<ExpandType = NativeExpand<T>> + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P> Reinterpret for P
where P: CubePrimitive,

Source§

fn reinterpret<From: CubePrimitive>(value: From) -> Self

Reinterpret the bits of another primitive as this primitive without conversion.
Source§

fn reinterpret_vectorization<From: CubePrimitive>() -> usize

Calculates the expected vectorization for the reinterpret target
Source§

fn __expand_reinterpret<From: CubePrimitive>( scope: &Scope, value: NativeExpand<From>, ) -> <Self as CubeType>::ExpandType

Source§

fn __expand_reinterpret_vectorization<From: CubePrimitive>( scope: &Scope, ) -> usize

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

impl<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.