1
1
openmpi/oshmem/mca/atomic/basic/atomic_basic_cswap.c
Sergey Oblomov 5eb8c99cd7 ATOMIC/UCX: optimization for cswap
- used uint64_t output datatype to avoid branches in
  implementations

Signed-off-by: Sergey Oblomov <sergeyo@mellanox.com>
2018-07-04 14:41:46 +03:00

49 строки
1.1 KiB
C

/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "oshmem_config.h"
#include <stdio.h>
#include <stdlib.h>
#include "oshmem/constants.h"
#include "oshmem/mca/spml/spml.h"
#include "oshmem/mca/atomic/atomic.h"
#include "oshmem/mca/atomic/base/base.h"
#include "atomic_basic.h"
int mca_atomic_basic_cswap(void *target,
uint64_t *prev,
uint64_t cond,
uint64_t value,
size_t nlong,
int pe)
{
int rc = OSHMEM_SUCCESS;
if (!prev) {
rc = OSHMEM_ERROR;
}
if (rc == OSHMEM_SUCCESS) {
atomic_basic_lock(pe);
rc = MCA_SPML_CALL(get(target, nlong, prev, pe));
if ((rc == OSHMEM_SUCCESS) && (!cond || !memcmp(prev, &cond, nlong))) {
rc = MCA_SPML_CALL(put(target, nlong, (void*)&value, pe));
shmem_quiet();
}
atomic_basic_unlock(pe);
}
return rc;
}