Skip to content

Commit 9ba85b8

Browse files
committed
coll/libnbc: revisit NBC_Handle usage
make NBC_Handle (almost) an internal structure created by NBC_Schedule_request() use a local variable instead of what was previously handle->tmpbuf Refs open-mpi#3487 Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 68ac950 commit 9ba85b8

26 files changed

+363
-652
lines changed

ompi/mca/coll/libnbc/Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
1313
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights
1414
# reserved.
15+
# Copyright (c) 2017 Research Organization for Information Science
16+
# and Technology (RIST). All rights reserved.
1517
# $COPYRIGHT$
1618
#
1719
# Additional copyrights may follow
@@ -37,7 +39,6 @@ sources = \
3739
nbc_ialltoallw.c \
3840
nbc_ibarrier.c \
3941
nbc_ibcast.c \
40-
nbc_ibcast_inter.c \
4142
nbc_iexscan.c \
4243
nbc_igather.c \
4344
nbc_igatherv.c \

ompi/mca/coll/libnbc/nbc.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* rights reserved.
1111
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1212
* reserved.
13-
* Copyright (c) 2015-2016 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
*
1616
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
@@ -709,6 +709,25 @@ int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule) {
709709
return OMPI_SUCCESS;
710710
}
711711

712+
int NBC_Schedule_request(NBC_Schedule *schedule, ompi_communicator_t *comm, ompi_coll_libnbc_module_t *module, ompi_request_t **request, void *tmpbuf) {
713+
int res;
714+
NBC_Handle *handle;
715+
res = NBC_Init_handle (comm, &handle, module);
716+
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
717+
return res;
718+
}
719+
handle->tmpbuf = tmpbuf;
720+
721+
res = NBC_Start (handle, schedule);
722+
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
723+
NBC_Return_handle (handle);
724+
return res;
725+
}
726+
727+
*request = (ompi_request_t *) handle;
728+
return OMPI_SUCCESS;
729+
}
730+
712731
#ifdef NBC_CACHE_SCHEDULE
713732
void NBC_SchedCache_args_delete_key_dummy(void *k) {
714733
/* do nothing because the key and the data element are identical :-)

ompi/mca/coll/libnbc/nbc_iallgather.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
5454
#ifdef NBC_CACHE_SCHEDULE
5555
NBC_Allgather_args *args, *found, search;
5656
#endif
57-
NBC_Handle *handle;
5857
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
5958

6059
NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@@ -155,20 +154,12 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
155154
}
156155
#endif
157156

158-
res = NBC_Init_handle (comm, &handle, libnbc_module);
157+
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
159158
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
160159
OBJ_RELEASE(schedule);
161160
return res;
162161
}
163162

164-
res = NBC_Start (handle, schedule);
165-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
166-
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
167-
return res;
168-
}
169-
170-
*request = (ompi_request_t *) handle;
171-
172163
return OMPI_SUCCESS;
173164
}
174165

@@ -180,7 +171,6 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
180171
MPI_Aint rcvext;
181172
NBC_Schedule *schedule;
182173
char *rbuf;
183-
NBC_Handle *handle;
184174
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
185175

186176
res = ompi_datatype_type_extent(recvtype, &rcvext);
@@ -221,19 +211,11 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
221211
return res;
222212
}
223213

224-
res = NBC_Init_handle (comm, &handle, libnbc_module);
214+
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
225215
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
226216
OBJ_RELEASE(schedule);
227217
return res;
228218
}
229219

230-
res = NBC_Start (handle, schedule);
231-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
232-
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
233-
return res;
234-
}
235-
236-
*request = (ompi_request_t *) handle;
237-
238220
return OMPI_SUCCESS;
239221
}

ompi/mca/coll/libnbc/nbc_iallgatherv.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
1212
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1313
* reserved.
14-
* Copyright (c) 2014-2016 Research Organization for Information Science
14+
* Copyright (c) 2014-2017 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1717
* $COPYRIGHT$
@@ -41,7 +41,6 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
4141
MPI_Aint rcvext;
4242
NBC_Schedule *schedule;
4343
char *rbuf, *sbuf, inplace;
44-
NBC_Handle *handle;
4544
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
4645

4746
NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@@ -100,20 +99,12 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
10099
return res;
101100
}
102101

103-
res = NBC_Init_handle (comm, &handle, libnbc_module);
102+
res = NBC_Schedule_request (schedule, comm, libnbc_module, request, NULL);
104103
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
105104
OBJ_RELEASE(schedule);
106105
return res;
107106
}
108107

109-
res = NBC_Start (handle, schedule);
110-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
111-
NBC_Return_handle (handle);
112-
return res;
113-
}
114-
115-
*request = (ompi_request_t *) handle;
116-
117108
return OMPI_SUCCESS;
118109
}
119110

@@ -124,7 +115,6 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
124115
int res, rsize;
125116
MPI_Aint rcvext;
126117
NBC_Schedule *schedule;
127-
NBC_Handle *handle;
128118
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
129119

130120
rsize = ompi_comm_remote_size (comm);
@@ -169,19 +159,11 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
169159
return res;
170160
}
171161

172-
res = NBC_Init_handle (comm, &handle, libnbc_module);
162+
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
173163
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
174164
OBJ_RELEASE(schedule);
175165
return res;
176166
}
177167

178-
res = NBC_Start (handle, schedule);
179-
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
180-
NBC_Return_handle (handle);
181-
return res;
182-
}
183-
184-
*request = (ompi_request_t *) handle;
185-
186168
return OMPI_SUCCESS;
187169
}

0 commit comments

Comments
 (0)