2005-02-14 21:04:23 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-02-14 21:04:23 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2005-02-14 21:04:23 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2005-02-14 21:04:23 +03:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/sys/atomic.h"
|
|
|
|
#include "opal/sys/architecture.h"
|
2005-02-14 21:04:23 +03:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#if OPAL_ASSEMBLY_ARCH == OMPI_SPARC
|
2005-02-14 21:04:23 +03:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#if OPAL_WANT_SMP_LOCKS
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
#define LOCKS_TABLE_SIZE 8
|
|
|
|
/* make sure to get into reasonably useful bits (so shift at least 5) */
|
|
|
|
#define FIND_LOCK(addr) (&(locks_table[(((unsigned long) addr) >> 8) & \
|
|
|
|
(LOCKS_TABLE_SIZE - 1)]))
|
|
|
|
|
|
|
|
/* have to fix if you change LOCKS_TABLE_SIZE */
|
2005-07-04 01:38:51 +04:00
|
|
|
static opal_atomic_lock_t locks_table[LOCKS_TABLE_SIZE] = {
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } },
|
|
|
|
{ { OPAL_ATOMIC_UNLOCKED } }
|
2005-02-14 21:04:23 +03:00
|
|
|
};
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
# else /* OPAL_WANT_SMP_LOCKS */
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
#define LOCKS_TABLE_SIZE 1
|
|
|
|
#define FIND_LOCK(addr) (&(locks_table[0]))
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
static opal_atomic_lock_t locks_table[1] = { OPAL_ATOMIC_UNLOCKED };
|
2005-02-14 21:04:23 +03:00
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#endif /* OPAL_WANT_SMP_LOCKS */
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
int32_t
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_add_32(volatile int32_t *addr, int delta)
|
2005-02-14 21:04:23 +03:00
|
|
|
{
|
|
|
|
int32_t ret;
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock(FIND_LOCK(addr));
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
ret = (*addr += delta);
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(FIND_LOCK(addr));
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_sub_32(volatile int32_t *addr, int delta)
|
2005-02-14 21:04:23 +03:00
|
|
|
{
|
|
|
|
int32_t ret;
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_lock(FIND_LOCK(addr));
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
ret = (*addr -= delta);
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_unlock(FIND_LOCK(addr));
|
2005-02-14 21:04:23 +03:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#endif /* OPAL_ASSEMBLY_ARCH == OMPI_SPARC32 */
|