1
1

Merge pull request #3719 from ggouaillardet/topic/libnbc_revamp

coll/libnbc: revisit NBC_Handle usage
Этот коммит содержится в:
Gilles Gouaillardet 2017-06-29 11:13:58 +09:00 коммит произвёл GitHub
родитель eee4579f5a 9ba85b85e1
Коммит 7e5e5fe887
26 изменённых файлов: 363 добавлений и 652 удалений

Просмотреть файл

@ -12,6 +12,8 @@
# Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights # Copyright (c) 2013 Los Alamos National Security, LLC. All rights
# reserved. # reserved.
# Copyright (c) 2017 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# $COPYRIGHT$ # $COPYRIGHT$
# #
# Additional copyrights may follow # Additional copyrights may follow
@ -37,7 +39,6 @@ sources = \
nbc_ialltoallw.c \ nbc_ialltoallw.c \
nbc_ibarrier.c \ nbc_ibarrier.c \
nbc_ibcast.c \ nbc_ibcast.c \
nbc_ibcast_inter.c \
nbc_iexscan.c \ nbc_iexscan.c \
nbc_igather.c \ nbc_igather.c \
nbc_igatherv.c \ nbc_igatherv.c \

Просмотреть файл

@ -10,7 +10,7 @@
* rights reserved. * rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* *
* Author(s): Torsten Hoefler <htor@cs.indiana.edu> * Author(s): Torsten Hoefler <htor@cs.indiana.edu>
@ -709,6 +709,25 @@ int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule) {
return OMPI_SUCCESS; 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 #ifdef NBC_CACHE_SCHEDULE
void NBC_SchedCache_args_delete_key_dummy(void *k) { void NBC_SchedCache_args_delete_key_dummy(void *k) {
/* do nothing because the key and the data element are identical :-) /* do nothing because the key and the data element are identical :-)

Просмотреть файл

@ -54,7 +54,6 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
#ifdef NBC_CACHE_SCHEDULE #ifdef NBC_CACHE_SCHEDULE
NBC_Allgather_args *args, *found, search; NBC_Allgather_args *args, *found, search;
#endif #endif
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -155,20 +154,12 @@ int ompi_coll_libnbc_iallgather(const void* sendbuf, int sendcount, MPI_Datatype
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -180,7 +171,6 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf; char *rbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
res = ompi_datatype_type_extent(recvtype, &rcvext); res = ompi_datatype_type_extent(recvtype, &rcvext);
@ -221,19 +211,11 @@ int ompi_coll_libnbc_iallgather_inter(const void* sendbuf, int sendcount, MPI_Da
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -41,7 +41,6 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, *sbuf, inplace; char *rbuf, *sbuf, inplace;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -100,20 +99,12 @@ int ompi_coll_libnbc_iallgatherv(const void* sendbuf, int sendcount, MPI_Datatyp
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -124,7 +115,6 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
int res, rsize; int res, rsize;
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -169,19 +159,11 @@ int ompi_coll_libnbc_iallgatherv_inter(const void* sendbuf, int sendcount, MPI_D
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -25,13 +25,13 @@
#include <assert.h> #include <assert.h>
static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype datatype, ptrdiff_t gap, const void *sendbuf, static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype datatype, ptrdiff_t gap, const void *sendbuf,
void *recvbuf, MPI_Op op, char inplace, NBC_Schedule *schedule, NBC_Handle *handle); void *recvbuf, MPI_Op op, char inplace, NBC_Schedule *schedule, void *tmpbuf);
static inline int allred_sched_ring(int rank, int p, int count, MPI_Datatype datatype, const void *sendbuf, static inline int allred_sched_ring(int rank, int p, int count, MPI_Datatype datatype, const void *sendbuf,
void *recvbuf, MPI_Op op, int size, int ext, NBC_Schedule *schedule, void *recvbuf, MPI_Op op, int size, int ext, NBC_Schedule *schedule,
NBC_Handle *handle); void *tmpbuf);
static inline int allred_sched_linear(int rank, int p, const void *sendbuf, void *recvbuf, int count, static inline int allred_sched_linear(int rank, int p, const void *sendbuf, void *recvbuf, int count,
MPI_Datatype datatype, ptrdiff_t gap, MPI_Op op, int ext, int size, MPI_Datatype datatype, ptrdiff_t gap, MPI_Op op, int ext, int size,
NBC_Schedule *schedule, NBC_Handle *handle); NBC_Schedule *schedule, void *tmpbuf);
#ifdef NBC_CACHE_SCHEDULE #ifdef NBC_CACHE_SCHEDULE
/* tree comparison function for schedule cache */ /* tree comparison function for schedule cache */
@ -65,7 +65,7 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
#endif #endif
enum { NBC_ARED_BINOMIAL, NBC_ARED_RING } alg; enum { NBC_ARED_BINOMIAL, NBC_ARED_RING } alg;
char inplace; char inplace;
NBC_Handle *handle = NULL; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap; ptrdiff_t span, gap;
@ -91,7 +91,6 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
/* for a single node - copy data to receivebuf */ /* for a single node - copy data to receivebuf */
res = NBC_Copy(sendbuf, count, datatype, recvbuf, count, datatype, comm); res = NBC_Copy(sendbuf, count, datatype, recvbuf, count, datatype, comm);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res; return res;
} }
} }
@ -99,15 +98,9 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -130,30 +123,29 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
#endif #endif
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) { if (NULL == schedule) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* ensure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) { switch(alg) {
case NBC_ARED_BINOMIAL: case NBC_ARED_BINOMIAL:
res = allred_sched_diss(rank, p, count, datatype, gap, sendbuf, recvbuf, op, inplace, schedule, handle); res = allred_sched_diss(rank, p, count, datatype, gap, sendbuf, recvbuf, op, inplace, schedule, tmpbuf);
break; break;
case NBC_ARED_RING: case NBC_ARED_RING:
res = allred_sched_ring(rank, p, count, datatype, sendbuf, recvbuf, op, size, ext, schedule, handle); res = allred_sched_ring(rank, p, count, datatype, sendbuf, recvbuf, op, size, ext, schedule, tmpbuf);
break; break;
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -188,15 +180,13 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
} }
#endif #endif
res = NBC_Start (handle, schedule); res = NBC_Schedule_request (schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -208,7 +198,7 @@ int ompi_coll_libnbc_iallreduce_inter(const void* sendbuf, void* recvbuf, int co
size_t size; size_t size;
MPI_Aint ext; MPI_Aint ext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap; ptrdiff_t span, gap;
@ -227,49 +217,40 @@ int ompi_coll_libnbc_iallreduce_inter(const void* sendbuf, void* recvbuf, int co
return res; return res;
} }
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* ensure the schedule is released with the handle on error */
handle->schedule = schedule;
res = allred_sched_linear (rank, rsize, sendbuf, recvbuf, count, datatype, gap, op, res = allred_sched_linear (rank, rsize, sendbuf, recvbuf, count, datatype, gap, op,
ext, size, schedule, handle); ext, size, schedule, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -310,7 +291,7 @@ int ompi_coll_libnbc_iallreduce_inter(const void* sendbuf, void* recvbuf, int co
if (vrank == root) rank = 0; \ if (vrank == root) rank = 0; \
} }
static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype datatype, ptrdiff_t gap, const void *sendbuf, void *recvbuf, static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype datatype, ptrdiff_t gap, const void *sendbuf, void *recvbuf,
MPI_Op op, char inplace, NBC_Schedule *schedule, NBC_Handle *handle) { MPI_Op op, char inplace, NBC_Schedule *schedule, void *tmpbuf) {
int root, vrank, maxr, vpeer, peer, res; int root, vrank, maxr, vpeer, peer, res;
char *rbuf, *lbuf, *buf; char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf; int tmprbuf, tmplbuf;
@ -330,7 +311,7 @@ static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype dat
rbuf = recvbuf; rbuf = recvbuf;
tmprbuf = false; tmprbuf = false;
if (inplace) { if (inplace) {
res = NBC_Copy(rbuf, count, datatype, ((char *)handle->tmpbuf) - gap, count, datatype, MPI_COMM_SELF); res = NBC_Copy(rbuf, count, datatype, ((char *)tmpbuf) - gap, count, datatype, MPI_COMM_SELF);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res; return res;
} }
@ -349,7 +330,7 @@ static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype dat
return res; return res;
} }
/* this cannot be done until handle->tmpbuf is unused :-( so barrier after the op */ /* this cannot be done until tmpbuf is unused :-( so barrier after the op */
if (firstred && !inplace) { if (firstred && !inplace) {
/* perform the reduce with the senbuf */ /* perform the reduce with the senbuf */
res = NBC_Sched_op (sendbuf, false, rbuf, tmprbuf, count, datatype, op, schedule, true); res = NBC_Sched_op (sendbuf, false, rbuf, tmprbuf, count, datatype, op, schedule, true);
@ -425,7 +406,7 @@ static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype dat
} }
static inline int allred_sched_ring (int r, int p, int count, MPI_Datatype datatype, const void *sendbuf, void *recvbuf, MPI_Op op, static inline int allred_sched_ring (int r, int p, int count, MPI_Datatype datatype, const void *sendbuf, void *recvbuf, MPI_Op op,
int size, int ext, NBC_Schedule *schedule, NBC_Handle *handle) { int size, int ext, NBC_Schedule *schedule, void *tmpbuf) {
int segsize, *segsizes, *segoffsets; /* segment sizes and offsets per segment (number of segments == number of nodes */ int segsize, *segsizes, *segoffsets; /* segment sizes and offsets per segment (number of segments == number of nodes */
int speer, rpeer; /* send and recvpeer */ int speer, rpeer; /* send and recvpeer */
int res = OMPI_SUCCESS; int res = OMPI_SUCCESS;
@ -625,7 +606,7 @@ static inline int allred_sched_ring (int r, int p, int count, MPI_Datatype datat
} }
static inline int allred_sched_linear(int rank, int rsize, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, static inline int allred_sched_linear(int rank, int rsize, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
ptrdiff_t gap, MPI_Op op, int ext, int size, NBC_Schedule *schedule, NBC_Handle *handle) { ptrdiff_t gap, MPI_Op op, int ext, int size, NBC_Schedule *schedule, void *tmpbuf) {
int res; int res;
if (0 == count) { if (0 == count) {

Просмотреть файл

@ -8,7 +8,7 @@
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2014 NVIDIA Corporation. All rights reserved. * Copyright (c) 2014 NVIDIA Corporation. 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -28,7 +28,7 @@ static inline int a2a_sched_pairwise(int rank, int p, MPI_Aint sndext, MPI_Aint
int recvcount, MPI_Datatype recvtype, MPI_Comm comm); int recvcount, MPI_Datatype recvtype, MPI_Comm comm);
static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcvext, NBC_Schedule* schedule, static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcvext, NBC_Schedule* schedule,
const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf,
int recvcount, MPI_Datatype recvtype, MPI_Comm comm, NBC_Handle *handle); int recvcount, MPI_Datatype recvtype, MPI_Comm comm, void* tmpbuf);
static inline int a2a_sched_inplace(int rank, int p, NBC_Schedule* schedule, void* buf, int count, static inline int a2a_sched_inplace(int rank, int p, NBC_Schedule* schedule, void* buf, int count,
MPI_Datatype type, MPI_Aint ext, ptrdiff_t gap, MPI_Comm comm); MPI_Datatype type, MPI_Aint ext, ptrdiff_t gap, MPI_Comm comm);
@ -66,7 +66,7 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
#endif #endif
char *rbuf, *sbuf, inplace; char *rbuf, *sbuf, inplace;
enum {NBC_A2A_LINEAR, NBC_A2A_PAIRWISE, NBC_A2A_DISS, NBC_A2A_INPLACE} alg; enum {NBC_A2A_LINEAR, NBC_A2A_PAIRWISE, NBC_A2A_DISS, NBC_A2A_INPLACE} alg;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap; ptrdiff_t span, gap;
@ -119,17 +119,11 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
} }
} }
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
/* allocate temp buffer if we need one */ /* allocate temp buffer if we need one */
if (alg == NBC_A2A_INPLACE) { if (alg == NBC_A2A_INPLACE) {
span = opal_datatype_span(&recvtype->super, recvcount, &gap); span = opal_datatype_span(&recvtype->super, recvcount, &gap);
handle->tmpbuf = malloc(span); tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
} else if (alg == NBC_A2A_DISS) { } else if (alg == NBC_A2A_DISS) {
@ -140,21 +134,19 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
res = PMPI_Pack_size (sendcount, sendtype, comm, &datasize); res = PMPI_Pack_size (sendcount, sendtype, comm, &datasize);
if (MPI_SUCCESS != res) { if (MPI_SUCCESS != res) {
NBC_Error("MPI Error in PMPI_Pack_size() (%i)", res); NBC_Error("MPI Error in PMPI_Pack_size() (%i)", res);
NBC_Return_handle (handle);
return res; return res;
} }
} }
/* allocate temporary buffers */ /* allocate temporary buffers */
if ((p & 1) == 0) { if ((p & 1) == 0) {
handle->tmpbuf = malloc (datasize * p * 2); tmpbuf = malloc (datasize * p * 2);
} else { } else {
/* we cannot divide p by two, so alloc more to be safe ... */ /* we cannot divide p by two, so alloc more to be safe ... */
handle->tmpbuf = malloc (datasize * (p / 2 + 1) * 2 * 2); tmpbuf = malloc (datasize * (p / 2 + 1) * 2 * 2);
} }
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -165,29 +157,29 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
if (NBC_Type_intrinsic(sendtype)) { if (NBC_Type_intrinsic(sendtype)) {
#endif /* OPAL_CUDA_SUPPORT */ #endif /* OPAL_CUDA_SUPPORT */
/* contiguous - just copy (1st copy) */ /* contiguous - just copy (1st copy) */
memcpy (handle->tmpbuf, (char *) sendbuf + datasize * rank, datasize * (p - rank)); memcpy (tmpbuf, (char *) sendbuf + datasize * rank, datasize * (p - rank));
if (rank != 0) { if (rank != 0) {
memcpy ((char *) handle->tmpbuf + datasize * (p - rank), sendbuf, datasize * rank); memcpy ((char *) tmpbuf + datasize * (p - rank), sendbuf, datasize * rank);
} }
} else { } else {
int pos=0; int pos=0;
/* non-contiguous - pack */ /* non-contiguous - pack */
res = PMPI_Pack ((char *) sendbuf + rank * sendcount * sndext, (p - rank) * sendcount, sendtype, handle->tmpbuf, res = PMPI_Pack ((char *) sendbuf + rank * sendcount * sndext, (p - rank) * sendcount, sendtype, tmpbuf,
(p - rank) * datasize, &pos, comm); (p - rank) * datasize, &pos, comm);
if (OPAL_UNLIKELY(MPI_SUCCESS != res)) { if (OPAL_UNLIKELY(MPI_SUCCESS != res)) {
NBC_Error("MPI Error in PMPI_Pack() (%i)", res); NBC_Error("MPI Error in PMPI_Pack() (%i)", res);
NBC_Return_handle (handle); free(tmpbuf);
return res; return res;
} }
if (rank != 0) { if (rank != 0) {
pos = 0; pos = 0;
res = PMPI_Pack(sendbuf, rank * sendcount, sendtype, (char *) handle->tmpbuf + datasize * (p - rank), res = PMPI_Pack(sendbuf, rank * sendcount, sendtype, (char *) tmpbuf + datasize * (p - rank),
rank * datasize, &pos, comm); rank * datasize, &pos, comm);
if (OPAL_UNLIKELY(MPI_SUCCESS != res)) { if (OPAL_UNLIKELY(MPI_SUCCESS != res)) {
NBC_Error("MPI Error in PMPI_Pack() (%i)", res); NBC_Error("MPI Error in PMPI_Pack() (%i)", res);
NBC_Return_handle (handle); free(tmpbuf);
return res; return res;
} }
} }
@ -208,13 +200,10 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
/* not found - generate new schedule */ /* not found - generate new schedule */
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* ensure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) { switch(alg) {
case NBC_A2A_INPLACE: case NBC_A2A_INPLACE:
res = a2a_sched_inplace(rank, p, schedule, recvbuf, recvcount, recvtype, rcvext, gap, comm); res = a2a_sched_inplace(rank, p, schedule, recvbuf, recvcount, recvtype, rcvext, gap, comm);
@ -223,7 +212,7 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
res = a2a_sched_linear(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); res = a2a_sched_linear(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
break; break;
case NBC_A2A_DISS: case NBC_A2A_DISS:
res = a2a_sched_diss(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, handle); res = a2a_sched_diss(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, tmpbuf);
break; break;
case NBC_A2A_PAIRWISE: case NBC_A2A_PAIRWISE:
res = a2a_sched_pairwise(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); res = a2a_sched_pairwise(rank, p, sndext, rcvext, schedule, sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
@ -231,13 +220,15 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -273,14 +264,13 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
} }
#endif #endif
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -292,7 +282,6 @@ int ompi_coll_libnbc_ialltoall_inter (const void* sendbuf, int sendcount, MPI_Da
MPI_Aint sndext, rcvext; MPI_Aint sndext, rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, *sbuf; char *rbuf, *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -341,20 +330,12 @@ int ompi_coll_libnbc_ialltoall_inter (const void* sendbuf, int sendcount, MPI_Da
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -416,7 +397,7 @@ static inline int a2a_sched_linear(int rank, int p, MPI_Aint sndext, MPI_Aint rc
static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcvext, NBC_Schedule* schedule, static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcvext, NBC_Schedule* schedule,
const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount, const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
MPI_Datatype recvtype, MPI_Comm comm, NBC_Handle *handle) { MPI_Datatype recvtype, MPI_Comm comm, void* tmpbuf) {
int res, speer, rpeer, datasize, offset, virtp; int res, speer, rpeer, datasize, offset, virtp;
char *rbuf, *rtmpbuf, *stmpbuf; char *rbuf, *rtmpbuf, *stmpbuf;
@ -436,13 +417,13 @@ static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcve
/* allocate temporary buffers */ /* allocate temporary buffers */
if ((p & 1) == 0) { if ((p & 1) == 0) {
rtmpbuf = (char *) handle->tmpbuf + datasize * p; rtmpbuf = (char *)tmpbuf + datasize * p;
stmpbuf = (char *) handle->tmpbuf + datasize * (p + p / 2); stmpbuf = (char *)tmpbuf + datasize * (p + p / 2);
} else { } else {
/* we cannot divide p by two, so alloc more to be safe ... */ /* we cannot divide p by two, so alloc more to be safe ... */
virtp = (p / 2 + 1) * 2; virtp = (p / 2 + 1) * 2;
rtmpbuf = (char *) handle->tmpbuf + datasize * p; rtmpbuf = (char *)tmpbuf + datasize * p;
stmpbuf = (char *) handle->tmpbuf + datasize * (p + virtp / 2); stmpbuf = (char *)tmpbuf + datasize * (p + virtp / 2);
} }
/* phase 2 - communicate */ /* phase 2 - communicate */
@ -454,7 +435,7 @@ static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcve
/* copy data to sendbuffer (2nd copy) - could be avoided using iovecs */ /* copy data to sendbuffer (2nd copy) - could be avoided using iovecs */
/*printf("[%i] round %i: copying element %i to buffer %lu\n", rank, r, i, (unsigned long)(stmpbuf+offset));*/ /*printf("[%i] round %i: copying element %i to buffer %lu\n", rank, r, i, (unsigned long)(stmpbuf+offset));*/
res = NBC_Sched_copy((void *)(intptr_t)(i * datasize), true, datasize, MPI_BYTE, stmpbuf + offset - res = NBC_Sched_copy((void *)(intptr_t)(i * datasize), true, datasize, MPI_BYTE, stmpbuf + offset -
(intptr_t) handle->tmpbuf, true, datasize, MPI_BYTE, schedule, false); (intptr_t)tmpbuf, true, datasize, MPI_BYTE, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res; return res;
} }
@ -466,12 +447,12 @@ static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcve
/* add p because modulo does not work with negative values */ /* add p because modulo does not work with negative values */
rpeer = ((rank - r) + p) % p; rpeer = ((rank - r) + p) % p;
res = NBC_Sched_recv (rtmpbuf - (intptr_t) handle->tmpbuf, true, offset, MPI_BYTE, rpeer, schedule, false); res = NBC_Sched_recv (rtmpbuf - (intptr_t)tmpbuf, true, offset, MPI_BYTE, rpeer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res; return res;
} }
res = NBC_Sched_send (stmpbuf - (intptr_t) handle->tmpbuf, true, offset, MPI_BYTE, speer, schedule, true); res = NBC_Sched_send (stmpbuf - (intptr_t)tmpbuf, true, offset, MPI_BYTE, speer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res; return res;
} }
@ -482,7 +463,7 @@ static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcve
/* test if bit r is set in rank number i */ /* test if bit r is set in rank number i */
if (i & r) { if (i & r) {
/* copy data to tmpbuffer (3rd copy) - could be avoided using iovecs */ /* copy data to tmpbuffer (3rd copy) - could be avoided using iovecs */
res = NBC_Sched_copy (rtmpbuf + offset - (intptr_t) handle->tmpbuf, true, datasize, MPI_BYTE, res = NBC_Sched_copy (rtmpbuf + offset - (intptr_t)tmpbuf, true, datasize, MPI_BYTE,
(void *)(intptr_t)(i * datasize), true, datasize, MPI_BYTE, schedule, (void *)(intptr_t)(i * datasize), true, datasize, MPI_BYTE, schedule,
false); false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
@ -494,8 +475,7 @@ static inline int a2a_sched_diss(int rank, int p, MPI_Aint sndext, MPI_Aint rcve
} }
} }
/* phase 3 - reorder - data is now in wrong order in handle->tmpbuf - /* phase 3 - reorder - data is now in wrong order in tmpbuf - reorder it into recvbuf */
* reorder it into recvbuf */
for (int i = 0 ; i < p; ++i) { for (int i = 0 ; i < p; ++i) {
rbuf = (char *) recvbuf + ((rank - i + p) % p) * recvcount * rcvext; rbuf = (char *) recvbuf + ((rank - i + p) % p) * recvcount * rcvext;
res = NBC_Sched_unpack ((void *)(intptr_t) (i * datasize), true, recvcount, recvtype, rbuf, false, schedule, res = NBC_Sched_unpack ((void *)(intptr_t) (i * datasize), true, recvcount, recvtype, rbuf, false, schedule,

Просмотреть файл

@ -50,7 +50,7 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, *sbuf, inplace; char *rbuf, *sbuf, inplace;
ptrdiff_t gap, span; ptrdiff_t gap, span;
NBC_Handle *handle; void * tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -64,11 +64,6 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
return res; return res;
} }
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
/* copy data to receivbuffer */ /* copy data to receivbuffer */
if (inplace) { if (inplace) {
int count = 0; int count = 0;
@ -80,12 +75,10 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
span = opal_datatype_span(&recvtype->super, count, &gap); span = opal_datatype_span(&recvtype->super, count, &gap);
if (OPAL_UNLIKELY(0 == span)) { if (OPAL_UNLIKELY(0 == span)) {
*request = &ompi_request_empty; *request = &ompi_request_empty;
NBC_Return_handle (handle);
return MPI_SUCCESS; return MPI_SUCCESS;
} }
handle->tmpbuf = malloc(span); tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
sendcounts = recvcounts; sendcounts = recvcounts;
@ -94,7 +87,6 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
res = ompi_datatype_type_extent (sendtype, &sndext); res = ompi_datatype_type_extent (sendtype, &sndext);
if (MPI_SUCCESS != res) { if (MPI_SUCCESS != res) {
NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res); NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
NBC_Return_handle (handle);
return res; return res;
} }
if (sendcounts[rank] != 0) { if (sendcounts[rank] != 0) {
@ -109,7 +101,7 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -123,27 +115,25 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
recvbuf, recvcounts, rdispls, rcvext, recvtype); recvbuf, recvcounts, rdispls, rcvext, recvtype);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -156,7 +146,6 @@ int ompi_coll_libnbc_ialltoallv_inter (const void* sendbuf, const int *sendcount
int res, rsize; int res, rsize;
MPI_Aint sndext, rcvext; MPI_Aint sndext, rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
@ -206,21 +195,12 @@ int ompi_coll_libnbc_ialltoallv_inter (const void* sendbuf, const int *sendcount
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; return res;
} }
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -49,7 +49,7 @@ int ompi_coll_libnbc_ialltoallw(const void* sendbuf, const int *sendcounts, cons
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, *sbuf, inplace; char *rbuf, *sbuf, inplace;
ptrdiff_t span=0; ptrdiff_t span=0;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -57,11 +57,6 @@ int ompi_coll_libnbc_ialltoallw(const void* sendbuf, const int *sendcounts, cons
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
p = ompi_comm_size (comm); p = ompi_comm_size (comm);
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
/* copy data to receivbuffer */ /* copy data to receivbuffer */
if (inplace) { if (inplace) {
ptrdiff_t lgap, lspan; ptrdiff_t lgap, lspan;
@ -73,12 +68,10 @@ int ompi_coll_libnbc_ialltoallw(const void* sendbuf, const int *sendcounts, cons
} }
if (OPAL_UNLIKELY(0 == span)) { if (OPAL_UNLIKELY(0 == span)) {
*request = &ompi_request_empty; *request = &ompi_request_empty;
NBC_Return_handle (handle);
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
handle->tmpbuf = malloc(span); tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
sendcounts = recvcounts; sendcounts = recvcounts;
@ -89,14 +82,13 @@ int ompi_coll_libnbc_ialltoallw(const void* sendbuf, const int *sendcounts, cons
sbuf = (char *) sendbuf + sdispls[rank]; sbuf = (char *) sendbuf + sdispls[rank];
res = NBC_Copy(sbuf, sendcounts[rank], sendtypes[rank], rbuf, recvcounts[rank], recvtypes[rank], comm); res = NBC_Copy(sbuf, sendcounts[rank], sendtypes[rank], rbuf, recvcounts[rank], recvtypes[rank], comm);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res; return res;
} }
} }
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -109,26 +101,25 @@ int ompi_coll_libnbc_ialltoallw(const void* sendbuf, const int *sendcounts, cons
recvbuf, recvcounts, rdispls, recvtypes); recvbuf, recvcounts, rdispls, recvtypes);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -141,7 +132,6 @@ int ompi_coll_libnbc_ialltoallw_inter (const void* sendbuf, const int *sendcount
int res, rsize; int res, rsize;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, *sbuf; char *rbuf, *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -178,20 +168,12 @@ int ompi_coll_libnbc_ialltoallw_inter (const void* sendbuf, const int *sendcount
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -7,7 +7,7 @@
* rights reserved. * rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2014 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Mellanox Technologies. All rights reserved. * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.

Просмотреть файл

@ -55,7 +55,6 @@ int ompi_coll_libnbc_ibcast(void *buffer, int count, MPI_Datatype datatype, int
NBC_Bcast_args *args, *found, search; NBC_Bcast_args *args, *found, search;
#endif #endif
enum { NBC_BCAST_LINEAR, NBC_BCAST_BINOMIAL, NBC_BCAST_CHAIN } alg; enum { NBC_BCAST_LINEAR, NBC_BCAST_BINOMIAL, NBC_BCAST_CHAIN } alg;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -163,20 +162,12 @@ int ompi_coll_libnbc_ibcast(void *buffer, int count, MPI_Datatype datatype, int
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -331,3 +322,55 @@ static inline int bcast_sched_chain(int rank, int p, int root, NBC_Schedule *sch
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
int ompi_coll_libnbc_ibcast_inter(void *buffer, int count, MPI_Datatype datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
struct mca_coll_base_module_2_2_0_t *module) {
int res;
NBC_Schedule *schedule;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
if (root != MPI_PROC_NULL) {
/* send to all others */
if (root == MPI_ROOT) {
int remsize;
remsize = ompi_comm_remote_size (comm);
for (int peer = 0 ; peer < remsize ; ++peer) {
/* send msg to peer */
res = NBC_Sched_send (buffer, false, count, datatype, peer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
}
} else {
/* recv msg from root */
res = NBC_Sched_recv (buffer, false, count, datatype, root, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
}
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
return OMPI_SUCCESS;
}

Просмотреть файл

@ -1,81 +0,0 @@
/* -*- Mode: C; c-basic-offset:2 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2006 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
*
*/
#include "nbc_internal.h"
int ompi_coll_libnbc_ibcast_inter(void *buffer, int count, MPI_Datatype datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
struct mca_coll_base_module_2_2_0_t *module) {
int res;
NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
if (root != MPI_PROC_NULL) {
/* send to all others */
if (root == MPI_ROOT) {
int remsize;
remsize = ompi_comm_remote_size (comm);
for (int peer = 0 ; peer < remsize ; ++peer) {
/* send msg to peer */
res = NBC_Sched_send (buffer, false, count, datatype, peer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
}
} else {
/* recv msg from root */
res = NBC_Sched_recv (buffer, false, count, datatype, root, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
}
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Init_handle (comm, &handle, libnbc_module);
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;
}

Просмотреть файл

@ -7,7 +7,7 @@
* rights reserved. * rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -55,7 +55,7 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
NBC_Scan_args *args, *found, search; NBC_Scan_args *args, *found, search;
#endif #endif
char inplace; char inplace;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -63,25 +63,19 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
p = ompi_comm_size (comm); p = ompi_comm_size (comm);
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
if (0 < rank) { if (0 < rank) {
handle->tmpbuf = malloc(span); tmpbuf = malloc(span);
if (handle->tmpbuf == NULL) { if (NULL == tmpbuf) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
if (inplace) { if (inplace) {
res = NBC_Copy(recvbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm); res = NBC_Copy(recvbuf, count, datatype, (char *)tmpbuf-gap, count, datatype, comm);
} else { } else {
res = NBC_Copy(sendbuf, count, datatype, (char *)handle->tmpbuf-gap, count, datatype, comm); res = NBC_Copy(sendbuf, count, datatype, (char *)tmpbuf-gap, count, datatype, comm);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); free(tmpbuf);
return res; return res;
} }
} }
@ -98,18 +92,16 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
#endif #endif
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
if (rank != 0) { if (rank != 0) {
res = NBC_Sched_recv (recvbuf, false, count, datatype, rank-1, schedule, false); res = NBC_Sched_recv (recvbuf, false, count, datatype, rank-1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -117,7 +109,8 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
/* we have to wait until we have the data */ /* we have to wait until we have the data */
res = NBC_Sched_barrier(schedule); res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -125,14 +118,16 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
datatype, op, schedule, true); datatype, op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
/* send reduced data onward */ /* send reduced data onward */
res = NBC_Sched_send ((void *)(-gap), true, count, datatype, rank + 1, schedule, false); res = NBC_Sched_send ((void *)(-gap), true, count, datatype, rank + 1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -143,14 +138,16 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
res = NBC_Sched_send (sendbuf, false, count, datatype, 1, schedule, false); res = NBC_Sched_send (sendbuf, false, count, datatype, 1, schedule, false);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -185,14 +182,12 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
} }
#endif #endif
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -8,7 +8,7 @@
* Copyright (c) 2013 The University of Tennessee and The University * Copyright (c) 2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -51,7 +51,6 @@ int ompi_coll_libnbc_igather(const void* sendbuf, int sendcount, MPI_Datatype se
MPI_Aint rcvext = 0; MPI_Aint rcvext = 0;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, inplace = 0; char *rbuf, inplace = 0;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -161,20 +160,12 @@ int ompi_coll_libnbc_igather(const void* sendbuf, int sendcount, MPI_Datatype se
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -186,7 +177,6 @@ int ompi_coll_libnbc_igather_inter (const void* sendbuf, int sendcount, MPI_Data
MPI_Aint rcvext = 0; MPI_Aint rcvext = 0;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf; char *rbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -230,19 +220,11 @@ int ompi_coll_libnbc_igather_inter (const void* sendbuf, int sendcount, MPI_Data
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -8,7 +8,7 @@
* Copyright (c) 2013 The University of Tennessee and The University * Copyright (c) 2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -36,7 +36,6 @@ int ompi_coll_libnbc_igatherv(const void* sendbuf, int sendcount, MPI_Datatype s
MPI_Aint rcvext = 0; MPI_Aint rcvext = 0;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf, inplace = 0; char *rbuf, inplace = 0;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -96,20 +95,12 @@ int ompi_coll_libnbc_igatherv(const void* sendbuf, int sendcount, MPI_Datatype s
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -121,7 +112,6 @@ int ompi_coll_libnbc_igatherv_inter (const void* sendbuf, int sendcount, MPI_Dat
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *rbuf; char *rbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -165,19 +155,11 @@ int ompi_coll_libnbc_igatherv_inter (const void* sendbuf, int sendcount, MPI_Dat
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -48,7 +48,6 @@ int ompi_coll_libnbc_ineighbor_allgather(const void *sbuf, int scount, MPI_Datat
ompi_request_t ** request, struct mca_coll_base_module_2_2_0_t *module) { ompi_request_t ** request, struct mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts; int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule; NBC_Schedule *schedule;
@ -153,20 +152,11 @@ int ompi_coll_libnbc_ineighbor_allgather(const void *sbuf, int scount, MPI_Datat
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; return res;
} }
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -49,7 +49,6 @@ int ompi_coll_libnbc_ineighbor_allgatherv(const void *sbuf, int scount, MPI_Data
struct mca_coll_base_module_2_2_0_t *module) { struct mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts; int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint rcvext; MPI_Aint rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule; NBC_Schedule *schedule;
@ -155,20 +154,11 @@ int ompi_coll_libnbc_ineighbor_allgatherv(const void *sbuf, int scount, MPI_Data
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; return res;
} }
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -45,7 +45,6 @@ int ompi_coll_libnbc_ineighbor_alltoall(const void *sbuf, int scount, MPI_Dataty
ompi_request_t ** request, struct mca_coll_base_module_2_2_0_t *module) { ompi_request_t ** request, struct mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts; int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint sndext, rcvext; MPI_Aint sndext, rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule; NBC_Schedule *schedule;
@ -157,19 +156,11 @@ int ompi_coll_libnbc_ineighbor_alltoall(const void *sbuf, int scount, MPI_Dataty
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; return res;
} }
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -49,7 +49,6 @@ int ompi_coll_libnbc_ineighbor_alltoallv(const void *sbuf, const int *scounts, c
struct mca_coll_base_module_2_2_0_t *module) { struct mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts; int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint sndext, rcvext; MPI_Aint sndext, rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule; NBC_Schedule *schedule;
@ -162,19 +161,11 @@ int ompi_coll_libnbc_ineighbor_alltoallv(const void *sbuf, const int *scounts, c
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -47,7 +47,6 @@ int ompi_coll_libnbc_ineighbor_alltoallw(const void *sbuf, const int *scounts, c
struct ompi_communicator_t *comm, ompi_request_t ** request, struct ompi_communicator_t *comm, ompi_request_t ** request,
struct mca_coll_base_module_2_2_0_t *module) { struct mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts; int res, indegree, outdegree, *srcs, *dsts;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule; NBC_Schedule *schedule;
@ -147,19 +146,11 @@ int ompi_coll_libnbc_ineighbor_alltoallw(const void *sbuf, const int *scounts, c
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -261,6 +261,7 @@ void NBC_SchedCache_args_delete_key_dummy(void *k);
int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule); int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule);
int NBC_Init_handle(struct ompi_communicator_t *comm, ompi_coll_libnbc_request_t **request, ompi_coll_libnbc_module_t *module); int NBC_Init_handle(struct ompi_communicator_t *comm, ompi_coll_libnbc_request_t **request, ompi_coll_libnbc_module_t *module);
int NBC_Schedule_request(NBC_Schedule *schedule, ompi_communicator_t *comm, ompi_coll_libnbc_module_t *module, ompi_request_t **request, void *tmpbuf);
void NBC_Return_handle(ompi_coll_libnbc_request_t *request); void NBC_Return_handle(ompi_coll_libnbc_request_t *request);
static inline int NBC_Type_intrinsic(MPI_Datatype type); static inline int NBC_Type_intrinsic(MPI_Datatype type);
int NBC_Create_fortran_handle(int *fhandle, NBC_Handle **handle); int NBC_Create_fortran_handle(int *fhandle, NBC_Handle **handle);

Просмотреть файл

@ -24,12 +24,12 @@
#include "nbc_internal.h" #include "nbc_internal.h"
static inline int red_sched_binomial (int rank, int p, int root, const void *sendbuf, void *redbuf, char tmpredbuf, int count, MPI_Datatype datatype, static inline int red_sched_binomial (int rank, int p, int root, const void *sendbuf, void *redbuf, char tmpredbuf, int count, MPI_Datatype datatype,
MPI_Op op, char inplace, NBC_Schedule *schedule, NBC_Handle *handle); MPI_Op op, char inplace, NBC_Schedule *schedule, void *tmpbuf);
static inline int red_sched_chain (int rank, int p, int root, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, static inline int red_sched_chain (int rank, int p, int root, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
MPI_Op op, int ext, size_t size, NBC_Schedule *schedule, NBC_Handle *handle, int fragsize); MPI_Op op, int ext, size_t size, NBC_Schedule *schedule, void *tmpbuf, int fragsize);
static inline int red_sched_linear (int rank, int rsize, int root, const void *sendbuf, void *recvbuf, void *tmpbuf, int count, MPI_Datatype datatype, static inline int red_sched_linear (int rank, int rsize, int root, const void *sendbuf, void *recvbuf, void *tmpbuf, int count, MPI_Datatype datatype,
MPI_Op op, NBC_Schedule *schedule, NBC_Handle *handle); MPI_Op op, NBC_Schedule *schedule);
#ifdef NBC_CACHE_SCHEDULE #ifdef NBC_CACHE_SCHEDULE
/* tree comparison function for schedule cache */ /* tree comparison function for schedule cache */
@ -60,9 +60,9 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
MPI_Aint ext; MPI_Aint ext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *redbuf=NULL, inplace; char *redbuf=NULL, inplace;
void *tmpbuf;
char tmpredbuf = 0; char tmpredbuf = 0;
enum { NBC_RED_BINOMIAL, NBC_RED_CHAIN } alg; enum { NBC_RED_BINOMIAL, NBC_RED_CHAIN } alg;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap; ptrdiff_t span, gap;
@ -95,11 +95,6 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
/* algorithm selection */ /* algorithm selection */
@ -107,23 +102,22 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
alg = NBC_RED_BINOMIAL; alg = NBC_RED_BINOMIAL;
if(rank == root) { if(rank == root) {
/* root reduces in receivebuffer */ /* root reduces in receivebuffer */
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
redbuf = recvbuf; redbuf = recvbuf;
} else { } else {
/* recvbuf may not be valid on non-root nodes */ /* recvbuf may not be valid on non-root nodes */
ptrdiff_t span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t); ptrdiff_t span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
handle->tmpbuf = malloc (span_align + span); tmpbuf = malloc (span_align + span);
redbuf = (char*)span_align - gap; redbuf = (char*)span_align - gap;
tmpredbuf = 1; tmpredbuf = 1;
} }
} else { } else {
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
alg = NBC_RED_CHAIN; alg = NBC_RED_CHAIN;
segsize = 16384/2; segsize = 16384/2;
} }
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -142,30 +136,29 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
#endif #endif
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) { switch(alg) {
case NBC_RED_BINOMIAL: case NBC_RED_BINOMIAL:
res = red_sched_binomial(rank, p, root, sendbuf, redbuf, tmpredbuf, count, datatype, op, inplace, schedule, handle); res = red_sched_binomial(rank, p, root, sendbuf, redbuf, tmpredbuf, count, datatype, op, inplace, schedule, tmpbuf);
break; break;
case NBC_RED_CHAIN: case NBC_RED_CHAIN:
res = red_sched_chain(rank, p, root, sendbuf, recvbuf, count, datatype, op, ext, size, schedule, handle, segsize); res = red_sched_chain(rank, p, root, sendbuf, recvbuf, count, datatype, op, ext, size, schedule, tmpbuf, segsize);
break; break;
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
#ifdef NBC_CACHE_SCHEDULE #ifdef NBC_CACHE_SCHEDULE
@ -200,15 +193,13 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
} }
#endif #endif
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -217,52 +208,46 @@ int ompi_coll_libnbc_ireduce_inter(const void* sendbuf, void* recvbuf, int count
struct mca_coll_base_module_2_2_0_t *module) { struct mca_coll_base_module_2_2_0_t *module) {
int rank, res, rsize; int rank, res, rsize;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap; ptrdiff_t span, gap;
void *tmpbuf;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
res = red_sched_linear (rank, rsize, root, sendbuf, recvbuf, (void *)(-gap), count, datatype, op, schedule, handle); res = red_sched_linear (rank, rsize, root, sendbuf, recvbuf, (void *)(-gap), count, datatype, op, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE; free(tmpbuf);
return res;
} }
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -299,9 +284,9 @@ int ompi_coll_libnbc_ireduce_inter(const void* sendbuf, void* recvbuf, int count
if (vrank == root) rank = 0; \ if (vrank == root) rank = 0; \
} }
static inline int red_sched_binomial (int rank, int p, int root, const void *sendbuf, void *redbuf, char tmpredbuf, int count, MPI_Datatype datatype, static inline int red_sched_binomial (int rank, int p, int root, const void *sendbuf, void *redbuf, char tmpredbuf, int count, MPI_Datatype datatype,
MPI_Op op, char inplace, NBC_Schedule *schedule, NBC_Handle *handle) { MPI_Op op, char inplace, NBC_Schedule *schedule, void *tmpbuf) {
int vroot, vrank, vpeer, peer, res, maxr; int vroot, vrank, vpeer, peer, res, maxr;
char *rbuf, *lbuf, *buf, tmpbuf; char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf; int tmprbuf, tmplbuf;
ptrdiff_t gap; ptrdiff_t gap;
(void)opal_datatype_span(&datatype->super, count, &gap); (void)opal_datatype_span(&datatype->super, count, &gap);
@ -330,7 +315,7 @@ static inline int red_sched_binomial (int rank, int p, int root, const void *sen
rbuf = redbuf; rbuf = redbuf;
tmprbuf = tmpredbuf; tmprbuf = tmpredbuf;
if (inplace) { if (inplace) {
res = NBC_Copy(rbuf, count, datatype, ((char *)handle->tmpbuf)-gap, count, datatype, MPI_COMM_SELF); res = NBC_Copy(rbuf, count, datatype, ((char *)tmpbuf)-gap, count, datatype, MPI_COMM_SELF);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res; return res;
} }
@ -343,6 +328,7 @@ static inline int red_sched_binomial (int rank, int p, int root, const void *sen
vpeer = vrank + (1 << (r - 1)); vpeer = vrank + (1 << (r - 1));
VRANK2RANK(peer, vpeer, vroot) VRANK2RANK(peer, vpeer, vroot)
if (peer < p) { if (peer < p) {
int tbuf;
/* we have to wait until we have the data */ /* we have to wait until we have the data */
res = NBC_Sched_recv (rbuf, tmprbuf, count, datatype, peer, schedule, true); res = NBC_Sched_recv (rbuf, tmprbuf, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
@ -350,7 +336,7 @@ static inline int red_sched_binomial (int rank, int p, int root, const void *sen
} }
/* perform the reduce in my local buffer */ /* perform the reduce in my local buffer */
/* this cannot be done until handle->tmpbuf is unused :-( so barrier after the op */ /* this cannot be done until tmpbuf is unused :-( so barrier after the op */
if (firstred && !inplace) { if (firstred && !inplace) {
/* perform the reduce with the senbuf */ /* perform the reduce with the senbuf */
res = NBC_Sched_op (sendbuf, false, rbuf, tmprbuf, count, datatype, op, schedule, true); res = NBC_Sched_op (sendbuf, false, rbuf, tmprbuf, count, datatype, op, schedule, true);
@ -365,7 +351,7 @@ static inline int red_sched_binomial (int rank, int p, int root, const void *sen
} }
/* swap left and right buffers */ /* swap left and right buffers */
buf = rbuf; rbuf = lbuf ; lbuf = buf; buf = rbuf; rbuf = lbuf ; lbuf = buf;
tmpbuf = tmprbuf; tmprbuf = tmplbuf; tmplbuf = tmpbuf; tbuf = tmprbuf; tmprbuf = tmplbuf; tmplbuf = tbuf;
} }
} else { } else {
/* we have to send this round */ /* we have to send this round */
@ -401,7 +387,7 @@ static inline int red_sched_binomial (int rank, int p, int root, const void *sen
/* chain send ... */ /* chain send ... */
static inline int red_sched_chain (int rank, int p, int root, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, static inline int red_sched_chain (int rank, int p, int root, const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype,
MPI_Op op, int ext, size_t size, NBC_Schedule *schedule, NBC_Handle *handle, int fragsize) { MPI_Op op, int ext, size_t size, NBC_Schedule *schedule, void *tmpbuf, int fragsize) {
int res, vrank, rpeer, speer, numfrag, fragcount, thiscount; int res, vrank, rpeer, speer, numfrag, fragcount, thiscount;
long offset; long offset;
@ -479,7 +465,7 @@ static inline int red_sched_chain (int rank, int p, int root, const void *sendbu
/* simple linear algorithm for intercommunicators */ /* simple linear algorithm for intercommunicators */
static inline int red_sched_linear (int rank, int rsize, int root, const void *sendbuf, void *recvbuf, void *tmpbuf, int count, MPI_Datatype datatype, static inline int red_sched_linear (int rank, int rsize, int root, const void *sendbuf, void *recvbuf, void *tmpbuf, int count, MPI_Datatype datatype,
MPI_Op op, NBC_Schedule *schedule, NBC_Handle *handle) { MPI_Op op, NBC_Schedule *schedule) {
int res; int res;
char *rbuf, *lbuf, *buf; char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf; int tmprbuf, tmplbuf;

Просмотреть файл

@ -7,7 +7,7 @@
* rights reserved. * rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 The University of Tennessee and The University * Copyright (c) 2015 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
@ -49,7 +49,7 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
ptrdiff_t gap, span, span_align; ptrdiff_t gap, span, span_align;
char *sbuf, inplace; char *sbuf, inplace;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle; void *tmpbuf;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
char *rbuf, *lbuf, *buf; char *rbuf, *lbuf, *buf;
@ -82,18 +82,12 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
maxr = (int) ceil ((log((double) p) / LOG2)); maxr = (int) ceil ((log((double) p) / LOG2));
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t); span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
handle->tmpbuf = malloc (span_align + span); tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
@ -102,13 +96,10 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
for (int r = 1, firstred = 1 ; r <= maxr ; ++r) { for (int r = 1, firstred = 1 ; r <= maxr ; ++r) {
if ((rank % (1 << r)) == 0) { if ((rank % (1 << r)) == 0) {
/* we have to receive this round */ /* we have to receive this round */
@ -117,11 +108,12 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
/* we have to wait until we have the data */ /* we have to wait until we have the data */
res = NBC_Sched_recv(rbuf, true, count, datatype, peer, schedule, true); res = NBC_Sched_recv(rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
/* this cannot be done until handle->tmpbuf is unused :-( so barrier after the op */ /* this cannot be done until tmpbuf is unused :-( so barrier after the op */
if (firstred) { if (firstred) {
/* take reduce data from the sendbuf in the first round -> save copy */ /* take reduce data from the sendbuf in the first round -> save copy */
res = NBC_Sched_op (sendbuf, false, rbuf, true, count, datatype, op, schedule, true); res = NBC_Sched_op (sendbuf, false, rbuf, true, count, datatype, op, schedule, true);
@ -132,7 +124,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
/* swap left and right buffers */ /* swap left and right buffers */
@ -149,7 +142,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
res = NBC_Sched_send (lbuf, true, count, datatype, peer, schedule, false); res = NBC_Sched_send (lbuf, true, count, datatype, peer, schedule, false);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -160,7 +154,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
res = NBC_Sched_barrier(schedule); res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -173,7 +168,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
res = NBC_Sched_send (sbuf, true, recvcounts[r], datatype, r, schedule, res = NBC_Sched_send (sbuf, true, recvcounts[r], datatype, r, schedule,
false); false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -185,25 +181,25 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -214,7 +210,7 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
MPI_Aint ext; MPI_Aint ext;
ptrdiff_t gap, span, span_align; ptrdiff_t gap, span, span_align;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -235,32 +231,24 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t); span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
if (count > 0) { if (count > 0) {
handle->tmpbuf = malloc (span_align + span); tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) { if (OPAL_UNLIKELY(NULL == tmpbuf)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
} }
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
/* send my data to the remote root */ /* send my data to the remote root */
res = NBC_Sched_send(sendbuf, false, count, datatype, 0, schedule, false); res = NBC_Sched_send(sendbuf, false, count, datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -270,7 +258,8 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
rbuf = (char *)(span_align-gap); rbuf = (char *)(span_align-gap);
res = NBC_Sched_recv (lbuf, true, count, datatype, 0, schedule, true); res = NBC_Sched_recv (lbuf, true, count, datatype, 0, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -278,14 +267,16 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
char *tbuf; char *tbuf;
res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true); res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_op (lbuf, true, rbuf, true, count, datatype, res = NBC_Sched_op (lbuf, true, rbuf, true, count, datatype,
op, schedule, true); op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
tbuf = lbuf; lbuf = rbuf; rbuf = tbuf; tbuf = lbuf; lbuf = rbuf; rbuf = tbuf;
@ -295,14 +286,16 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
res = NBC_Sched_copy (lbuf, true, recvcounts[0], datatype, recvbuf, false, res = NBC_Sched_copy (lbuf, true, recvcounts[0], datatype, recvbuf, false,
recvcounts[0], datatype, schedule, false); recvcounts[0], datatype, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
for (int peer = 1, offset = recvcounts[0] * ext; peer < lsize ; ++peer) { for (int peer = 1, offset = recvcounts[0] * ext; peer < lsize ; ++peer) {
res = NBC_Sched_local_send (lbuf + offset, true, recvcounts[peer], datatype, peer, schedule, res = NBC_Sched_local_send (lbuf + offset, true, recvcounts[peer], datatype, peer, schedule,
false); false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -312,25 +305,25 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
/* receive my block */ /* receive my block */
res = NBC_Sched_local_recv (recvbuf, false, recvcounts[rank], datatype, 0, schedule, false); res = NBC_Sched_local_recv (recvbuf, false, recvcounts[rank], datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -8,7 +8,7 @@
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved. * Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -47,7 +47,7 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
ptrdiff_t gap, span; ptrdiff_t gap, span;
char *redbuf, *sbuf, inplace; char *redbuf, *sbuf, inplace;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -61,20 +61,11 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
return (MPI_SUCCESS == res) ? MPI_ERR_SIZE : res; return (MPI_SUCCESS == res) ? MPI_ERR_SIZE : res;
} }
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OMPI_SUCCESS != res) {
return res;
}
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) { if (NULL == schedule) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
maxr = (int)ceil((log((double)p)/LOG2)); maxr = (int)ceil((log((double)p)/LOG2));
count = p * recvcount; count = p * recvcount;
@ -85,23 +76,22 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t); span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
handle->tmpbuf = malloc (span_align + span); tmpbuf = malloc (span_align + span);
if (NULL == handle->tmpbuf) { if (NULL == tmpbuf) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
rbuf = (void *)(-gap); rbuf = (void *)(-gap);
lbuf = (char *)(span_align - gap); lbuf = (char *)(span_align - gap);
redbuf = (char *) handle->tmpbuf + span_align - gap; redbuf = (char *) tmpbuf + span_align - gap;
/* copy data to redbuf if we only have a single node */ /* copy data to redbuf if we only have a single node */
if ((p == 1) && !inplace) { if ((p == 1) && !inplace) {
res = NBC_Copy (sendbuf, count, datatype, redbuf, count, datatype, comm); res = NBC_Copy (sendbuf, count, datatype, redbuf, count, datatype, comm);
if (OMPI_SUCCESS != res) { if (OMPI_SUCCESS != res) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -114,7 +104,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
/* we have to wait until we have the data */ /* we have to wait until we have the data */
res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true); res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -128,7 +119,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
/* swap left and right buffers */ /* swap left and right buffers */
@ -146,7 +138,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -157,7 +150,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
res = NBC_Sched_barrier(schedule); res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -165,7 +159,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
if (rank != 0) { if (rank != 0) {
res = NBC_Sched_recv (recvbuf, false, recvcount, datatype, 0, schedule, false); res = NBC_Sched_recv (recvbuf, false, recvcount, datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} else { } else {
@ -175,7 +170,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
/* root sends the right buffer to the right receiver */ /* root sends the right buffer to the right receiver */
res = NBC_Sched_send (sbuf, true, recvcount, datatype, r, schedule, false); res = NBC_Sched_send (sbuf, true, recvcount, datatype, r, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -185,7 +181,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
datatype, schedule, false); datatype, schedule, false);
} }
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -193,19 +190,18 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start (handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }
@ -216,7 +212,7 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
MPI_Aint ext; MPI_Aint ext;
ptrdiff_t gap, span, span_align; ptrdiff_t gap, span, span_align;
NBC_Schedule *schedule; NBC_Schedule *schedule;
NBC_Handle *handle; void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -229,37 +225,29 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
return res; return res;
} }
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
count = rcount * lsize; count = rcount * lsize;
span = opal_datatype_span(&dtype->super, count, &gap); span = opal_datatype_span(&dtype->super, count, &gap);
span_align = OPAL_ALIGN(span, dtype->super.align, ptrdiff_t); span_align = OPAL_ALIGN(span, dtype->super.align, ptrdiff_t);
if (count > 0) { if (count > 0) {
handle->tmpbuf = malloc (span_align + span); tmpbuf = malloc (span_align + span);
if (NULL == handle->tmpbuf) { if (NULL == tmpbuf) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
} }
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) { if (NULL == schedule) {
NBC_Return_handle (handle); free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
/* send my data to the remote root */ /* send my data to the remote root */
res = NBC_Sched_send (sendbuf, false, count, dtype, 0, schedule, false); res = NBC_Sched_send (sendbuf, false, count, dtype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -269,7 +257,8 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
rbuf = (char *)(span_align-gap); rbuf = (char *)(span_align-gap);
res = NBC_Sched_recv (lbuf, true, count, dtype, 0, schedule, true); res = NBC_Sched_recv (lbuf, true, count, dtype, 0, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -277,14 +266,16 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
char *tbuf; char *tbuf;
res = NBC_Sched_recv (rbuf, true, count, dtype, peer, schedule, true); res = NBC_Sched_recv (rbuf, true, count, dtype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Sched_op (lbuf, true, rbuf, true, count, dtype, res = NBC_Sched_op (lbuf, true, rbuf, true, count, dtype,
op, schedule, true); op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
tbuf = lbuf; lbuf = rbuf; rbuf = tbuf; tbuf = lbuf; lbuf = rbuf; rbuf = tbuf;
@ -294,13 +285,15 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
res = NBC_Sched_copy (lbuf, true, rcount, dtype, recvbuf, false, rcount, res = NBC_Sched_copy (lbuf, true, rcount, dtype, recvbuf, false, rcount,
dtype, schedule, false); dtype, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
for (int peer = 1 ; peer < lsize ; ++peer) { for (int peer = 1 ; peer < lsize ; ++peer) {
res = NBC_Sched_local_send (lbuf + ext * rcount * peer, true, rcount, dtype, peer, schedule, false); res = NBC_Sched_local_send (lbuf + ext * rcount * peer, true, rcount, dtype, peer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -308,7 +301,8 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
/* receive my block */ /* receive my block */
res = NBC_Sched_local_recv(recvbuf, false, rcount, dtype, 0, schedule, false); res = NBC_Sched_local_recv(recvbuf, false, rcount, dtype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -317,18 +311,17 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
res = NBC_Sched_commit(schedule); res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -5,7 +5,7 @@
* Corporation. All rights reserved. * Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All * Copyright (c) 2006 The Technical University of Chemnitz. All
* rights reserved. * rights reserved.
* Copyright (c) 2014-2015 Research Organization for Information Science * Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights * Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved. * reserved.
@ -51,8 +51,8 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
int rank, p, res; int rank, p, res;
ptrdiff_t gap, span; ptrdiff_t gap, span;
NBC_Schedule *schedule; NBC_Schedule *schedule;
void *tmpbuf = NULL;
char inplace; char inplace;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace); NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -68,11 +68,6 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
} }
} }
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
#ifdef NBC_CACHE_SCHEDULE #ifdef NBC_CACHE_SCHEDULE
NBC_Scan_args *args, *found, search; NBC_Scan_args *args, *found, search;
@ -87,34 +82,32 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
#endif #endif
schedule = OBJ_NEW(NBC_Schedule); schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) { if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* ensure the schedule is released with the handle */
handle->schedule = schedule;
if(rank != 0) { if(rank != 0) {
span = opal_datatype_span(&datatype->super, count, &gap); span = opal_datatype_span(&datatype->super, count, &gap);
handle->tmpbuf = malloc (span); tmpbuf = malloc (span);
if (NULL == handle->tmpbuf) { if (NULL == tmpbuf) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE; return OMPI_ERR_OUT_OF_RESOURCE;
} }
/* we have to wait until we have the data */ /* we have to wait until we have the data */
res = NBC_Sched_recv ((void *)(-gap), true, count, datatype, rank-1, schedule, true); res = NBC_Sched_recv ((void *)(-gap), true, count, datatype, rank-1, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
/* perform the reduce in my local buffer */ /* perform the reduce in my local buffer */
/* this cannot be done until handle->tmpbuf is unused :-( so barrier after the op */ /* this cannot be done until tmpbuf is unused :-( so barrier after the op */
res = NBC_Sched_op ((void *)(-gap), true, recvbuf, false, count, datatype, op, schedule, res = NBC_Sched_op ((void *)(-gap), true, recvbuf, false, count, datatype, op, schedule,
true); true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
@ -122,14 +115,16 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
if (rank != p-1) { if (rank != p-1) {
res = NBC_Sched_send (recvbuf, false, count, datatype, rank+1, schedule, false); res = NBC_Sched_send (recvbuf, false, count, datatype, rank+1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
} }
res = NBC_Sched_commit (schedule); res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
@ -164,14 +159,12 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
} }
#endif #endif
res = NBC_Start(handle, schedule); res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle); OBJ_RELEASE(schedule);
free(tmpbuf);
return res; return res;
} }
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2013 The University of Tennessee and The University * Copyright (c) 2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -52,7 +52,6 @@ int ompi_coll_libnbc_iscatter (const void* sendbuf, int sendcount, MPI_Datatype
MPI_Aint sndext = 0; MPI_Aint sndext = 0;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *sbuf, inplace = 0; char *sbuf, inplace = 0;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
@ -158,20 +157,12 @@ int ompi_coll_libnbc_iscatter (const void* sendbuf, int sendcount, MPI_Datatype
} }
#endif #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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -183,7 +174,6 @@ int ompi_coll_libnbc_iscatter_inter (const void* sendbuf, int sendcount, MPI_Dat
MPI_Aint sndext; MPI_Aint sndext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *sbuf; char *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -227,19 +217,11 @@ int ompi_coll_libnbc_iscatter_inter (const void* sendbuf, int sendcount, MPI_Dat
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2013 The University of Tennessee and The University * Copyright (c) 2013 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights * of Tennessee Research Foundation. All rights
* reserved. * 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. * and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved. * Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -35,7 +35,6 @@ int ompi_coll_libnbc_iscatterv(const void* sendbuf, const int *sendcounts, const
MPI_Aint sndext; MPI_Aint sndext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *sbuf, inplace = 0; char *sbuf, inplace = 0;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm); rank = ompi_comm_rank (comm);
@ -93,20 +92,12 @@ int ompi_coll_libnbc_iscatterv(const void* sendbuf, const int *sendcounts, const
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }
@ -118,7 +109,6 @@ int ompi_coll_libnbc_iscatterv_inter (const void* sendbuf, const int *sendcounts
MPI_Aint sndext; MPI_Aint sndext;
NBC_Schedule *schedule; NBC_Schedule *schedule;
char *sbuf; char *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module; ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rsize = ompi_comm_remote_size (comm); rsize = ompi_comm_remote_size (comm);
@ -161,19 +151,11 @@ int ompi_coll_libnbc_iscatterv_inter (const void* sendbuf, const int *sendcounts
return res; 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)) { if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule); OBJ_RELEASE(schedule);
return res; 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; return OMPI_SUCCESS;
} }