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) 2006 Cisco Systems, Inc. All rights reserved.
13 * Copyright (c) 2018 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 #ifndef OMPI_GEN_REQUEST_H
23 #define OMPI_GEN_REQUEST_H
24
25 #include "ompi_config.h"
26 #include "ompi/request/request.h"
27
28 BEGIN_C_DECLS
29 OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_grequest_t);
30
31 /**
32 * Fortran type for generalized request query function
33 */
34 typedef void (MPI_F_Grequest_query_function)(MPI_Aint *extra_state,
35 MPI_Fint *status,
36 MPI_Fint *ierr);
37 /**
38 * Fortran type for generalized request free function
39 */
40 typedef void (MPI_F_Grequest_free_function)(MPI_Aint *extra_state,
41 MPI_Fint *ierr);
42 /**
43 * Fortran type for generalized request cancel function
44 */
45 typedef void (MPI_F_Grequest_cancel_function)(MPI_Aint *extra_state,
46 ompi_fortran_logical_t *complete,
47 MPI_Fint *ierr);
48
49 #if OMPI_ENABLE_GREQUEST_EXTENSIONS
50 /**
51 * Fortran type for generalized request query function
52 */
53 typedef int (ompi_grequestx_poll_function)(void *, MPI_Status *);
54
55 typedef void (ompi_f_grequestx_poll_function)(MPI_Aint *extra_state,
56 MPI_Fint *status,
57 MPI_Fint *ierr);
58 #endif
59
60 /**
61 * Union for query function for use in ompi_grequest_t
62 */
63 typedef union {
64 MPI_Grequest_query_function* c_query;
65 MPI_F_Grequest_query_function* f_query;
66 } MPI_Grequest_query_fct_t;
67
68 /**
69 * Union for free function for use in ompi_grequest_t
70 */
71 typedef union {
72 MPI_Grequest_free_function* c_free;
73 MPI_F_Grequest_free_function* f_free;
74 } MPI_Grequest_free_fct_t;
75
76 /**
77 * Union for cancel function for use in ompi_grequest_t
78 */
79 typedef union {
80 MPI_Grequest_cancel_function* c_cancel;
81 MPI_F_Grequest_cancel_function* f_cancel;
82 } MPI_Grequest_cancel_fct_t;
83
84 #if OMPI_ENABLE_GREQUEST_EXTENSIONS
85 /**
86 * Union for poll function for use in ompi_grequestx_t
87 */
88 typedef union {
89 ompi_grequestx_poll_function* c_poll;
90 ompi_f_grequestx_poll_function* f_poll;
91 } ompi_grequestx_poll_fct_t;
92 #endif
93
94 /**
95 * Main structure for MPI generalized requests
96 */
97 struct ompi_grequest_t {
98 ompi_request_t greq_base;
99 MPI_Grequest_query_fct_t greq_query;
100 MPI_Grequest_free_fct_t greq_free;
101 MPI_Grequest_cancel_fct_t greq_cancel;
102 #if OMPI_ENABLE_GREQUEST_EXTENSIONS
103 ompi_grequestx_poll_fct_t greq_poll;
104 #endif
105 void *greq_state;
106 bool greq_funcs_are_c;
107 };
108 /**
109 * Convenience typedef
110 */
111 typedef struct ompi_grequest_t ompi_grequest_t;
112
113 /**
114 * Start a generalized request (back end for MPI_GREQUEST_START)
115 */
116 OMPI_DECLSPEC int ompi_grequest_start(
117 MPI_Grequest_query_function *gquery,
118 MPI_Grequest_free_function *gfree,
119 MPI_Grequest_cancel_function *gcancel,
120 void* gstate,
121 ompi_request_t** request);
122
123 /**
124 * Complete a generalized request (back end for MPI_GREQUEST_COMPLETE)
125 */
126 OMPI_DECLSPEC int ompi_grequest_complete(ompi_request_t *req);
127
128 /**
129 * Invoke the query function on a generalized request
130 */
131 OMPI_DECLSPEC int ompi_grequest_invoke_query(ompi_request_t *request,
132 ompi_status_public_t *status);
133 END_C_DECLS
134
135 #endif