numba_dpex.kernel_api.atomic_ref¶
Implements a mock Python class to represent sycl::atomic_ref
for
prototyping numba_dpex kernel functions before they are JIT compiled.
Overview¶
Analogue to the sycl::atomic_ref class. |
Classes¶
- class AtomicRef(ref, index, memory_order=MemoryOrder.RELAXED, memory_scope=MemoryScope.DEVICE, address_space=None)¶
Analogue to the sycl::atomic_ref class.
An atomic reference is a view into a data container that can be then updated atomically using any of the
fetch_*
member functions of the class.Overview
¶ fetch_add
(val)Adds the operand
val
to the object referenced by the AtomicReffetch_sub
(val)Subtracts the operand
val
to the object referenced by thefetch_min
(val)Calculates the minimum value of the operand
val
and the objectfetch_max
(val)Calculates the maximum value of the operand
val
and the objectfetch_and
(val)Calculates the bitwise AND of the operand
val
and the objectfetch_or
(val)Calculates the bitwise OR of the operand
val
and the objectfetch_xor
(val)Calculates the bitwise XOR of the operand
val
and the objectload
()Loads the value of the object referenced by the AtomicRef.
store
(val)Stores operand
val
to the object referenced by the AtomicRef.exchange
(val)Replaces the value of the object referenced by the AtomicRef
compare_exchange
(expected, desired, expected_idx)Compares the value of the object referenced by the AtomicRef
Members
- fetch_add(val)¶
Adds the operand
val
to the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be added to the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_sub(val)¶
Subtracts the operand
val
to the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be subtracted from the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_min(val)¶
Calculates the minimum value of the operand
val
and the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be compared against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_max(val)¶
Calculates the maximum value of the operand
val
and the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be compared against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_and(val)¶
Calculates the bitwise AND of the operand
val
and the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be bitwise ANDed against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_or(val)¶
Calculates the bitwise OR of the operand
val
and the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be bitwise ORed against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- fetch_xor(val)¶
Calculates the bitwise XOR of the operand
val
and the object referenced by the AtomicRef and assigns the result to the value of the referenced object. Returns the original value of the object.- Parameters:
val – Value to be bitwise XORed against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- load()¶
Loads the value of the object referenced by the AtomicRef.
Returns: The value of the object referenced by the AtomicRef.
- store(val)¶
Stores operand
val
to the object referenced by the AtomicRef.- Parameters:
val – Value to be stored in the object referenced by the AtomicRef.
- exchange(val)¶
Replaces the value of the object referenced by the AtomicRef with value of
val
. Returns the original value of the referenced object.- Parameters:
val – Value to be exchanged against the object referenced by the AtomicRef.
Returns: The original value of the object referenced by the AtomicRef.
- compare_exchange(expected, desired, expected_idx=0)¶
Compares the value of the object referenced by the AtomicRef against the value of
expected[expected_idx]
. If the values are equal, replaces the value of the referenced object with the value ofdesired
. Otherwise assigns the original value of the referenced object toexpected[expected_idx]
.- Parameters:
expected – Array containing the expected value of the object referenced by the AtomicRef.
desired – Value that replaces the value of the object referenced by the AtomicRef.
expected_idx – Offset in expected array where the expected
present. (value of the object referenced by the AtomicRef is)
- Returns:
True
if the comparison operation and replacement operation were successful.