Edit

Share via


MPI_Compare_and_swap function

Performs a remote atomic compare and swap operation.

Syntax

int MPIAPI MPI_Compare_and_swap(
  _In_  void         *origin_addr,
  _In_  void         *compare_addr,
  _Out_ void         *result_addr,
        MPI_Datatype datatype,
        int          target_rank,
        MPI_Aint     target_disp,
        MPI_Win      win
);

Parameters

  • origin_addr [in]
    initial address of buffer

  • compare_addr [in]
    initial address of comparebuffer

  • result_addr [out]
    initial address of result buffer

  • datatype
    datatype of each entry in all buffers

  • target_rank
    rank of target

  • target_disp
    displacement from start of window to beginning of target buffer

  • win
    window object

Return value

Returns MPI_SUCCESS on success. Otherwise, the return value is an error code.

In Fortran, the return value is stored in the IERROR parameter.

Fortran

    MPI_COMPARE_AND_SWAP(ORIGIN_ADDR, COMPARE_ADDR, RESULT_ADDR,
                DATATYPE, TARGET_RANK, TARGET_DISP, WIN, IERROR)
        <type> ORIGIN_ADDR(*), COMPARE_ADDR(*), RESULT_ADDR(*)
        INTEGER(KIND=MPI_ADDRESS_KIND) TARGET_DISP
        INTEGER DATATYPE, TARGET_RANK, WIN, IERROR

Remarks

This function compares one element of type datatype in the compare buffer compare_addr with the buffer at offset target_disp in the target window specified by target_rank and win and replaces the value at the target with the value in the origin buffer origin_addr if the compare buffer and the target buffer are identical. The original value at the target is returned in the buffer result_addr. The parameter datatype must belong to one of the following categories of predefined datatypes: C integer, Fortran integer, Logical, Multi-language types, or Byte. The origin and result buffers (origin_addr and result_addr) must be disjoint.

Requirements

Product

HPC Pack 2012 MS-MPI Redistributable Package, HPC Pack 2008 R2 MS-MPI Redistributable Package, HPC Pack 2008 MS-MPI Redistributable Package or HPC Pack 2008 Client Utilities

Header

Mpi.h; Mpif.h

Library

Msmpi.lib

DLL

Msmpi.dll

See also

MPI One-Sided Communications Functions