shmem_short_cswap

Purpose

Performs an atomic conditional swap to a symmetric data object.

C syntax

#include <shmem.h>
 
short shmem_short_cswap(short *target, short cond, short value, int pe);
 

Parameters

INPUT
target
The remotely accessible integer data object to be updated on the PE.
cond
cond is compared to the target value. If cond and the target are equal, then value is swapped into the target. Otherwise, the target is unchanged. In either case, the old value of the target is returned as the function return value. cond must be of the same data type as target.
value
Value to be atomically written to the target PE. Value is the same type as target.
pe
An integer indicating the PE number on which target is to be updated.

Description

This conditional swap routine conditionally update a target data object on an arbitrary processing element (PE) and return prior contents of the data object in one atomic operation.

The function shmem_short_cswap performs an atomic conditional operation on a remotely accessible short data object.

The atomic accessing of the shared variable is guaranteed only when that variable is updated solely using IBM openshmem functions.

Return values

This function returns the contents that had been at the target address on the remote PE prior to the swap is returned.

IBM NOTES

To utilize the hardware atomic operations support of the PERCS system, the variables of these operations should be aligned with their natural byte alignments. For example, an int variable should be 4-byte aligned; a long long variable should be 8-byte aligned. If the participating variables are not aligned, the operation is done in software with sub-optimal performance

C examples



Related information

Subroutines: shmem_swap


OpenSHMEM API Index