Trait cubecl_core::frontend::Atomic
source · pub trait Atomic: Sized + CubeTypewhere
ExpandElement: From<<Self::Primitive as CubeType>::ExpandType> + From<<Self as CubeType>::ExpandType>,{
type Primitive: Numeric;
Show 22 methods
// Provided methods
fn load(pointer: &Self) -> Self::Primitive { ... }
fn store(pointer: &Self, value: Self::Primitive) { ... }
fn swap(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn compare_and_swap(
pointer: &Self,
cmp: Self::Primitive,
value: Self::Primitive,
) -> Self::Primitive { ... }
fn add(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn sub(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn max(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn min(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn and(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn or(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn xor(pointer: &Self, value: Self::Primitive) -> Self::Primitive { ... }
fn __expand_load(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_store(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) { ... }
fn __expand_swap(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_compare_and_swap(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
cmp: <Self::Primitive as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_add(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_sub(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_max(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_min(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_and(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_or(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
fn __expand_xor(
context: &mut CubeContext,
pointer: <Self as CubeType>::ExpandType,
value: <Self::Primitive as CubeType>::ExpandType,
) -> <Self::Primitive as CubeType>::ExpandType { ... }
}
Expand description
An atomic type. Represents an shared value that can be operated on atomically.
Required Associated Types§
Provided Methods§
sourcefn swap(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn swap(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Atomically stores the value into the atomic and returns the old value.
sourcefn compare_and_swap(
pointer: &Self,
cmp: Self::Primitive,
value: Self::Primitive,
) -> Self::Primitive
fn compare_and_swap( pointer: &Self, cmp: Self::Primitive, value: Self::Primitive, ) -> Self::Primitive
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.
sourcefn add(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn add(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Atomically add a number to the atomic variable. Returns the old value.
sourcefn sub(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn sub(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Atomically subtracts a number from the atomic variable. Returns the old value.
sourcefn max(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn max(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Atomically sets the value of the atomic variable to max(current_value, value)
. Returns
the old value.
sourcefn min(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn min(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Atomically sets the value of the atomic variable to min(current_value, value)
. Returns the
old value.
sourcefn and(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn and(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Executes an atomic bitwise and operation on the atomic variable. Returns the old value.
sourcefn or(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn or(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Executes an atomic bitwise or operation on the atomic variable. Returns the old value.
sourcefn xor(pointer: &Self, value: Self::Primitive) -> Self::Primitive
fn xor(pointer: &Self, value: Self::Primitive) -> Self::Primitive
Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.