Skip to content

Commit 4eed554

Browse files
committed
libnbc: retain datatype and schedule them for release
This is a proof of concept, and only ibcast is implemented Thanks Thomas Ponweiser for reporting this
1 parent 292563f commit 4eed554

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

ompi/mca/coll/libnbc/nbc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
1919
*
2020
*/
21+
2122
#include "nbc_internal.h"
2223
#include "ompi/mca/coll/base/coll_tags.h"
2324
#include "ompi/op/op.h"
@@ -257,6 +258,23 @@ int NBC_Sched_unpack (void *inbuf, char tmpinbuf, int count, MPI_Datatype dataty
257258
return OMPI_SUCCESS;
258259
}
259260

261+
/* this function schedule the release of one datatype */
262+
int NBC_Sched_datatype (MPI_Datatype datatype, NBC_Schedule *schedule) {
263+
int ret;
264+
NBC_Args_datatype datatype_args;
265+
datatype_args.type = DATATYPE;
266+
datatype_args.datatype = datatype;
267+
ret = nbc_schedule_round_append (schedule, &datatype_args, sizeof (datatype_args), false);
268+
if (OMPI_SUCCESS != ret) {
269+
return ret;
270+
}
271+
OBJ_RETAIN(datatype);
272+
273+
NBC_DEBUG(10, "added datatype - ends at byte %i\n", nbc_schedule_get_size (schedule));
274+
275+
return OMPI_SUCCESS;
276+
}
277+
260278
/* this function ends a round of a schedule */
261279
int NBC_Sched_barrier (NBC_Schedule *schedule) {
262280
return nbc_schedule_round_append (schedule, NULL, 0, true);
@@ -390,6 +408,7 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
390408
NBC_Args_copy copyargs;
391409
NBC_Args_unpack unpackargs;
392410
void *buf1, *buf2;
411+
NBC_Args_datatype datatypeargs;
393412

394413
/* get round-schedule address */
395414
ptr = handle->schedule->data + handle->row_offset;
@@ -535,6 +554,15 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
535554
}
536555

537556
break;
557+
558+
case DATATYPE:
559+
NBC_DEBUG(5, " DATATYPE(offset %li) ", offset);
560+
NBC_GET_BYTES(ptr,datatypeargs);
561+
OBJ_RELEASE(datatypeargs.datatype);
562+
res = OMPI_SUCCESS;
563+
564+
break;
565+
538566
default:
539567
NBC_Error ("NBC_Start_round: bad type %li at offset %li", (long)type, offset);
540568
return OMPI_ERROR;

ompi/mca/coll/libnbc/nbc_ibcast.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Corporation. All rights reserved.
66
* Copyright (c) 2006 The Technical University of Chemnitz. All
77
* rights reserved.
8-
* Copyright (c) 2014-2015 Research Organization for Information Science
8+
* Copyright (c) 2014-2016 Research Organization for Information Science
99
* and Technology (RIST). All rights reserved.
1010
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1111
* reserved.
@@ -108,6 +108,12 @@ int ompi_coll_libnbc_ibcast(void *buffer, int count, MPI_Datatype datatype, int
108108
return res;
109109
}
110110

111+
res = NBC_Sched_datatype (datatype, schedule);
112+
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
113+
OBJ_RELEASE(schedule);
114+
return res;
115+
}
116+
111117
res = NBC_Sched_commit (schedule);
112118
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
113119
OBJ_RELEASE(schedule);

ompi/mca/coll/libnbc/nbc_internal.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ typedef enum {
8181
RECV,
8282
OP,
8383
COPY,
84-
UNPACK
84+
UNPACK,
85+
DATATYPE
8586
} NBC_Fn_type;
8687

8788
/* the send argument struct */
@@ -142,6 +143,12 @@ typedef struct {
142143
char tmpoutbuf;
143144
} NBC_Args_unpack;
144145

146+
/* release datatype */
147+
typedef struct {
148+
NBC_Fn_type type;
149+
MPI_Datatype datatype;
150+
} NBC_Args_datatype;
151+
145152
/* internal function prototypes */
146153
int NBC_Sched_send (const void* buf, char tmpbuf, int count, MPI_Datatype datatype, int dest, NBC_Schedule *schedule, bool barrier);
147154
int NBC_Sched_local_send (const void* buf, char tmpbuf, int count, MPI_Datatype datatype, int dest,NBC_Schedule *schedule, bool barrier);
@@ -153,6 +160,7 @@ int NBC_Sched_copy (void *src, char tmpsrc, int srccount, MPI_Datatype srctype,
153160
MPI_Datatype tgttype, NBC_Schedule *schedule, bool barrier);
154161
int NBC_Sched_unpack (void *inbuf, char tmpinbuf, int count, MPI_Datatype datatype, void *outbuf, char tmpoutbuf,
155162
NBC_Schedule *schedule, bool barrier);
163+
int NBC_Sched_datatype (MPI_Datatype datatype, NBC_Schedule *schedule);
156164

157165
int NBC_Sched_barrier (NBC_Schedule *schedule);
158166
int NBC_Sched_commit (NBC_Schedule *schedule);
@@ -330,6 +338,10 @@ static inline void nbc_get_round_size (char *p, unsigned long *size) {
330338
/*printf("found a UNPACK at offset %li\n", (long)p-(long)schedule); */
331339
offset += sizeof(NBC_Args_unpack);
332340
break;
341+
case DATATYPE:
342+
/*printf("found a DATATYPE at offset%li\n", (long)p-(long)schedule); */
343+
offset += sizeof(NBC_Args_datatype);
344+
break;
333345
default:
334346
NBC_Error("NBC_GET_ROUND_SIZE: bad type %i at offset %li", type, offset);
335347
return;

0 commit comments

Comments
 (0)