Skip to content

Commit

Permalink
coll/libnbc: revisit NBC_Handle usage
Browse files Browse the repository at this point in the history
make NBC_Handle (almost) an internal structure created
by NBC_Schedule_request()
use a local variable instead of what was previously handle->tmpbuf

Refs #3487

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>

(back-ported from commit 9ba85b8)
  • Loading branch information
ggouaillardet committed Aug 8, 2017
1 parent 30c3b35 commit 608726a
Show file tree
Hide file tree
Showing 26 changed files with 373 additions and 654 deletions.
3 changes: 2 additions & 1 deletion ompi/mca/coll/libnbc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights
# reserved.
# Copyright (c) 2017 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand All @@ -37,7 +39,6 @@ sources = \
nbc_ialltoallw.c \
nbc_ibarrier.c \
nbc_ibcast.c \
nbc_ibcast_inter.c \
nbc_iexscan.c \
nbc_igather.c \
nbc_igatherv.c \
Expand Down
21 changes: 20 additions & 1 deletion ompi/mca/coll/libnbc/nbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
Expand Down Expand Up @@ -709,6 +709,25 @@ int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule) {
return OMPI_SUCCESS;
}

int NBC_Schedule_request(NBC_Schedule *schedule, ompi_communicator_t *comm, ompi_coll_libnbc_module_t *module, ompi_request_t **request, void *tmpbuf) {
int res;
NBC_Handle *handle;
res = NBC_Init_handle (comm, &handle, module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
handle->tmpbuf = tmpbuf;

res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}

*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}

#ifdef NBC_CACHE_SCHEDULE
void NBC_SchedCache_args_delete_key_dummy(void *k) {
/* do nothing because the key and the data element are identical :-)
Expand Down
22 changes: 2 additions & 20 deletions ompi/mca/coll/libnbc/nbc_iallgather.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
#ifdef NBC_CACHE_SCHEDULE
NBC_Allgather_args *args, *found, search;
#endif
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;

NBC_IN_PLACE(sendbuf, recvbuf, inplace);
Expand Down Expand Up @@ -147,20 +146,12 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
}
#endif

res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}

res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
return res;
}

*request = (ompi_request_t *) handle;

return OMPI_SUCCESS;
}

Expand All @@ -172,7 +163,6 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
MPI_Aint rcvext;
NBC_Schedule *schedule;
char *rbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;

res = ompi_datatype_type_extent(recvtype, &rcvext);
Expand Down Expand Up @@ -213,19 +203,11 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
return res;
}

res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}

res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
return res;
}

*request = (ompi_request_t *) handle;

return OMPI_SUCCESS;
}
24 changes: 3 additions & 21 deletions ompi/mca/coll/libnbc/nbc_iallgatherv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
*/
Expand All @@ -37,7 +37,6 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
MPI_Aint rcvext;
NBC_Schedule *schedule;
char *rbuf, *sbuf, inplace;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;

NBC_IN_PLACE(sendbuf, recvbuf, inplace);
Expand Down Expand Up @@ -96,20 +95,12 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
return res;
}

res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request (schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}

res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}

*request = (ompi_request_t *) handle;

return OMPI_SUCCESS;
}

Expand All @@ -120,7 +111,6 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
int res, rsize;
MPI_Aint rcvext;
NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;

rsize = ompi_comm_remote_size (comm);
Expand Down Expand Up @@ -165,19 +155,11 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
return res;
}

res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}

res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}

*request = (ompi_request_t *) handle;

return OMPI_SUCCESS;
}
Loading

0 comments on commit 608726a

Please sign in to comment.