Skip to content

Commit e4dcf83

Browse files
committed
checkpoint
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 5b22688 commit e4dcf83

File tree

6 files changed

+268
-95
lines changed

6 files changed

+268
-95
lines changed

ompi/mca/coll/base/coll_base_util.c

Lines changed: 42 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,6 @@
2929
#include "ompi/mca/pml/pml.h"
3030
#include "coll_base_util.h"
3131

32-
struct retain_op_data {
33-
ompi_request_complete_fn_t req_complete_cb;
34-
void *req_complete_cb_data;
35-
ompi_op_t *op;
36-
ompi_datatype_t *datatype;
37-
};
38-
39-
struct retain_datatypes_data {
40-
ompi_request_complete_fn_t req_complete_cb;
41-
void *req_complete_cb_data;
42-
ompi_datatype_t *stype;
43-
ompi_datatype_t *rtype;
44-
};
45-
46-
struct retain_datatypes_w_data {
47-
ompi_request_complete_fn_t req_complete_cb;
48-
void *req_complete_cb_data;
49-
int count;
50-
ompi_datatype_t *types[];
51-
};
52-
5332
int ompi_coll_base_sendrecv_actual( const void* sendbuf, size_t scount,
5433
ompi_datatype_t* sdatatype,
5534
int dest, int stag,
@@ -126,111 +105,112 @@ int ompi_rounddown(int num, int factor)
126105
}
127106

128107
static int release_op_callback(struct ompi_request_t *request) {
129-
struct retain_op_data * p = (struct retain_op_data *)request->req_complete_cb_data;
108+
struct ompi_coll_base_nbc_request_t * p = (ompi_coll_base_nbc_request_t *)request;
130109
int rc = OMPI_SUCCESS;
131110
assert (NULL != p);
132111
if (NULL != p->req_complete_cb) {
133112
request->req_complete_cb = p->req_complete_cb;
134113
request->req_complete_cb_data = p->req_complete_cb_data;
135-
rc = request->req_complete_cb(request);
114+
rc = request->req_complete_cb(request->req_complete_cb_data);
136115
}
137116
if (NULL != p->op) {
138117
OBJ_RELEASE(p->op);
139118
}
140119
if (NULL != p->datatype) {
141120
OBJ_RELEASE(p->datatype);
142121
}
143-
free(p);
144122
return rc;
145123
}
146124

