Skip to content

Commit 42cf4a3

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 18c5a21 commit 42cf4a3

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

ompi/mca/coll/libnbc/nbc.c

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
* rights reserved.
1111
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1212
* reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2016 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
*
1616
* Author(s): Torsten Hoefler <[email protected]>
1717
*
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"
@@ -241,6 +242,23 @@ int NBC_Sched_unpack (void *inbuf, char tmpinbuf, int count, MPI_Datatype dataty
241242
return OMPI_SUCCESS;
242243
}
243244

245+
/* this function schedule the release of one datatype */
246+
int NBC_Sched_datatype (MPI_Datatype datatype, NBC_Schedule *schedule) {
247+
int ret;
248+
NBC_Args_datatype datatype_args;
249+
datatype_args.type = DATATYPE;
250+
datatype_args.datatype = datatype;
251+
ret = nbc_schedule_round_append (schedule, &datatype_args, sizeof (datatype_args), false);
252+
if (OMPI_SUCCESS != ret) {
253+
return ret;
254+
}
255+
OBJ_RETAIN(datatype);
256+
257+
NBC_DEBUG(10, "added datatype - ends at byte %i\n", nbc_schedule_get_size (schedule));
258+
259+
return OMPI_SUCCESS;
260+
}
261+
244262
/* this function ends a round of a schedule */
245263
int NBC_Sched_barrier (NBC_Schedule *schedule) {
246264
return nbc_schedule_round_append (schedule, NULL, 0, true);
@@ -373,6 +391,7 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
373391
NBC_Args_op opargs;
374392
NBC_Args_copy copyargs;
375393
NBC_Args_unpack unpackargs;
394+
NBC_Args_datatype datatypeargs;
376395
void *buf1, *buf2, *buf3;
377396

378397
/* get round-schedule address */
@@ -524,6 +543,15 @@ static inline int NBC_Start_round(NBC_Handle *handle) {
524543
}
525544

526545
break;
546+
547+
case DATATYPE:
548+
NBC_DEBUG(5, " DATATYPE(offset %li) ", offset);
549+
NBC_GET_BYTES(ptr,datatypeargs);
550+
OBJ_RELEASE(datatypeargs.datatype);
551+
res = OMPI_SUCCESS;
552+
553+
break;
554+
527555
default:
528556
NBC_Error ("NBC_Start_round: bad type %li at offset %li", (long)type, offset);
529557
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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
1212
* Copyright (c) 2014 NVIDIA Corporation. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2016 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
@@ -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_recv (void* buf, char tmpbuf, int count, MPI_Datatype datatype, int source, NBC_Schedule *schedule, bool barrier);
@@ -151,6 +158,7 @@ int NBC_Sched_copy (void *src, char tmpsrc, int srccount, MPI_Datatype srctype,
151158
MPI_Datatype tgttype, NBC_Schedule *schedule, bool barrier);
152159
int NBC_Sched_unpack (void *inbuf, char tmpinbuf, int count, MPI_Datatype datatype, void *outbuf, char tmpoutbuf,
153160
NBC_Schedule *schedule, bool barrier);
161+
int NBC_Sched_datatype (MPI_Datatype datatype, NBC_Schedule *schedule);
154162

155163
int NBC_Sched_barrier (NBC_Schedule *schedule);
156164
int NBC_Sched_commit (NBC_Schedule *schedule);
@@ -328,6 +336,10 @@ static inline void nbc_get_round_size (char *p, unsigned long *size) {
328336
/*printf("found a UNPACK at offset %li\n", (long)p-(long)schedule); */
329337
offset += sizeof(NBC_Args_unpack);
330338
break;
339+
case DATATYPE:
340+
/*printf("found a DATATYPE at offset%li\n", (long)p-(long)schedule); */
341+
offset += sizeof(NBC_Args_datatype);
342+
break;
331343
default:
332344
NBC_Error("NBC_GET_ROUND_SIZE: bad type %i at offset %li", type, offset);
333345
return;

0 commit comments

Comments
 (0)