This source file includes following definitions.
- mca_common_ompio_request_free
- mca_common_ompio_request_cancel
- mca_common_ompio_request_construct
- mca_common_ompio_request_destruct
- mca_common_ompio_request_init
- mca_common_ompio_request_fini
- mca_common_ompio_request_alloc
- mca_common_ompio_register_progress
- mca_common_ompio_progress
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "common_ompio_request.h"
22 #include "common_ompio_buffer.h"
23
24 static void mca_common_ompio_request_construct(mca_ompio_request_t* req);
25 static void mca_common_ompio_request_destruct(mca_ompio_request_t *req);
26
27 bool mca_common_ompio_progress_is_registered=false;
28
29
30
31 opal_list_t mca_common_ompio_pending_requests = {{0}};
32
33
34
35 static int mca_common_ompio_request_free ( struct ompi_request_t **req)
36 {
37 mca_ompio_request_t *ompio_req = ( mca_ompio_request_t *)*req;
38 if ( NULL != ompio_req->req_tbuf ) {
39 if ( MCA_OMPIO_REQUEST_READ == ompio_req->req_type ){
40 struct iovec decoded_iov;
41 uint32_t iov_count=1;
42 size_t pos=0;
43
44 decoded_iov.iov_base = ompio_req->req_tbuf;
45 decoded_iov.iov_len = ompio_req->req_size;
46 opal_convertor_unpack (&ompio_req->req_convertor, &decoded_iov, &iov_count, &pos );
47 }
48 mca_common_ompio_release_buf ( NULL, ompio_req->req_tbuf );
49 }
50 if ( NULL != ompio_req->req_free_fn ) {
51 ompio_req->req_free_fn (ompio_req );
52 }
53 opal_list_remove_item (&mca_common_ompio_pending_requests, &ompio_req->req_item);
54
55 OBJ_RELEASE (*req);
56 *req = MPI_REQUEST_NULL;
57 return OMPI_SUCCESS;
58 }
59
60 static int mca_common_ompio_request_cancel ( struct ompi_request_t *req, int flag)
61 {
62 return OMPI_SUCCESS;
63 }
64
65 OBJ_CLASS_INSTANCE(mca_ompio_request_t, ompi_request_t,
66 mca_common_ompio_request_construct,
67 mca_common_ompio_request_destruct);
68
69 void mca_common_ompio_request_construct(mca_ompio_request_t* req)
70 {
71 OMPI_REQUEST_INIT (&(req->req_ompi), false );
72 req->req_ompi.req_free = mca_common_ompio_request_free;
73 req->req_ompi.req_cancel = mca_common_ompio_request_cancel;
74 req->req_ompi.req_type = OMPI_REQUEST_IO;
75 req->req_data = NULL;
76 req->req_tbuf = NULL;
77 req->req_size = 0;
78 req->req_progress_fn = NULL;
79 req->req_free_fn = NULL;
80
81 OBJ_CONSTRUCT(&req->req_item, opal_list_item_t);
82 opal_list_append (&mca_common_ompio_pending_requests, &req->req_item);
83 return;
84 }
85 void mca_common_ompio_request_destruct(mca_ompio_request_t* req)
86 {
87 OMPI_REQUEST_FINI ( &(req->req_ompi));
88 OBJ_DESTRUCT (&req->req_item);
89 if ( NULL != req->req_data ) {
90 free (req->req_data);
91 }
92
93 return;
94 }
95
96 void mca_common_ompio_request_init ( void )
97 {
98
99 OBJ_CONSTRUCT(&mca_common_ompio_pending_requests, opal_list_t);
100 return;
101 }
102
103 void mca_common_ompio_request_fini ( void )
104 {
105
106
107
108
109 OBJ_DESTRUCT(&mca_common_ompio_pending_requests);
110 return;
111 }
112
113 void mca_common_ompio_request_alloc ( mca_ompio_request_t **req, mca_ompio_request_type_t type )
114 {
115 mca_ompio_request_t *ompio_req = NULL;
116
117 ompio_req = OBJ_NEW(mca_ompio_request_t);
118 ompio_req->req_type = type;
119 ompio_req->req_ompi.req_state = OMPI_REQUEST_ACTIVE;
120
121 *req=ompio_req;
122
123 return;
124 }
125
126 void mca_common_ompio_register_progress ( void )
127 {
128 if ( false == mca_common_ompio_progress_is_registered) {
129 opal_progress_register (mca_common_ompio_progress);
130 mca_common_ompio_progress_is_registered=true;
131 }
132 return;
133 }
134 int mca_common_ompio_progress ( void )
135 {
136 mca_ompio_request_t *req=NULL;
137 opal_list_item_t *litem=NULL;
138 int completed=0;
139
140 OPAL_LIST_FOREACH(litem, &mca_common_ompio_pending_requests, opal_list_item_t) {
141 req = GET_OMPIO_REQ_FROM_ITEM(litem);
142 if( REQUEST_COMPLETE(&req->req_ompi) ) {
143 continue;
144 }
145 if ( NULL != req->req_progress_fn ) {
146 if ( req->req_progress_fn(req) ) {
147 completed++;
148 ompi_request_complete (&req->req_ompi, true);
149
150
151
152 }
153 }
154
155 }
156
157 return completed;
158 }