|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2004-2005 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-2005 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) 2011-2012 Cisco Systems, Inc. All rights reserved. |
| 14 | + * Copyright (c) 2014 Los Alamos National Security, LLC. All rights |
| 15 | + * reserved. |
| 16 | + * Copyright (c) 2015-2019 Research Organization for Information Science |
| 17 | + * and Technology (RIST). All rights reserved. |
| 18 | + * $COPYRIGHT$ |
| 19 | + * |
| 20 | + * Additional copyrights may follow |
| 21 | + * |
| 22 | + * $HEADER$ |
| 23 | + */ |
| 24 | + |
| 25 | +#include "ompi_config.h" |
| 26 | + |
| 27 | +#include "ompi/win/win.h" |
| 28 | +#include "ompi/errhandler/errhandler.h" |
| 29 | +#include "ompi/mpi/fortran/use-mpi-f08/ts/bindings.h" |
| 30 | +#include "ompi/mpi/fortran/base/constants.h" |
| 31 | + |
| 32 | +static const char FUNC_NAME[] = "MPI_Compare_and_swap"; |
| 33 | + |
| 34 | +void ompi_compare_and_swap_ts(CFI_cdesc_t *x1, CFI_cdesc_t *x2, CFI_cdesc_t *x3, |
| 35 | + MPI_Fint *datatype, MPI_Fint *target_rank, MPI_Aint *target_disp, |
| 36 | + MPI_Fint *win, MPI_Fint *ierr) |
| 37 | +{ |
| 38 | + int c_ierr; |
| 39 | + MPI_Datatype c_datatype = PMPI_Type_f2c(*datatype); |
| 40 | + MPI_Win c_win = PMPI_Win_f2c(*win); |
| 41 | + char *origin_addr = x1->base_addr, *compare_addr = x2->base_addr, *result_addr = x3->base_addr; |
| 42 | + |
| 43 | + OMPI_CFI_CHECK_CONTIGUOUS(x1, c_ierr); |
| 44 | + if (MPI_SUCCESS != c_ierr) { |
| 45 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 46 | + OMPI_ERRHANDLER_INVOKE(c_win, c_ierr, FUNC_NAME) |
| 47 | + return; |
| 48 | + } |
| 49 | + OMPI_CFI_CHECK_CONTIGUOUS(x2, c_ierr); |
| 50 | + if (MPI_SUCCESS != c_ierr) { |
| 51 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 52 | + OMPI_ERRHANDLER_INVOKE(c_win, c_ierr, FUNC_NAME) |
| 53 | + return; |
| 54 | + } |
| 55 | + OMPI_CFI_CHECK_CONTIGUOUS(x3, c_ierr); |
| 56 | + if (MPI_SUCCESS != c_ierr) { |
| 57 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 58 | + return; |
| 59 | + } |
| 60 | + c_ierr = PMPI_Compare_and_swap(OMPI_F2C_BOTTOM(origin_addr), |
| 61 | + OMPI_F2C_BOTTOM(compare_addr), |
| 62 | + OMPI_F2C_BOTTOM(result_addr), |
| 63 | + c_datatype, |
| 64 | + OMPI_FINT_2_INT(*target_rank), |
| 65 | + *target_disp, c_win); |
| 66 | + if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); |
| 67 | +} |
0 commit comments