1 /*
2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3  *                         University Research and Technology
4  *                         Corporation.  All rights reserved.
5  * Copyright (c) 2004-2005 The University of Tennessee and The University
6  *                         of Tennessee Research Foundation.  All rights
7  *                         reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  *                         University of Stuttgart.  All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  *                         All rights reserved.
12  * Copyright (c) 2011-2014 Cisco Systems, Inc.  All rights reserved.
13  * Copyright (c) 2015      Research Organization for Information Science
14  *                         and Technology (RIST). All rights reserved.
15  * $COPYRIGHT$
16  *
17  * Additional copyrights may follow
18  *
19  * $HEADER$
20  */
21 
22 #include "ompi_config.h"
23 
24 #include "ompi/mpi/fortran/mpif-h/bindings.h"
25 
26 #if OMPI_BUILD_MPI_PROFILING
27 #if OPAL_HAVE_WEAK_SYMBOLS
28 #pragma weak PMPI_WIN_ALLOCATE_SHARED = ompi_win_allocate_shared_f
29 #pragma weak pmpi_win_allocate_shared = ompi_win_allocate_shared_f
30 #pragma weak pmpi_win_allocate_shared_ = ompi_win_allocate_shared_f
31 #pragma weak pmpi_win_allocate_shared__ = ompi_win_allocate_shared_f
32 
33 #pragma weak PMPI_Win_allocate_shared_f = ompi_win_allocate_shared_f
34 #pragma weak PMPI_Win_allocate_shared_f08 = ompi_win_allocate_shared_f
35 
36 #pragma weak PMPI_WIN_ALLOCATE_SHARED_CPTR = ompi_win_allocate_shared_f
37 #pragma weak pmpi_win_allocate_shared_cptr = ompi_win_allocate_shared_f
38 #pragma weak pmpi_win_allocate_shared_cptr_ = ompi_win_allocate_shared_f
39 #pragma weak pmpi_win_allocate_shared_cptr__ = ompi_win_allocate_shared_f
40 
41 #pragma weak PMPI_Win_allocate_shared_cptr_f = ompi_win_allocate_shared_f
42 #pragma weak PMPI_Win_allocate_shared_cptr_f08 = ompi_win_allocate_shared_f
43 #else
44 OMPI_GENERATE_F77_BINDINGS (PMPI_WIN_ALLOCATE_SHARED,
45                             pmpi_win_allocate_shared,
46                             pmpi_win_allocate_shared_,
47                             pmpi_win_allocate_shared__,
48                             pompi_win_allocate_shared_f,
49                             (MPI_Aint *size, MPI_Fint *disp_unit,
50                              MPI_Fint *info, MPI_Fint *comm, char *baseptr,
51                              MPI_Fint *win, MPI_Fint *ierr),
52                             (size, disp_unit, info, comm, baseptr, win, ierr) )
53 
54 OMPI_GENERATE_F77_BINDINGS (PMPI_WIN_ALLOCATE_SHARED_CPTR,
55                             pmpi_win_allocate_shared_cptr,
56                             pmpi_win_allocate_shared_cptr_,
57                             pmpi_win_allocate_shared_cptr__,
58                             pompi_win_allocate_shared_cptr_f,
59                             (MPI_Aint *size, MPI_Fint *disp_unit,
60                              MPI_Fint *info, MPI_Fint *comm, char *baseptr,
61                              MPI_Fint *win, MPI_Fint *ierr),
62                             (size, disp_unit, info, comm, baseptr, win, ierr) )
63 #endif
64 #endif
65 
66 #if OPAL_HAVE_WEAK_SYMBOLS
67 #pragma weak MPI_WIN_ALLOCATE_SHARED = ompi_win_allocate_shared_f
68 #pragma weak mpi_win_allocate_shared = ompi_win_allocate_shared_f
69 #pragma weak mpi_win_allocate_shared_ = ompi_win_allocate_shared_f
70 #pragma weak mpi_win_allocate_shared__ = ompi_win_allocate_shared_f
71 
72 #pragma weak MPI_Win_allocate_shared_f = ompi_win_allocate_shared_f
73 #pragma weak MPI_Win_allocate_shared_f08 = ompi_win_allocate_shared_f
74 
75 #pragma weak MPI_WIN_ALLOCATE_SHARED_CPTR = ompi_win_allocate_shared_f
76 #pragma weak mpi_win_allocate_shared_cptr = ompi_win_allocate_shared_f
77 #pragma weak mpi_win_allocate_shared_cptr_ = ompi_win_allocate_shared_f
78 #pragma weak mpi_win_allocate_shared_cptr__ = ompi_win_allocate_shared_f
79 
80 #pragma weak MPI_Win_allocate_shared_cptr_f = ompi_win_allocate_shared_f
81 #pragma weak MPI_Win_allocate_shared_cptr_f08 = ompi_win_allocate_shared_f
82 #else
83 #if ! OMPI_BUILD_MPI_PROFILING
84 OMPI_GENERATE_F77_BINDINGS (MPI_WIN_ALLOCATE_SHARED,
85                             mpi_win_allocate_shared,
86                             mpi_win_allocate_shared_,
87                             mpi_win_allocate_shared__,
88                             ompi_win_allocate_shared_f,
89                             (MPI_Aint *size, MPI_Fint *disp_unit,
90                              MPI_Fint *info, MPI_Fint *comm, char *baseptr,
91                              MPI_Fint *win, MPI_Fint *ierr),
92                             (size, disp_unit, info, comm, baseptr, win, ierr) )
93 
94 OMPI_GENERATE_F77_BINDINGS (MPI_WIN_ALLOCATE_SHARED_CPTR,
95                             mpi_win_allocate_shared_cptr,
96                             mpi_win_allocate_shared_cptr_,
97                             mpi_win_allocate_shared_cptr__,
98                             ompi_win_allocate_shared_cptr_f,
99                             (MPI_Aint *size, MPI_Fint *disp_unit,
100                              MPI_Fint *info, MPI_Fint *comm, char *baseptr,
101                              MPI_Fint *win, MPI_Fint *ierr),
102                             (size, disp_unit, info, comm, baseptr, win, ierr) )
103 #else
104 #define ompi_win_allocate_shared_f pompi_win_allocate_shared_f
105 #define ompi_win_allocate_shared_cptr_f pompi_win_allocate_shared_cptr_f
106 #endif
107 #endif
108 
109 
ompi_win_allocate_shared_f(MPI_Aint * size,MPI_Fint * disp_unit,MPI_Fint * info,MPI_Fint * comm,char * baseptr,MPI_Fint * win,MPI_Fint * ierr)110 void ompi_win_allocate_shared_f(MPI_Aint *size, MPI_Fint *disp_unit,
111                                 MPI_Fint *info, MPI_Fint *comm, char *baseptr,
112                                 MPI_Fint *win, MPI_Fint *ierr)
113 {
114     int c_ierr;
115     MPI_Info c_info;
116     MPI_Comm c_comm;
117     MPI_Win c_win;
118 
119     c_info = PMPI_Info_f2c(*info);
120     c_comm = PMPI_Comm_f2c(*comm);
121 
122     c_ierr = PMPI_Win_allocate_shared(*size, OMPI_FINT_2_INT(*disp_unit),
123                                      c_info, c_comm,
124                                      baseptr, &c_win);
125     *win = PMPI_Win_c2f(c_win);
126     if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
127 }
128 
129 /*
130  * Note that MPI-3 mandates a second form of the
131  * MPI_Win_allocate_shared interface -- one that has a "_cptr" suffix.
132  */
ompi_win_allocate_shared_cptr_f(MPI_Aint * size,MPI_Fint * disp_unit,MPI_Fint * info,MPI_Fint * comm,char * baseptr,MPI_Fint * win,MPI_Fint * ierr)133 void ompi_win_allocate_shared_cptr_f(MPI_Aint *size, MPI_Fint *disp_unit,
134                                      MPI_Fint *info, MPI_Fint *comm,
135                                      char *baseptr,
136                                      MPI_Fint *win, MPI_Fint *ierr)
137 {
138     ompi_win_allocate_shared_f(size, disp_unit, info, comm, baseptr,
139                                win, ierr);
140 }
141