SHMEM_CSWAP(3) | Open MPI | SHMEM_CSWAP(3) |
shmem_int_cswap(3), shmem_int4_cswap(3), shmem_int8_cswap(3), shmem_long_cswap(3), shmem_longlong_cswap(3) - Performs an atomic conditional swap to a remote data object
C or C++:
#include <mpp/shmem.h> int shmem_int_cswap(int *target, int cond, int value, int pe); long shmem_long_cswap(long *target, long cond, long value,
int pe); long long shmem_longlong_cswap(longlong *target,
longlong cond, longlong value, int pe);
Fortran:
INCLUDE "mpp/shmem.fh" INTEGER pe INTEGER(KIND=4) SHMEM_INT4_CSWAP ires = SHMEM_INT4_CSWAP(target, cond, value, pe) INTEGER(KIND=8) SHMEM_INT8_CSWAP ires = SHMEM_INT8_CSWAP(target, cond, value, pe)
The conditional swap routines conditionally update a target data object on an arbitrary processing element (PE) and return the prior contents of the data object in one atomic operation.
The arguments are as follows:
The term remotely accessible is defined in intro_shmem(3).
The contents that had been in the target data object on the remote PE prior to the conditional swap.
The following call ensures that the first PE to execute the conditional swap will successfully write its PE number to race_winner on PE 0.
main() {
static int race_winner = -1;
int oldval;
shmem_init();
oldval = shmem_int_cswap(&race_winner, -1, shmem_my_pe(), 0);
if (oldval == -1)
printf("pe %d was first\n",shmem_my_pe()); }
December 18, 2020 | 4.1.0 |