@@ -412,49 +412,52 @@ static inline void opal_atomic_add(type *addr, type delta);
412412
413413#endif /* !OPAL_C_HAVE__ATOMIC */
414414
415- /****** load-linked, store-conditional atomic implementations ******/
416415
417- /* C11 atomics do not expose the low-level load-linked, store-conditional
418- * instructions. Open MPI can use these instructions to implement a more
419- * efficient version of the lock-free lifo and fifo. On Apple Silicon the
420- * LL/SC fifo and lifo are ~ 2-20x faster than the CAS128 implementation. */
421- #if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
422- # include "opal/sys/arm64/atomic_llsc.h"
423- #endif
416+ /**********************************************************************
417+ *
418+ * Load-linked, Store Conditional
419+ *
420+ * Optional. Check OPAL_HAVE_ATOMIC_LLSC_32,
421+ * OPAL_HAVE_ATOMIC_LLSC_64, or OPAL_HAVE_ATOMIC_LLSC_PTR before
422+ * using. Implemented as macros due to function call behaviors;
423+ * prototyped here as C++-style fuctions for readability.
424+ *
425+ * C11 and GCC built-in atomics don't provide native LL/SC support, so
426+ * if there is an architectual implementation, we use it even if
427+ * we are using the C11 or GCC built-in atomics.
428+ *
429+ *********************************************************************/
424430
425- #if !defined(OPAL_HAVE_ATOMIC_LLSC_32 )
426- # define OPAL_HAVE_ATOMIC_LLSC_32 0
427- #endif
431+ #ifdef DOXYGEN
428432
429- #if !defined(OPAL_HAVE_ATOMIC_LLSC_64 )
430- # define OPAL_HAVE_ATOMIC_LLSC_64 0
431- #endif
432-
433- #if (OPAL_HAVE_ATOMIC_LLSC_32 || OPAL_HAVE_ATOMIC_LLSC_64 )
433+ static inline void opal_atomic_ll_32 (opal_atomic_int32_t * addr , int32_t & ret );
434434
435- # if SIZEOF_VOID_P == 4 && OPAL_HAVE_ATOMIC_LLSC_32
435+ static inline void opal_atomic_sc_32 ( opal_atomic_int32_t * addr , int32_t newval , int & ret );
436436
437- # define opal_atomic_ll_ptr (addr , ret ) opal_atomic_ll_32((opal_atomic_int32_t *) (addr), ret)
438- # define opal_atomic_sc_ptr (addr , value , ret ) \
439- opal_atomic_sc_32((opal_atomic_int32_t *) (addr), (intptr_t)(value), ret)
437+ static inline void opal_atomic_ll_64 (opal_atomic_int64_t * addr , int64_t & ret );
440438
441- # define OPAL_HAVE_ATOMIC_LLSC_PTR 1
439+ static inline void opal_atomic_sc_64 ( opal_atomic_int64_t * addr , int64_t newval , int & ret );
442440
443- # elif SIZEOF_VOID_P == 8 && OPAL_HAVE_ATOMIC_LLSC_64
441+ static inline void opal_atomic_ll_ptr ( opal_atomic_intptr_t * addr , intptr_t & ret );
444442
445- # define opal_atomic_ll_ptr (addr , ret ) opal_atomic_ll_64((opal_atomic_int64_t *) (addr), ret)
446- # define opal_atomic_sc_ptr (addr , value , ret ) \
447- opal_atomic_sc_64((opal_atomic_int64_t *) (addr), (intptr_t)(value), ret)
443+ static inline void opal_atomic_sc_ptr (opal_atomic_intptr_t * addr , intptr_t newval , int & ret );
448444
449- # define OPAL_HAVE_ATOMIC_LLSC_PTR 1
445+ #endif
450446
451- # endif
447+ #if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
448+ # include "opal/sys/arm64/atomic_llsc.h"
449+ #elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
450+ # include "opal/sys/powerpc/atomic_llsc.h"
451+ #endif
452452
453- #else
453+ #if !defined(OPAL_HAVE_ATOMIC_LLSC_32 )
454+ # define OPAL_HAVE_ATOMIC_LLSC_32 0
455+ #endif
454456
455- # define OPAL_HAVE_ATOMIC_LLSC_PTR 0
457+ #if !defined(OPAL_HAVE_ATOMIC_LLSC_64 )
458+ # define OPAL_HAVE_ATOMIC_LLSC_64 0
459+ #endif
456460
457- #endif /* (OPAL_HAVE_ATOMIC_LLSC_32 || OPAL_HAVE_ATOMIC_LLSC_64)*/
458461
459462END_C_DECLS
460463
0 commit comments