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) 2007-2012 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2015-2017 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 #include "ompi/communicator/communicator.h"
26
27 #if OMPI_BUILD_MPI_PROFILING
28 #if OPAL_HAVE_WEAK_SYMBOLS
29 #pragma weak PMPI_WIN_CREATE_KEYVAL = ompi_win_create_keyval_f
30 #pragma weak pmpi_win_create_keyval = ompi_win_create_keyval_f
31 #pragma weak pmpi_win_create_keyval_ = ompi_win_create_keyval_f
32 #pragma weak pmpi_win_create_keyval__ = ompi_win_create_keyval_f
33
34 #pragma weak PMPI_Win_create_keyval_f = ompi_win_create_keyval_f
35 #pragma weak PMPI_Win_create_keyval_f08 = ompi_win_create_keyval_f
36 #else
37 OMPI_GENERATE_F77_BINDINGS (PMPI_WIN_CREATE_KEYVAL,
38 pmpi_win_create_keyval,
39 pmpi_win_create_keyval_,
40 pmpi_win_create_keyval__,
41 pompi_win_create_keyval_f,
42 (ompi_aint_copy_attr_function* win_copy_attr_fn, ompi_aint_delete_attr_function* win_delete_attr_fn, MPI_Fint *win_keyval, MPI_Aint *extra_state, MPI_Fint *ierr),
43 (win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state, ierr) )
44 #endif
45 #endif
46
47 #if OPAL_HAVE_WEAK_SYMBOLS
48 #pragma weak MPI_WIN_CREATE_KEYVAL = ompi_win_create_keyval_f
49 #pragma weak mpi_win_create_keyval = ompi_win_create_keyval_f
50 #pragma weak mpi_win_create_keyval_ = ompi_win_create_keyval_f
51 #pragma weak mpi_win_create_keyval__ = ompi_win_create_keyval_f
52
53 #pragma weak MPI_Win_create_keyval_f = ompi_win_create_keyval_f
54 #pragma weak MPI_Win_create_keyval_f08 = ompi_win_create_keyval_f
55 #else
56 #if ! OMPI_BUILD_MPI_PROFILING
57 OMPI_GENERATE_F77_BINDINGS (MPI_WIN_CREATE_KEYVAL,
58 mpi_win_create_keyval,
59 mpi_win_create_keyval_,
60 mpi_win_create_keyval__,
61 ompi_win_create_keyval_f,
62 (ompi_aint_copy_attr_function* win_copy_attr_fn, ompi_aint_delete_attr_function* win_delete_attr_fn, MPI_Fint *win_keyval, MPI_Aint *extra_state, MPI_Fint *ierr),
63 (win_copy_attr_fn, win_delete_attr_fn, win_keyval, extra_state, ierr) )
64 #else
65 #define ompi_win_create_keyval_f pompi_win_create_keyval_f
66 #endif
67 #endif
68
69 static char FUNC_NAME[] = "MPI_Win_create_keyval";
70
ompi_win_create_keyval_f(ompi_aint_copy_attr_function * win_copy_attr_fn,ompi_aint_delete_attr_function * win_delete_attr_fn,MPI_Fint * win_keyval,MPI_Aint * extra_state,MPI_Fint * ierr)71 void ompi_win_create_keyval_f(ompi_aint_copy_attr_function* win_copy_attr_fn,
72 ompi_aint_delete_attr_function* win_delete_attr_fn,
73 MPI_Fint *win_keyval, MPI_Aint *extra_state, MPI_Fint *ierr)
74 {
75 int ret, c_ierr;
76 OMPI_SINGLE_NAME_DECL(win_keyval);
77 ompi_attribute_fn_ptr_union_t copy_fn;
78 ompi_attribute_fn_ptr_union_t del_fn;
79
80 copy_fn.attr_aint_copy_fn = win_copy_attr_fn;
81 del_fn.attr_aint_delete_fn = win_delete_attr_fn;
82
83 /* Note that we only set the "F77" bit and exclude the "F77_OLD"
84 bit, indicating that the callbacks should use the new MPI-2
85 INTEGER(KIND=MPI_ADDRESS_KIND)-parameter functions (as opposed
86 to the old MPI-1 INTEGER-parameter functions). */
87
88 ret = ompi_attr_create_keyval_aint(WIN_ATTR, copy_fn, del_fn,
89 OMPI_SINGLE_NAME_CONVERT(win_keyval), *extra_state, OMPI_KEYVAL_F77,
90 NULL);
91
92 if (MPI_SUCCESS != ret) {
93 c_ierr = OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER,
94 FUNC_NAME);
95 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
96 } else {
97 if (NULL != ierr) *ierr = OMPI_INT_2_FINT(MPI_SUCCESS);
98 OMPI_SINGLE_INT_2_FINT(win_keyval);
99 }
100 }
101