Atomic
Module
Implements the Atomic class.
Atomic
Represents a value with atomic operations.
The class provides atomic add
and sub
methods for mutating the value.
Parameters:
- _type (
DType
): DType of the value.
Aliases:
scalar_type = scalar<#lit.struct.extract<:@"$DType"::@DType _type, "value">>
type = _type
Fields:
value
The atomic value.
This is the underlying value of the atomic. Access to the value can only occur through atomic primitive operations.
Functions:
__init__
__init__(self: Self&, value: SIMD[_type, 1])
Construct a new atomic value.
Args:
- value (
SIMD[_type, 1]
): Initial value represented as SIMD[type, 1] type.
__init__(self: Self&, value: Int)
Construct a new atomic value.
Args:
- value (
Int
): Initial value represented as mlir.index type.
__init__(self: Self&, value: scalar<#lit.struct.extract<:_"$DType"::_DType _type, "value">>)
Construct a new atomic value.
Args:
- value (
scalar<#lit.struct.extract<:_"$DType"::_DType _type, "value">>
): Initial value represented as pop.scalartype.
__iadd__
__iadd__(self: Self&, rhs: SIMD[_type, 1])
Atomic in-place add.
Atomically replaces the current value with the result of arithmetic addition of the value and arg. That is, it performs atomic post-increment. The operation is a read-modify-write operation. Memory is affected according to the value of order which is sequentially consistent.
Args:
- rhs (
SIMD[_type, 1]
): Value to add.
__isub__
__isub__(self: Self&, rhs: SIMD[_type, 1])
Atomic in-place sub.
Atomically replaces the current value with the result of arithmetic subtraction of the value and arg. That is, it performs atomic post-decrement. The operation is a read-modify-write operation. Memory is affected according to the value of order which is sequentially consistent.
Args:
- rhs (
SIMD[_type, 1]
): Value to subtract.
fetch_add
fetch_add(self: Self&, rhs: SIMD[_type, 1]) -> Self
Atomic in-place add.
Atomically replaces the current value with the result of arithmetic addition of the value and arg. That is, it performs atomic post-increment. The operation is a read-modify-write operation. Memory is affected according to the value of order which is sequentially consistent.
Args:
- rhs (
SIMD[_type, 1]
): Value to add.
Returns:
The original value before addition.
fetch_sub
fetch_sub(self: Self&, rhs: SIMD[_type, 1]) -> Self
Atomic in-place sub.
Atomically replaces the current value with the result of arithmetic subtraction of the value and arg. That is, it performs atomic post-decrement. The operation is a read-modify-write operation. Memory is affected according to the value of order which is sequentially consistent.
Args:
- rhs (
SIMD[_type, 1]
): Value to subtract.
Returns:
The original value before subtraction.
max
max(self: Self&, rhs: SIMD[_type, 1])
Atomic in-place max.
Atomically replaces the current value with the result of max of the value and arg. The operation is a read-modify-write operation perform according to sequentiall consistency semantics.
Constraints:
The input type must be either integral or floating-point type.
Args:
- rhs (
SIMD[_type, 1]
): Value to max.
min
min(self: Self&, rhs: SIMD[_type, 1])
Atomic in-place min.
Atomically replaces the current value with the result of min of the value and arg. The operation is a read-modify-write operation. The operation is a read-modify-write operation perform according to sequentiall consistency semantics.
Constraints:
The input type must be either integral or floating-point type.
Args:
- rhs (
SIMD[_type, 1]
): Value to min.