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: InnerImplementations§
Source§impl<Inner> Atomic<Inner>where
Inner: Numeric,
impl<Inner> Atomic<Inner>where
Inner: Numeric,
Sourcepub fn swap(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn swap(pointer: &Atomic<Inner>, value: Inner) -> Inner
Atomically stores the value into the atomic and returns the old value.
Sourcepub fn add(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn add(pointer: &Atomic<Inner>, value: Inner) -> Inner
Atomically add a number to the atomic variable. Returns the old value.
Sourcepub fn max(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn max(pointer: &Atomic<Inner>, value: Inner) -> Inner
Atomically sets the value of the atomic variable to max(current_value, value). Returns
the old value.
Sourcepub fn min(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn min(pointer: &Atomic<Inner>, value: Inner) -> Inner
Atomically sets the value of the atomic variable to min(current_value, value). Returns the
old value.
Sourcepub fn sub(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn sub(pointer: &Atomic<Inner>, value: Inner) -> Inner
Atomically subtracts a number from the atomic variable. Returns the old value.
pub fn __expand_load( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_store( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, )
pub fn __expand_swap( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_add( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_sub( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_max( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_min( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Source§impl<Inner> Atomic<Inner>where
Inner: Int,
impl<Inner> Atomic<Inner>where
Inner: Int,
Sourcepub fn compare_and_swap(
pointer: &Atomic<Inner>,
cmp: Inner,
value: Inner,
) -> Inner
pub fn compare_and_swap( pointer: &Atomic<Inner>, 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.
Sourcepub fn and(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn and(pointer: &Atomic<Inner>, value: Inner) -> Inner
Executes an atomic bitwise and operation on the atomic variable. Returns the old value.
Sourcepub fn or(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn or(pointer: &Atomic<Inner>, value: Inner) -> Inner
Executes an atomic bitwise or operation on the atomic variable. Returns the old value.
Sourcepub fn xor(pointer: &Atomic<Inner>, value: Inner) -> Inner
pub fn xor(pointer: &Atomic<Inner>, value: Inner) -> Inner
Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.
pub fn __expand_compare_and_swap( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_and( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_or( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_xor( scope: &mut Scope, pointer: <Atomic<Inner> as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Trait Implementations§
Source§impl<Inner> CubePrimitive for Atomic<Inner>where
Inner: CubePrimitive,
impl<Inner> CubePrimitive for Atomic<Inner>where
Inner: CubePrimitive,
Source§fn as_elem_native() -> Option<Elem>
fn as_elem_native() -> Option<Elem>
Source§fn as_elem_native_unchecked() -> Elem
fn as_elem_native_unchecked() -> Elem
fn from_expand_elem( elem: ExpandElement, ) -> <Atomic<Inner> as CubeType>::ExpandType
Source§fn min_line_size(&self) -> Option<u8>
fn min_line_size(&self) -> Option<u8>
fn is_supported<S, C>(client: &ComputeClient<S, C>) -> bool
fn elem_size() -> u32
fn elem_size_bits() -> u32
fn __expand_elem_size(scope: &Scope) -> u32
fn __expand_elem_size_bits(scope: &Scope) -> u32
Source§impl<Inner> CubeType for Atomic<Inner>where
Inner: CubePrimitive,
impl<Inner> CubeType for Atomic<Inner>where
Inner: CubePrimitive,
type ExpandType = ExpandElementTyped<Atomic<Inner>>
Source§fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
Source§impl<Inner> ExpandElementIntoMut for Atomic<Inner>where
Inner: CubePrimitive,
impl<Inner> ExpandElementIntoMut for Atomic<Inner>where
Inner: CubePrimitive,
fn elem_into_mut(scope: &mut Scope, elem: ExpandElement) -> ExpandElement
Source§impl<Inner> LaunchArgExpand for Atomic<Inner>where
Inner: CubePrimitive,
impl<Inner> LaunchArgExpand for Atomic<Inner>where
Inner: CubePrimitive,
Source§type CompilationArg = ()
type CompilationArg = ()
Source§fn expand(
_: &<Atomic<Inner> as LaunchArgExpand>::CompilationArg,
builder: &mut KernelBuilder,
) -> ExpandElementTyped<Atomic<Inner>>
fn expand( _: &<Atomic<Inner> as LaunchArgExpand>::CompilationArg, builder: &mut KernelBuilder, ) -> ExpandElementTyped<Atomic<Inner>>
Source§fn expand_output(
arg: &Self::CompilationArg,
builder: &mut KernelBuilder,
) -> Self::ExpandType
fn expand_output( arg: &Self::CompilationArg, builder: &mut KernelBuilder, ) -> Self::ExpandType
impl<Inner> Copy for Atomic<Inner>where
Inner: Copy + CubePrimitive,
impl<Inner> Eq for Atomic<Inner>where
Inner: Eq + CubePrimitive,
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> UnwindSafe for Atomic<Inner>where
Inner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<P> Cast for Pwhere
P: CubePrimitive,
impl<P> Cast for Pwhere
P: CubePrimitive,
fn cast_from<From>(_value: From) -> Pwhere
From: CubePrimitive,
fn __expand_cast_from<From>(
scope: &mut Scope,
value: ExpandElementTyped<From>,
) -> Self::ExpandTypewhere
From: CubePrimitive,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P> CubeDebug for Pwhere
P: CubePrimitive,
impl<P> CubeDebug for Pwhere
P: CubePrimitive,
Source§fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.