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: Numeric> Atomic<Inner>

Source

pub fn load(pointer: &Self) -> Inner

Load the value of the atomic.

Source

pub fn store(pointer: &Self, value: Inner)

Store the value of the atomic.

Source

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

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

Source

pub fn add(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn max(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn min(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn sub(pointer: &Self, value: Inner) -> Inner

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

Source

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

Source

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

Source

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

Source

pub fn __expand_add( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_sub( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_max( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_min( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source§

impl<Inner: Int> Atomic<Inner>

Source

pub fn compare_and_swap(pointer: &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 and(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn or(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn xor(pointer: &Self, value: Inner) -> Inner

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

Source

pub fn __expand_compare_and_swap( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_and( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_or( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Source

pub fn __expand_xor( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType

Trait Implementations§

Source§

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

Source§

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

Returns a copy 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<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>

Source§

fn as_elem_native() -> Option<Elem>

Native or static element type.
Source§

fn as_elem(scope: &Scope) -> Elem

Return the element type to use on GPU.
Source§

fn as_elem_native_unchecked() -> Elem

Native or static element type.
Source§

fn size() -> Option<usize>

Only native element types have a size.
Source§

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

Source§

fn is_supported<S: ComputeServer<Feature = Feature>, C: ComputeChannel<S>>( client: &ComputeClient<S, C>, ) -> bool

Source§

fn elem_size() -> u32

Source§

fn __expand_elem_size(context: &Scope) -> u32

Source§

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

Source§

type ExpandType = ExpandElementTyped<Atomic<Inner>>

Source§

fn init(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType

Wrapper around the init method, necessary to type inference.
Source§

impl<Inner: CubePrimitive> ExpandElementBaseInit 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> LaunchArgExpand for Atomic<Inner>

Source§

type CompilationArg = ()

Compilation argument.
Source§

fn expand( _: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> ExpandElementTyped<Self>

Register an input variable during compilation that fill the KernelBuilder.
Source§

fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> <Self as CubeType>::ExpandType

Register an output variable during compilation that fill the KernelBuilder.
Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 + CubePrimitive> Copy for Atomic<Inner>

Source§

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

Source§

impl<Inner: 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> 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> 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: &mut Scope, value: ExpandElementTyped<From>, ) -> <Self as CubeType>::ExpandType

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

Checks if this value is equivalent to the given key. Read more
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<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 __expand_reinterpret<From: CubePrimitive>( scope: &mut Scope, value: ExpandElementTyped<From>, ) -> <Self as CubeType>::ExpandType

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V