|
OpenMPI
0.1.1
|
Atomic operations. More...
#include "opal_config.h"#include "opal/sys/architecture.h"#include "opal/sys/atomic_impl.h"Go to the source code of this file.
Data Structures | |
| struct | opal_atomic_lock_t |
| Volatile lock object (with optional padding). More... | |
Macros | |
| #define | OMPI_GCC_INLINE_ASSEMBLY OPAL_C_GCC_INLINE_ASSEMBLY |
| #define | OMPI_DEC_INLINE_ASSEMBLY OPAL_C_DEC_INLINE_ASSEMBLY |
| #define | OMPI_XLC_INLINE_ASSEMBLY OPAL_C_XLC_INLINE_ASSEMBLY |
| #define | OPAL_HAVE_INLINE_ATOMIC_MEM_BARRIER 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_CMPSET_32 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_CMPSET_64 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_ADD_32 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_SUB_32 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_ADD_64 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_SUB_64 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_SWAP_32 0 |
| #define | OPAL_HAVE_INLINE_ATOMIC_SWAP_64 0 |
| #define | OPAL_HAVE_ATOMIC_SPINLOCKS (OPAL_HAVE_ATOMIC_CMPSET_32 || OPAL_HAVE_ATOMIC_CMPSET_64) |
| #define | OPAL_NEED_INLINE_ATOMIC_SPINLOCKS |
| #define | OPAL_HAVE_ATOMIC_MATH_32 OPAL_HAVE_ATOMIC_CMPSET_32 |
| #define | OPAL_HAVE_ATOMIC_MATH_64 0 |
| #define | OPAL_HAVE_ATOMIC_MATH_64 OPAL_HAVE_ATOMIC_CMPSET_64 |
| #define | opal_atomic_cmpset(ADDR, OLDVAL, NEWVAL) |
| Atomic compare and set of pointer with relaxed semantics. More... | |
| #define | opal_atomic_cmpset_acq(ADDR, OLDVAL, NEWVAL) |
| Atomic compare and set of pointer with acquire semantics. More... | |
| #define | opal_atomic_cmpset_rel(ADDR, OLDVAL, NEWVAL) |
| Atomic compare and set of pointer with release semantics. More... | |
| #define | opal_atomic_add(ADDR, VALUE) |
| Atomically increment the content depending on the type. More... | |
| #define | opal_atomic_sub(ADDR, VALUE) |
| Atomically decrement the content depending on the type. More... | |
Typedefs | |
| typedef struct opal_atomic_lock_t | opal_atomic_lock_t |
Enumerations | |
| enum | { OPAL_ATOMIC_UNLOCKED = 0, OPAL_ATOMIC_LOCKED = 1 } |
| Enumeration of lock states. | |
Functions | |
| void | opal_atomic_mb (void) |
| Memory barrier. More... | |
| void | opal_atomic_rmb (void) |
| Read memory barrier. More... | |
| void | opal_atomic_wmb (void) |
| Write memory barrier. More... | |
| static void | opal_atomic_init (opal_atomic_lock_t *lock, int32_t value) |
| Initialize a lock to value. More... | |
| static int | opal_atomic_trylock (opal_atomic_lock_t *lock) |
| Try to acquire a lock. More... | |
| static void | opal_atomic_lock (opal_atomic_lock_t *lock) |
| Acquire a lock by spinning. More... | |
| static void | opal_atomic_unlock (opal_atomic_lock_t *lock) |
| Release a lock. More... | |
| int | opal_atomic_cmpset_32 (volatile int32_t *addr, int32_t oldval, int32_t newval) |
| int | opal_atomic_cmpset_acq_32 (volatile int32_t *addr, int32_t oldval, int32_t newval) |
| int | opal_atomic_cmpset_rel_32 (volatile int32_t *addr, int32_t oldval, int32_t newval) |
| int | opal_atomic_cmpset_64 (volatile int64_t *addr, int64_t oldval, int64_t newval) |
| int | opal_atomic_cmpset_acq_64 (volatile int64_t *addr, int64_t oldval, int64_t newval) |
| int | opal_atomic_cmpset_rel_64 (volatile int64_t *addr, int64_t oldval, int64_t newval) |
| int32_t | opal_atomic_add_32 (volatile int32_t *addr, int delta) |
| int32_t | opal_atomic_sub_32 (volatile int32_t *addr, int delta) |
| int64_t | opal_atomic_add_64 (volatile int64_t *addr, int64_t delta) |
| int64_t | opal_atomic_sub_64 (volatile int64_t *addr, int64_t delta) |
| static size_t | opal_atomic_add_size_t (volatile size_t *addr, int delta) |
| static size_t | opal_atomic_sub_size_t (volatile size_t *addr, int delta) |
| static int | opal_atomic_cmpset_xx (volatile void *addr, int64_t oldval, int64_t newval, size_t length) |
| static int | opal_atomic_cmpset_acq_xx (volatile void *addr, int64_t oldval, int64_t newval, size_t length) |
| static int | opal_atomic_cmpset_rel_xx (volatile void *addr, int64_t oldval, int64_t newval, size_t length) |
| static int | opal_atomic_cmpset_ptr (volatile void *addr, void *oldval, void *newval) |
| static int | opal_atomic_cmpset_acq_ptr (volatile void *addr, void *oldval, void *newval) |
| static int | opal_atomic_cmpset_rel_ptr (volatile void *addr, void *oldval, void *newval) |
| static void | opal_atomic_add_xx (volatile void *addr, int32_t value, size_t length) |
| static void | opal_atomic_sub_xx (volatile void *addr, int32_t value, size_t length) |
Atomic operations.
This API is patterned after the FreeBSD kernel atomic interface (which is influenced by Intel's ia64 architecture). The FreeBSD interface is documented at
http://www.freebsd.org/cgi/man.cgi?query=atomic&sektion=9
Only the necessary subset of functions are implemented here.
The following #defines will be true / false based on assembly support:
OPAL_HAVE_ATOMIC_MEM_BARRIER atomic memory barriersOPAL_HAVE_ATOMIC_SPINLOCKS atomic spinlocksOPAL_HAVE_ATOMIC_MATH_32 if 32 bit add/sub/cmpset can be done "atomicly"OPAL_HAVE_ATOMIC_MATH_64 if 32 bit add/sub/cmpset can be done "atomicly"Note that for the Atomic math, atomic add/sub may be implemented as C code using opal_atomic_cmpset. The appearance of atomic operation will be upheld in these cases.
| #define opal_atomic_add | ( | ADDR, | |
| VALUE | |||
| ) |
Atomically increment the content depending on the type.
This macro detect at compile time the type of the first argument and choose the correct function to be called.
| addr | Address of <TYPE> |
| delta | Value to add (converted to <TYPE>). |
Referenced by mca_coll_sm_barrier_intra(), opal_list_insert(), and opal_progress().
| #define opal_atomic_cmpset | ( | ADDR, | |
| OLDVAL, | |||
| NEWVAL | |||
| ) |
Atomic compare and set of pointer with relaxed semantics.
This macro detect at compile time the type of the first argument and choose the correct function to be called.
| addr | Address of <TYPE>. |
| oldval | Comparison value <TYPE>. |
| newval | New value to set if comparision is true <TYPE>. |
See opal_atomic_cmpset_* for pseudo-code.
| #define opal_atomic_cmpset_acq | ( | ADDR, | |
| OLDVAL, | |||
| NEWVAL | |||
| ) |
Atomic compare and set of pointer with acquire semantics.
This macro detect at compile time the type of the first argument and choose the correct function to be called.
| addr | Address of <TYPE>. |
| oldval | Comparison value <TYPE>. |
| newval | New value to set if comparision is true <TYPE>. |
See opal_atomic_cmpset_acq_* for pseudo-code.
| #define opal_atomic_cmpset_rel | ( | ADDR, | |
| OLDVAL, | |||
| NEWVAL | |||
| ) |
Atomic compare and set of pointer with release semantics.
This macro detect at compile time the type of the first argument and choose the correct function to b
| addr | Address of <TYPE>. |
| oldval | Comparison value <TYPE>. |
| newval | New value to set if comparision is true <TYPE>. |
See opal_atomic_cmpsetrel_* for pseudo-code.
| #define opal_atomic_sub | ( | ADDR, | |
| VALUE | |||
| ) |
Atomically decrement the content depending on the type.
This macro detect at compile time the type of the first argument and choose the correct function to be called.
| addr | Address of <TYPE> |
| delta | Value to substract (converted to <TYPE>). |
|
inlinestatic |
Initialize a lock to value.
| lock | Address of the lock |
| value | Initial value to set lock to |
Referenced by opal_progress_init(), and orte_locks_init().
|
inlinestatic |
Acquire a lock by spinning.
| lock | Address of the lock. |
Referenced by mca_btl_sm_component_progress(), mca_btl_smcuda_component_progress(), opal_class_initialize(), opal_progress_finalize(), opal_progress_register(), and opal_progress_unregister().
| void opal_atomic_mb | ( | void | ) |
Memory barrier.
Will use system-specific features to instruct the processor and memory controller that all writes and reads that have been posted before the call to opal_atomic_mb() must appear to have completed before the next read or write.
| void opal_atomic_rmb | ( | void | ) |
Read memory barrier.
Use system-specific features to instruct the processor and memory conrtoller that all reads that have been posted before the call to opal_atomic_rmb() must appear to have been completed before the next read. Nothing is said about the ordering of writes when using opal_atomic_rmb().
Referenced by mca_btl_sm_add_procs(), mca_btl_smcuda_add_procs(), and mca_mpool_grdma_evict().
|
inlinestatic |
Try to acquire a lock.
| lock | Address of the lock. |
Referenced by orte_finalize().
|
inlinestatic |
Release a lock.
| lock | Address of the lock. |
Referenced by mca_btl_sm_component_progress(), mca_btl_smcuda_component_progress(), opal_class_initialize(), opal_progress_finalize(), opal_progress_register(), and opal_progress_unregister().
| void opal_atomic_wmb | ( | void | ) |
Write memory barrier.
Use system-specific features to instruct the processor and memory conrtoller that all writes that have been posted before the call to opal_atomic_wmb() must appear to have been completed before the next write. Nothing is said about the ordering of reads when using opal_atomic_wmb().
Referenced by mca_btl_sm_add_procs(), mca_btl_smcuda_add_procs(), mca_coll_sm_bcast_intra(), and mca_mpool_grdma_evict().