Correct the assembly using xaddl for IA32.
Add atomic functions for add and sub 32 and 64 bits for AMD64. This commit was SVN r24453.
Этот коммит содержится в:
родитель
eb8383802e
Коммит
f79c87f0c3
@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* Copyright (c) 2004-2010 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
@ -44,7 +44,6 @@
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_CMPSET_64 1
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* Memory Barriers
|
||||
@ -120,4 +119,95 @@ static inline int opal_atomic_cmpset_64( volatile int64_t *addr,
|
||||
#define opal_atomic_cmpset_acq_64 opal_atomic_cmpset_64
|
||||
#define opal_atomic_cmpset_rel_64 opal_atomic_cmpset_64
|
||||
|
||||
#if OMPI_GCC_INLINE_ASSEMBLY
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_MATH_32 1
|
||||
#define OPAL_HAVE_ATOMIC_MATH_64 1
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_ADD_32 1
|
||||
|
||||
/**
|
||||
* atomic_add - add integer to atomic variable
|
||||
* @i: integer value to add
|
||||
* @v: pointer of type int
|
||||
*
|
||||
* Atomically adds @i to @v.
|
||||
*/
|
||||
static inline int32_t opal_atomic_add_32(volatile int32_t* v, int i)
|
||||
{
|
||||
int ret = i;
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddl %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret+i);
|
||||
}
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_ADD_64 1
|
||||
|
||||
/**
|
||||
* atomic_add - add integer to atomic variable
|
||||
* @i: integer value to add
|
||||
* @v: pointer of type int
|
||||
*
|
||||
* Atomically adds @i to @v.
|
||||
*/
|
||||
static inline int64_t opal_atomic_add_64(volatile int64_t* v, int64_t i)
|
||||
{
|
||||
int64_t ret = i;
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddq %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret+i);
|
||||
}
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_SUB_32 1
|
||||
|
||||
/**
|
||||
* atomic_sub - subtract the atomic variable
|
||||
* @i: integer value to subtract
|
||||
* @v: pointer of type int
|
||||
*
|
||||
* Atomically subtracts @i from @v.
|
||||
*/
|
||||
static inline int32_t opal_atomic_sub_32(volatile int32_t* v, int i)
|
||||
{
|
||||
int ret = -i;
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddl %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret-i);
|
||||
}
|
||||
|
||||
#define OPAL_HAVE_ATOMIC_SUB_64 1
|
||||
|
||||
/**
|
||||
* atomic_sub - subtract the atomic variable
|
||||
* @i: integer value to subtract
|
||||
* @v: pointer of type int
|
||||
*
|
||||
* Atomically subtracts @i from @v.
|
||||
*/
|
||||
static inline int64_t opal_atomic_sub_64(volatile int64_t* v, int64_t i)
|
||||
{
|
||||
int64_t ret = -i;
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddq %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret-i);
|
||||
}
|
||||
|
||||
#endif /* OMPI_GCC_INLINE_ASSEMBLY */
|
||||
|
||||
#endif /* ! OMPI_SYS_ARCH_ATOMIC_H */
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
* University Research and Technology
|
||||
* Corporation. All rights reserved.
|
||||
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
||||
* Copyright (c) 2004-2010 The University of Tennessee and The University
|
||||
* of Tennessee Research Foundation. All rights
|
||||
* reserved.
|
||||
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
||||
@ -168,6 +168,8 @@ static inline int32_t opal_atomic_add_32(volatile int32_t* v, int i)
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddl %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret+i);
|
||||
}
|
||||
@ -186,6 +188,8 @@ static inline int32_t opal_atomic_sub_32(volatile int32_t* v, int i)
|
||||
__asm__ __volatile__(
|
||||
SMPLOCK "xaddl %1,%0"
|
||||
:"=m" (*v), "+r" (ret)
|
||||
:"m" (*v)
|
||||
:"memory", "cc"
|
||||
);
|
||||
return (ret-i);
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user