147-
int ompi_coll_base_retain_op( ompi_request_t *request, ompi_op_t *op,
125+
int ompi_coll_base_retain_op( ompi_request_t *req, ompi_op_t *op,
148126
ompi_datatype_t *type) {
127+
ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
149128
bool retain = !ompi_op_is_intrinsic(op);
150129
retain |= !ompi_datatype_is_predefined(type);
151130
if (OPAL_UNLIKELY(retain)) {
152-
struct retain_op_data *p = (struct retain_op_data *)calloc(1, sizeof(struct retain_op_data));
153-
if (OPAL_UNLIKELY(NULL == p)) {
154-
return OMPI_ERR_OUT_OF_RESOURCE;
155-
}
156131
if (!ompi_op_is_intrinsic(op)) {
157132
OBJ_RETAIN(op);
158-
p->op = op;
133+
request->op = op;
134+
} else {
135+
request->op = NULL;
159136
}
160137
if (!ompi_datatype_is_predefined(type)) {
161138
OBJ_RETAIN(type);
162-
p->datatype = type;
139+
request->datatype = type;
140+
} else {
141+
request->datatype = NULL;
163142
}
164-
p->req_complete_cb = request->req_complete_cb;
165-
p->req_complete_cb_data = request->req_complete_cb_data;
166-
request->req_complete_cb = release_op_callback;
167-
request->req_complete_cb_data = p;
143+
request->req_complete_cb = request->super.req_complete_cb;
144+
request->req_complete_cb_data = request->super.req_complete_cb_data;
145+
req->req_complete_cb = release_op_callback;
146+
req->req_complete_cb_data = request;
168147
}
169148
return OMPI_SUCCESS;
170149
}
171150

172151
static int release_datatypes_callback(struct ompi_request_t *request) {
173-
struct retain_datatypes_data * p = (struct retain_datatypes_data *)request->req_complete_cb_data;
152+
struct ompi_coll_base_nbc_request_t * p = (ompi_coll_base_nbc_request_t *)request;
174153
int rc = OMPI_SUCCESS;
175154
assert (NULL != p);
176155
if (NULL != p->req_complete_cb) {
177156
request->req_complete_cb = p->req_complete_cb;
178157
request->req_complete_cb_data = p->req_complete_cb_data;
179-
rc = request->req_complete_cb(request);
158+
rc = request->req_complete_cb(request->req_complete_cb_data);
180159
}
181160
if (NULL != p->stype) {
182161
OBJ_RELEASE(p->stype);
183162
}
184163
if (NULL != p->rtype) {
185164
OBJ_RELEASE(p->rtype);
186165
}
187-
free(p);
188166
return rc;
189167
}
190168

191-
int ompi_coll_base_retain_datatypes( ompi_request_t *request, ompi_datatype_t *stype,
169+
int ompi_coll_base_retain_datatypes( ompi_request_t *req, ompi_datatype_t *stype,
192170
ompi_datatype_t *rtype) {
171+
ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
193172
bool retain = NULL != stype && !ompi_datatype_is_predefined(stype);
194173
retain |= NULL != rtype && !ompi_datatype_is_predefined(rtype);
195174
if (OPAL_UNLIKELY(retain)) {
196-
struct retain_datatypes_data *p = (struct retain_datatypes_data *)calloc(1, sizeof(struct retain_datatypes_data));
197-
if (OPAL_UNLIKELY(NULL == p)) {
198-
return OMPI_ERR_OUT_OF_RESOURCE;
199-
}
200175
if (NULL != stype && !ompi_datatype_is_predefined(stype)) {
201176
OBJ_RETAIN(stype);
202-
p->stype = stype;
177+
request->stype = stype;
178+
} else {
179+
request->stype = NULL;
203180
}
204181
if (NULL != rtype && !ompi_datatype_is_predefined(rtype)) {
205182
OBJ_RETAIN(rtype);
206-
p->rtype = rtype;
183+
request->rtype = rtype;
184+
} else {
185+
request->rtype = NULL;
207186
}
208-
p->req_complete_cb = request->req_complete_cb;
209-
p->req_complete_cb_data = request->req_complete_cb_data;
210-
request->req_complete_cb = release_datatypes_callback;
211-
request->req_complete_cb_data = p;
187+
request->req_complete_cb = req->req_complete_cb;
188+
request->req_complete_cb_data = req->req_complete_cb_data;
189+
req->req_complete_cb = release_datatypes_callback;
190+
req->req_complete_cb_data = request;
212191
}
213192
return OMPI_SUCCESS;
214193
}
215194

216195
static int release_datatypes_w_callback(struct ompi_request_t *request) {
217-
struct retain_datatypes_w_data * p = (struct retain_datatypes_w_data *)request->req_complete_cb_data;
196+
ompi_coll_base_nbc_request_t *p = (ompi_coll_base_nbc_request_t *)request;
218197
int rc = OMPI_SUCCESS;
219198
assert (NULL != p);
220-
if (NULL != p->req_complete_cb) {
199+
if (NULL != request->req_complete_cb) {
221200
request->req_complete_cb = p->req_complete_cb;
222201
request->req_complete_cb_data = p->req_complete_cb_data;
223-
rc = request->req_complete_cb(request);
202+
rc = request->req_complete_cb(request->req_complete_cb_data);
224203
}
225204
for (int i=0; i<p->count; i++) {
226205
OBJ_RELEASE(p->types[i]);
227206
}
228-
free(p);
207+
free(p->types);
229208
return rc;
230209
}
231210

232-
int ompi_coll_base_retain_datatypes_w( ompi_request_t *request, int count,
211+
int ompi_coll_base_retain_datatypes_w( ompi_request_t *req, int count,
233212
ompi_datatype_t *const stypes[], ompi_datatype_t *const rtypes[]) {
213+
ompi_coll_base_nbc_request_t *request = (ompi_coll_base_nbc_request_t *)req;
234214
int datatypes = 0;
235215
for (int i=0; i<count; i++) {
236216
if (NULL != stypes[i] && !ompi_datatype_is_predefined(stypes[i])) {
@@ -241,25 +221,25 @@ int ompi_coll_base_retain_datatypes_w( ompi_request_t *request, int count,
241221
}
242222
}
243223
if (OPAL_UNLIKELY(0 < datatypes)) {
244-
struct retain_datatypes_w_data *p = (struct retain_datatypes_w_data *)calloc(1, sizeof(struct retain_datatypes_data)+(datatypes-1)*sizeof(ompi_datatype_t *));
245-
if (OPAL_UNLIKELY(NULL == p)) {
224+
request->types = (ompi_datatype_t **)calloc(datatypes, sizeof(ompi_datatype_t *));
225+
if (OPAL_UNLIKELY(NULL == request->types)) {
246226
return OMPI_ERR_OUT_OF_RESOURCE;
247227
}
248228
datatypes = 0;
249229
for (int i=0; i<count; i++) {
250230
if (NULL != stypes[i] && !ompi_datatype_is_predefined(stypes[i])) {
251-
p->types[datatypes++] = stypes[i];
231+
request->types[datatypes++] = stypes[i];
252232
OBJ_RETAIN(stypes[i]);
253233
}
254234
if (NULL != rtypes[i] && !ompi_datatype_is_predefined(rtypes[i])) {
255-
p->types[datatypes++] = rtypes[i];
235+
request->types[datatypes++] = rtypes[i];
256236
OBJ_RETAIN(rtypes[i]);
257237
}
258238
}
259-
p->req_complete_cb = request->req_complete_cb;
260-
p->req_complete_cb_data = request->req_complete_cb_data;
261-
request->req_complete_cb = release_datatypes_w_callback;
262-
request->req_complete_cb_data = p;
239+
request->req_complete_cb = req->req_complete_cb;
240+
request->req_complete_cb_data = req->req_complete_cb_data;
241+
req->req_complete_cb = release_datatypes_w_callback;
242+
req->req_complete_cb_data = request;
263243
}
264244
return OMPI_SUCCESS;
265245
}

ompi/mca/coll/base/coll_base_util.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232

3333
BEGIN_C_DECLS
3434

35+
struct ompi_coll_base_nbc_request_t {
36+
ompi_request_t super;
37+
ompi_request_complete_fn_t req_complete_cb;
38+
void *req_complete_cb_data;
39+
ompi_op_t *op;
40+
ompi_datatype_t *datatype;
41+
ompi_datatype_t *stype;
42+
ompi_datatype_t *rtype;
43+
ompi_datatype_t **types;
44+
int count;
45+
};
46+
47+
typedef struct ompi_coll_base_nbc_request_t ompi_coll_base_nbc_request_t;
48+
3549
/**
3650
* A MPI_like function doing a send and a receive simultaneously.
3751
* If one of the communications results in a zero-byte message the
@@ -86,7 +100,7 @@ unsigned int ompi_mirror_perm(unsigned int x, int nbits);
86100
int ompi_rounddown(int num, int factor);
87101

88102
int ompi_coll_base_retain_op( ompi_request_t *request, ompi_op_t *op,
89-
ompi_datatype_t *type);
103+
ompi_datatype_t *type);
90104

91105
int ompi_coll_base_retain_datatypes( ompi_request_t *request, ompi_datatype_t *stype,
92106
ompi_datatype_t *rtype);

ompi/mca/coll/libnbc/coll_libnbc.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2014-2017 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2014-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
1919
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
2020
* $COPYRIGHT$
@@ -28,7 +28,7 @@
2828
#define MCA_COLL_LIBNBC_EXPORT_H
2929

3030
#include "ompi/mca/coll/coll.h"
31-
#include "ompi/request/request.h"
31+
#include "ompi/mca/coll/base/coll_base_util.h"
3232
#include "opal/sys/atomic.h"
3333

3434
BEGIN_C_DECLS
@@ -121,7 +121,7 @@ typedef struct NBC_Schedule NBC_Schedule;
121121
OBJ_CLASS_DECLARATION(NBC_Schedule);
122122

123123
struct ompi_coll_libnbc_request_t {
124-
ompi_request_t super;
124+
ompi_coll_base_nbc_request_t super;
125125
MPI_Comm comm;
126126
long row_offset;
127127
bool nbc_complete; /* status in libnbc level */
@@ -145,13 +145,13 @@ typedef ompi_coll_libnbc_request_t NBC_Handle;
145145
opal_free_list_item_t *item; \
146146
item = opal_free_list_wait (&mca_coll_libnbc_component.requests); \
147147
req = (ompi_coll_libnbc_request_t*) item; \
148-
OMPI_REQUEST_INIT(&req->super, persistent); \
149-
req->super.req_mpi_object.comm = comm; \
148+
OMPI_REQUEST_INIT(&req->super.super, persistent); \
149+
req->super.super.req_mpi_object.comm = comm; \
150150
} while (0)
151151

152152
#define OMPI_COLL_LIBNBC_REQUEST_RETURN(req) \
153153
do { \
154-
OMPI_REQUEST_FINI(&(req)->super); \
154+
OMPI_REQUEST_FINI(&(req)->super.super); \
155155
opal_free_list_return (&mca_coll_libnbc_component.requests, \
156156
(opal_free_list_item_t*) (req)); \
157157
} while (0)

ompi/mca/coll/libnbc/coll_libnbc_component.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16-
* Copyright (c) 2016-2017 Research Organization for Information Science
17-
* and Technology (RIST). All rights reserved.
16+
* Copyright (c) 2016-2019 Research Organization for Information Science
17+
* and Technology (RIST). All rights reserved.
1818
* Copyright (c) 2016 IBM Corporation. All rights reserved.
1919
* Copyright (c) 2017 Ian Bradley Morgan and Anthony Skjellum. All
2020
* rights reserved.
@@ -448,21 +448,21 @@ ompi_coll_libnbc_progress(void)
448448
/* done, remove and complete */
449449
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
450450
opal_list_remove_item(&mca_coll_libnbc_component.active_requests,
451-
&request->super.super.super);
451+
&request->super.super.super.super);
452452
OPAL_THREAD_UNLOCK(&mca_coll_libnbc_component.lock);
453453

454454
if( OMPI_SUCCESS == res || NBC_OK == res || NBC_SUCCESS == res ) {
455-
request->super.req_status.MPI_ERROR = OMPI_SUCCESS;
455+
request->super.super.req_status.MPI_ERROR = OMPI_SUCCESS;
456456
}
457457
else {
458-
request->super.req_status.MPI_ERROR = res;
458+
request->super.super.req_status.MPI_ERROR = res;
459459
}
460-
if(request->super.req_persistent) {
460+
if(request->super.super.req_persistent) {
461461
/* reset for the next communication */
462462
request->row_offset = 0;
463463
}
464-
if(!request->super.req_persistent || !REQUEST_COMPLETE(&request->super)) {
465-
ompi_request_complete(&request->super, true);
464+
if(!request->super.super.req_persistent || !REQUEST_COMPLETE(&request->super.super)) {
465+
ompi_request_complete(&request->super.super, true);
466466
}
467467
}
468468
OPAL_THREAD_LOCK(&mca_coll_libnbc_component.lock);
@@ -527,7 +527,7 @@ request_start(size_t count, ompi_request_t ** requests)
527527
NBC_DEBUG(5, "tmpbuf address=%p size=%u\n", handle->tmpbuf, sizeof(handle->tmpbuf));
528528
NBC_DEBUG(5, "--------------------------------\n");
529529

530-
handle->super.req_complete = REQUEST_PENDING;
530+
handle->super.super.req_complete = REQUEST_PENDING;
531531
handle->nbc_complete = false;
532532

533533
res = NBC_Start(handle);
@@ -557,7 +557,7 @@ request_free(struct ompi_request_t **ompi_req)
557557
ompi_coll_libnbc_request_t *request =
558558
(ompi_coll_libnbc_request_t*) *ompi_req;
559559

560-
if( !REQUEST_COMPLETE(&request->super) ) {
560+
if( !REQUEST_COMPLETE(&request->super.super) ) {
561561
return MPI_ERR_REQUEST;
562562
}
563563

@@ -571,11 +571,11 @@ request_free(struct ompi_request_t **ompi_req)
571571
static void
572572
request_construct(ompi_coll_libnbc_request_t *request)
573573
{
574-
request->super.req_type = OMPI_REQUEST_COLL;
575-
request->super.req_status._cancelled = 0;
576-
request->super.req_start = request_start;
577-
request->super.req_free = request_free;
578-
request->super.req_cancel = request_cancel;
574+
request->super.super.req_type = OMPI_REQUEST_COLL;
575+
request->super.super.req_status._cancelled = 0;
576+
request->super.super.req_start = request_start;
577+
request->super.super.req_free = request_free;
578+
request->super.super.req_cancel = request_cancel;
579579
}
580580

581581

0 commit comments

Comments
 (0)