This source file includes following definitions.
- MPI_Compare_and_swap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 }