Skip to main content

Atomic

Struct Atomic 

Source
pub struct Atomic<Inner>
where 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> Atomic<Inner>
where Inner: CubePrimitive, <Inner as CubePrimitive>::Scalar: Numeric,

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: &mut Scope, this: <Atomic<Inner> as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source§

impl<Inner> Atomic<Inner>
where Inner: CubePrimitive, <Inner as CubePrimitive>::Scalar: Int,

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: &mut Scope, this: <Atomic<Inner> as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

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

Source

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

Source

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

Trait Implementations§

Source§

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

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> CubePrimitive for Atomic<Inner>
where Inner: CubePrimitive,

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 as_type(scope: &Scope) -> Type

Return the element type to use on GPU.
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: ManagedVariable, ) -> <Atomic<Inner> as CubeType>::ExpandType

Source§

fn from_const_value(_value: ConstantValue) -> Atomic<Inner>

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>(client: &ComputeClient<R>) -> EnumSet<TypeUsage>
where R: Runtime,

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> CubeType for Atomic<Inner>
where Inner: CubePrimitive,

Source§

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

Source§

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

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> NativeAssign for Atomic<Inner>
where Inner: CubePrimitive,

Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

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

Source§

impl<Inner> StructuralPartialEq for Atomic<Inner>
where Inner: CubePrimitive,

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(&mut self, _scope: &mut Scope, value: T)

Assign value to self in scope.
Source§

fn init_mut(&self, _scope: &mut Scope) -> T

Create a new mutable variable of this type 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>( scope: &mut Scope, value: NativeExpand<From>, ) -> Self::ExpandType
where From: CubePrimitive,

Source§

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

Source§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

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<P> CubeDebug for P
where P: CubePrimitive,

Source§

fn set_debug_name(&self, scope: &mut 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<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<P> Reinterpret for P
where P: CubePrimitive,

Source§

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

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

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

Calculates the expected vectorization for the reinterpret target
Source§

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

Source§

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

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.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,