1
1
openmpi/oshmem/mca/atomic/basic/atomic_basic_cswap.c
Xin Zhao c429900cd9 OMPI/OSHMEM: add new functionality of OpenSHMEM v1.4.
Signed-off-by: Xin Zhao <xinz@mellanox.com>
2018-07-16 12:55:25 -07:00

50 строки
1.2 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(shmem_ctx_t ctx,
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(ctx, pe);
rc = MCA_SPML_CALL(get(ctx, target, nlong, prev, pe));
if ((rc == OSHMEM_SUCCESS) && (!cond || !memcmp(prev, &cond, nlong))) {
rc = MCA_SPML_CALL(put(ctx, target, nlong, (void*)&value, pe));
shmem_quiet();
}
atomic_basic_unlock(ctx, pe);
}
return rc;
}