root/ompi/mpi/c/compare_and_swap.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_Compare_and_swap

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2006      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2011      Sandia National Laboratories. All rights reserved.
  15  * Copyright (c) 2015      Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
  18  *                         reserved.
  19  * $COPYRIGHT$
  20  *
  21  * Additional copyrights may follow
  22  *
  23  * $HEADER$
  24  */
  25 #include "ompi_config.h"
  26 #include <stdio.h>
  27 
  28 #include "ompi/mpi/c/bindings.h"
  29 #include "ompi/runtime/params.h"
  30 #include "ompi/communicator/communicator.h"
  31 #include "ompi/errhandler/errhandler.h"
  32 #include "ompi/win/win.h"
  33 #include "ompi/mca/osc/osc.h"
  34 #include "ompi/datatype/ompi_datatype.h"
  35 
  36 #if OMPI_BUILD_MPI_PROFILING
  37 #if OPAL_HAVE_WEAK_SYMBOLS
  38 #pragma weak MPI_Compare_and_swap = PMPI_Compare_and_swap
  39 #endif
  40 #define MPI_Compare_and_swap PMPI_Compare_and_swap
  41 #endif
  42 
  43 static const char FUNC_NAME[] = "MPI_Compare_and_swap";
  44 
  45 
  46 int MPI_Compare_and_swap(const void *origin_addr, const void *compare_addr, void *result_addr,
  47                          MPI_Datatype datatype, int target_rank, MPI_Aint target_disp, MPI_Win win)
  48 {
  49     int rc;
  50 
  51     if (MPI_PARAM_CHECK) {
  52         rc = OMPI_SUCCESS;
  53 
  54         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  55 
  56         if (ompi_win_invalid(win)) {
  57             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_WIN, FUNC_NAME);
  58         } else if (ompi_win_peer_invalid(win, target_rank) &&
  59                    (MPI_PROC_NULL != target_rank)) {
  60             rc = MPI_ERR_RANK;
  61         } else if ( MPI_WIN_FLAVOR_DYNAMIC != win->w_flavor && target_disp < 0 ) {
  62             rc = MPI_ERR_DISP;
  63         } else {
  64             OMPI_CHECK_DATATYPE_FOR_ONE_SIDED(rc, datatype, 1);
  65         }
  66         OMPI_ERRHANDLER_CHECK(rc, win, rc, FUNC_NAME);
  67     }
  68 
  69     if (MPI_PROC_NULL == target_rank) return MPI_SUCCESS;
  70 
  71     OPAL_CR_ENTER_LIBRARY();
  72 
  73     rc = win->w_osc_module->osc_compare_and_swap(origin_addr, compare_addr, result_addr,
  74                                                  datatype, target_rank, target_disp, win);
  75     OMPI_ERRHANDLER_RETURN(rc, win, rc, FUNC_NAME);
  76 }

/* [<][>][^][v][top][bottom][index][help] */