1
1

coll/libnbc: revisit NBC_Handle usage

make NBC_Handle (almost) an internal structure created
by NBC_Schedule_request()
use a local variable instead of what was previously handle->tmpbuf

Refs open-mpi/ompi#3487

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
Gilles Gouaillardet 2017-06-20 17:24:16 +09:00
родитель 68ac95003f
Коммит 9ba85b85e1
26 изменённых файлов: 363 добавлений и 652 удалений

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

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

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

@ -10,7 +10,7 @@
* rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015-2016 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
*
* Author(s): Torsten Hoefler <htor@cs.indiana.edu>
@ -709,6 +709,25 @@ int NBC_Start(NBC_Handle *handle, NBC_Schedule *schedule) {
return OMPI_SUCCESS;
}
int NBC_Schedule_request(NBC_Schedule *schedule, ompi_communicator_t *comm, ompi_coll_libnbc_module_t *module, ompi_request_t **request, void *tmpbuf) {
int res;
NBC_Handle *handle;
res = NBC_Init_handle (comm, &handle, module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
handle->tmpbuf = tmpbuf;
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}
#ifdef NBC_CACHE_SCHEDULE
void NBC_SchedCache_args_delete_key_dummy(void *k) {
/* do nothing because the key and the data element are identical :-)

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

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

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

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

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

@ -25,13 +25,13 @@
#include <assert.h>
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,
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,
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
/* tree comparison function for schedule cache */
@ -65,7 +65,7 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
#endif
enum { NBC_ARED_BINOMIAL, NBC_ARED_RING } alg;
char inplace;
NBC_Handle *handle = NULL;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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 */
res = NBC_Copy(sendbuf, count, datatype, recvbuf, count, datatype, comm);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
}
@ -99,15 +98,9 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
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);
handle->tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
@ -130,30 +123,29 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
#endif
schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) {
NBC_Return_handle (handle);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* ensure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) {
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;
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;
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -188,15 +180,13 @@ int ompi_coll_libnbc_iallreduce(const void* sendbuf, void* recvbuf, int count, M
}
#endif
res = NBC_Start (handle, schedule);
res = NBC_Schedule_request (schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}
@ -208,7 +198,7 @@ int ompi_coll_libnbc_iallreduce_inter(const void* sendbuf, void* recvbuf, int co
size_t size;
MPI_Aint ext;
NBC_Schedule *schedule;
NBC_Handle *handle;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap;
@ -227,49 +217,40 @@ int ompi_coll_libnbc_iallreduce_inter(const void* sendbuf, void* recvbuf, int co
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);
handle->tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
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,
ext, size, schedule, handle);
ext, size, schedule, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
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; \
}
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;
char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf;
@ -330,7 +311,7 @@ static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype dat
rbuf = recvbuf;
tmprbuf = false;
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)) {
return res;
}
@ -349,7 +330,7 @@ static inline int allred_sched_diss(int rank, int p, int count, MPI_Datatype dat
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) {
/* perform the reduce with the senbuf */
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,
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 speer, rpeer; /* send and recvpeer */
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,
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;
if (0 == count) {

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

@ -8,7 +8,7 @@
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. 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.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $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);
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, 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,
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
char *rbuf, *sbuf, inplace;
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;
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 */
if (alg == NBC_A2A_INPLACE) {
span = opal_datatype_span(&recvtype->super, recvcount, &gap);
handle->tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
} 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);
if (MPI_SUCCESS != res) {
NBC_Error("MPI Error in PMPI_Pack_size() (%i)", res);
NBC_Return_handle (handle);
return res;
}
}
/* allocate temporary buffers */
if ((p & 1) == 0) {
handle->tmpbuf = malloc (datasize * p * 2);
tmpbuf = malloc (datasize * p * 2);
} else {
/* 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)) {
NBC_Return_handle (handle);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
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)) {
#endif /* OPAL_CUDA_SUPPORT */
/* 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) {
memcpy ((char *) handle->tmpbuf + datasize * (p - rank), sendbuf, datasize * rank);
memcpy ((char *) tmpbuf + datasize * (p - rank), sendbuf, datasize * rank);
}
} else {
int pos=0;
/* 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);
if (OPAL_UNLIKELY(MPI_SUCCESS != res)) {
NBC_Error("MPI Error in PMPI_Pack() (%i)", res);
NBC_Return_handle (handle);
free(tmpbuf);
return res;
}
if (rank != 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);
if (OPAL_UNLIKELY(MPI_SUCCESS != res)) {
NBC_Error("MPI Error in PMPI_Pack() (%i)", res);
NBC_Return_handle (handle);
free(tmpbuf);
return res;
}
}
@ -208,13 +200,10 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
/* not found - generate new schedule */
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* ensure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) {
case NBC_A2A_INPLACE:
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);
break;
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;
case NBC_A2A_PAIRWISE:
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -273,14 +264,13 @@ int ompi_coll_libnbc_ialltoall(const void* sendbuf, int sendcount, MPI_Datatype
}
#endif
res = NBC_Start (handle, schedule);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}
@ -292,7 +282,6 @@ int ompi_coll_libnbc_ialltoall_inter (const void* sendbuf, int sendcount, MPI_Da
MPI_Aint sndext, rcvext;
NBC_Schedule *schedule;
char *rbuf, *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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;
}
res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}
@ -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,
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;
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 */
if ((p & 1) == 0) {
rtmpbuf = (char *) handle->tmpbuf + datasize * p;
stmpbuf = (char *) handle->tmpbuf + datasize * (p + p / 2);
rtmpbuf = (char *)tmpbuf + datasize * p;
stmpbuf = (char *)tmpbuf + datasize * (p + p / 2);
} else {
/* we cannot divide p by two, so alloc more to be safe ... */
virtp = (p / 2 + 1) * 2;
rtmpbuf = (char *) handle->tmpbuf + datasize * p;
stmpbuf = (char *) handle->tmpbuf + datasize * (p + virtp / 2);
rtmpbuf = (char *)tmpbuf + datasize * p;
stmpbuf = (char *)tmpbuf + datasize * (p + virtp / 2);
}
/* 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 */
/*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 -
(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)) {
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 */
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)) {
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)) {
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 */
if (i & r) {
/* 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,
false);
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 -
* reorder it into recvbuf */
/* phase 3 - reorder - data is now in wrong order in tmpbuf - reorder it into recvbuf */
for (int i = 0 ; i < p; ++i) {
rbuf = (char *) recvbuf + ((rank - i + p) % p) * recvcount * rcvext;
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;
char *rbuf, *sbuf, inplace;
ptrdiff_t gap, span;
NBC_Handle *handle;
void * tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_IN_PLACE(sendbuf, recvbuf, inplace);
@ -64,11 +64,6 @@ int ompi_coll_libnbc_ialltoallv(const void* sendbuf, const int *sendcounts, cons
return res;
}
res = NBC_Init_handle (comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
/* copy data to receivbuffer */
if (inplace) {
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);
if (OPAL_UNLIKELY(0 == span)) {
*request = &ompi_request_empty;
NBC_Return_handle (handle);
return MPI_SUCCESS;
}
handle->tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc(span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
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);
if (MPI_SUCCESS != res) {
NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
NBC_Return_handle (handle);
return res;
}
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);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
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);
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}
@ -156,7 +146,6 @@ int ompi_coll_libnbc_ialltoallv_inter (const void* sendbuf, const int *sendcount
int res, rsize;
MPI_Aint sndext, rcvext;
NBC_Schedule *schedule;
NBC_Handle *handle;
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;
}
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}

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

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

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

@ -7,7 +7,7 @@
* rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014 Research Organization for Information Science
* Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Mellanox Technologies. 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;
#endif
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;
rank = ompi_comm_rank (comm);
@ -163,20 +162,12 @@ int ompi_coll_libnbc_ibcast(void *buffer, int count, MPI_Datatype datatype, int
}
#endif
res = NBC_Init_handle (comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
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;
}
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.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All 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.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
@ -55,7 +55,7 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
NBC_Scan_args *args, *found, search;
#endif
char inplace;
NBC_Handle *handle;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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);
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);
if (0 < rank) {
handle->tmpbuf = malloc(span);
if (handle->tmpbuf == NULL) {
NBC_Return_handle (handle);
tmpbuf = malloc(span);
if (NULL == tmpbuf) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
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 {
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)) {
NBC_Return_handle (handle);
free(tmpbuf);
return res;
}
}
@ -98,18 +92,16 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
#endif
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
if (rank != 0) {
res = NBC_Sched_recv (recvbuf, false, count, datatype, rank-1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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 */
res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -125,14 +118,16 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
datatype, op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
/* send reduced data onward */
res = NBC_Sched_send ((void *)(-gap), true, count, datatype, rank + 1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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);
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -185,14 +182,12 @@ int ompi_coll_libnbc_iexscan(const void* sendbuf, void* recvbuf, int count, MPI_
}
#endif
res = NBC_Start (handle, schedule);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}

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

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

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

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

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

@ -5,7 +5,7 @@
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* 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.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* 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) {
int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule;
@ -153,20 +152,11 @@ int ompi_coll_libnbc_ineighbor_allgather(const void *sbuf, int scount, MPI_Datat
}
#endif
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}

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

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

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

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

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

@ -5,7 +5,7 @@
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* 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.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* 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) {
int res, indegree, outdegree, *srcs, *dsts;
MPI_Aint sndext, rcvext;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule;
@ -162,19 +161,11 @@ int ompi_coll_libnbc_ineighbor_alltoallv(const void *sbuf, const int *scounts, c
}
#endif
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start (handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}

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

@ -5,7 +5,7 @@
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* 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.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* 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 mca_coll_base_module_2_2_0_t *module) {
int res, indegree, outdegree, *srcs, *dsts;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
NBC_Schedule *schedule;
@ -147,19 +146,11 @@ int ompi_coll_libnbc_ineighbor_alltoallw(const void *sbuf, const int *scounts, c
}
#endif
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
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_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);
static inline int NBC_Type_intrinsic(MPI_Datatype type);
int NBC_Create_fortran_handle(int *fhandle, NBC_Handle **handle);

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

@ -24,12 +24,12 @@
#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,
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,
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,
MPI_Op op, NBC_Schedule *schedule, NBC_Handle *handle);
MPI_Op op, NBC_Schedule *schedule);
#ifdef NBC_CACHE_SCHEDULE
/* 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;
NBC_Schedule *schedule;
char *redbuf=NULL, inplace;
void *tmpbuf;
char tmpredbuf = 0;
enum { NBC_RED_BINOMIAL, NBC_RED_CHAIN } alg;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap;
@ -95,11 +95,6 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
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);
/* algorithm selection */
@ -107,23 +102,22 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
alg = NBC_RED_BINOMIAL;
if(rank == root) {
/* root reduces in receivebuffer */
handle->tmpbuf = malloc (span);
tmpbuf = malloc (span);
redbuf = recvbuf;
} else {
/* recvbuf may not be valid on non-root nodes */
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;
tmpredbuf = 1;
}
} else {
handle->tmpbuf = malloc (span);
tmpbuf = malloc (span);
alg = NBC_RED_CHAIN;
segsize = 16384/2;
}
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
@ -142,30 +136,29 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
#endif
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* make sure the schedule is released with the handle on error */
handle->schedule = schedule;
switch(alg) {
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;
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;
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
#ifdef NBC_CACHE_SCHEDULE
@ -200,15 +193,13 @@ int ompi_coll_libnbc_ireduce(const void* sendbuf, void* recvbuf, int count, MPI_
}
#endif
res = NBC_Start(handle, schedule);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
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) {
int rank, res, rsize;
NBC_Schedule *schedule;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
ptrdiff_t span, gap;
void *tmpbuf;
rank = ompi_comm_rank (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);
handle->tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc (span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE;
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return OMPI_ERR_OUT_OF_RESOURCE;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
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; \
}
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;
char *rbuf, *lbuf, *buf, tmpbuf;
char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf;
ptrdiff_t 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;
tmprbuf = tmpredbuf;
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)) {
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));
VRANK2RANK(peer, vpeer, vroot)
if (peer < p) {
int tbuf;
/* we have to wait until we have the data */
res = NBC_Sched_recv (rbuf, tmprbuf, count, datatype, peer, schedule, true);
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 */
/* 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) {
/* perform the reduce with the senbuf */
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 */
buf = rbuf; rbuf = lbuf ; lbuf = buf;
tmpbuf = tmprbuf; tmprbuf = tmplbuf; tmplbuf = tmpbuf;
tbuf = tmprbuf; tmprbuf = tmplbuf; tmplbuf = tbuf;
}
} else {
/* 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 ... */
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;
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 */
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;
char *rbuf, *lbuf, *buf;
int tmprbuf, tmplbuf;

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

@ -7,7 +7,7 @@
* rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2015 The University of Tennessee and The University
* 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;
char *sbuf, inplace;
NBC_Schedule *schedule;
NBC_Handle *handle;
void *tmpbuf;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
char *rbuf, *lbuf, *buf;
@ -82,18 +82,12 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
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));
span = opal_datatype_span(&datatype->super, count, &gap);
span_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
handle->tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
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);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
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) {
if ((rank % (1 << r)) == 0) {
/* 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 */
res = NBC_Sched_recv(rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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) {
/* 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);
@ -132,7 +124,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
/* 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);
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -160,7 +154,8 @@ int ompi_coll_libnbc_ireduce_scatter(const void* sendbuf, void* recvbuf, const i
res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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,
false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}
@ -214,7 +210,7 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
MPI_Aint ext;
ptrdiff_t gap, span, span_align;
NBC_Schedule *schedule;
NBC_Handle *handle;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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_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) {
handle->tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == handle->tmpbuf)) {
NBC_Return_handle (handle);
tmpbuf = malloc (span_align + span);
if (OPAL_UNLIKELY(NULL == tmpbuf)) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
}
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
free(tmpbuf);
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 */
res = NBC_Sched_send(sendbuf, false, count, datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -270,7 +258,8 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
rbuf = (char *)(span_align-gap);
res = NBC_Sched_recv (lbuf, true, count, datatype, 0, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -278,14 +267,16 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
char *tbuf;
res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_op (lbuf, true, rbuf, true, count, datatype,
op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
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,
recvcounts[0], datatype, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
for (int peer = 1, offset = recvcounts[0] * ext; peer < lsize ; ++peer) {
res = NBC_Sched_local_send (lbuf + offset, true, recvcounts[peer], datatype, peer, schedule,
false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -312,25 +305,25 @@ int ompi_coll_libnbc_ireduce_scatter_inter (const void* sendbuf, void* recvbuf,
/* receive my block */
res = NBC_Sched_local_recv (recvbuf, false, recvcounts[rank], datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}

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

@ -8,7 +8,7 @@
* Copyright (c) 2012 Sandia National Laboratories. All rights reserved.
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science
* Copyright (c) 2014-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
@ -47,7 +47,7 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
ptrdiff_t gap, span;
char *redbuf, *sbuf, inplace;
NBC_Schedule *schedule;
NBC_Handle *handle;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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;
}
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OMPI_SUCCESS != res) {
return res;
}
schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
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));
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_align = OPAL_ALIGN(span, datatype->super.align, ptrdiff_t);
handle->tmpbuf = malloc (span_align + span);
if (NULL == handle->tmpbuf) {
OMPI_COLL_LIBNBC_REQUEST_RETURN(handle);
tmpbuf = malloc (span_align + span);
if (NULL == tmpbuf) {
OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE;
}
rbuf = (void *)(-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 */
if ((p == 1) && !inplace) {
res = NBC_Copy (sendbuf, count, datatype, redbuf, count, datatype, comm);
if (OMPI_SUCCESS != res) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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 */
res = NBC_Sched_recv (rbuf, true, count, datatype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
/* 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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -157,7 +150,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
res = NBC_Sched_barrier(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -165,7 +159,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
if (rank != 0) {
res = NBC_Sched_recv (recvbuf, false, recvcount, datatype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
} 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 */
res = NBC_Sched_send (sbuf, true, recvcount, datatype, r, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
@ -185,7 +181,8 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
datatype, schedule, false);
}
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
@ -193,19 +190,18 @@ int ompi_coll_libnbc_ireduce_scatter_block(const void* sendbuf, void* recvbuf, i
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}
@ -216,7 +212,7 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
MPI_Aint ext;
ptrdiff_t gap, span, span_align;
NBC_Schedule *schedule;
NBC_Handle *handle;
void *tmpbuf = NULL;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
rank = ompi_comm_rank (comm);
@ -229,37 +225,29 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
return res;
}
res = NBC_Init_handle(comm, &handle, libnbc_module);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
return res;
}
count = rcount * lsize;
span = opal_datatype_span(&dtype->super, count, &gap);
span_align = OPAL_ALIGN(span, dtype->super.align, ptrdiff_t);
if (count > 0) {
handle->tmpbuf = malloc (span_align + span);
if (NULL == handle->tmpbuf) {
NBC_Return_handle (handle);
tmpbuf = malloc (span_align + span);
if (NULL == tmpbuf) {
return OMPI_ERR_OUT_OF_RESOURCE;
}
}
schedule = OBJ_NEW(NBC_Schedule);
if (NULL == schedule) {
NBC_Return_handle (handle);
free(tmpbuf);
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 */
res = NBC_Sched_send (sendbuf, false, count, dtype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -269,7 +257,8 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
rbuf = (char *)(span_align-gap);
res = NBC_Sched_recv (lbuf, true, count, dtype, 0, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -277,14 +266,16 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
char *tbuf;
res = NBC_Sched_recv (rbuf, true, count, dtype, peer, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
res = NBC_Sched_op (lbuf, true, rbuf, true, count, dtype,
op, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
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,
dtype, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
for (int peer = 1 ; peer < lsize ; ++peer) {
res = NBC_Sched_local_send (lbuf + ext * rcount * peer, true, rcount, dtype, peer, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
@ -308,7 +301,8 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
/* receive my block */
res = NBC_Sched_local_recv(recvbuf, false, rcount, dtype, 0, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
@ -317,18 +311,17 @@ int ompi_coll_libnbc_ireduce_scatter_block_inter(const void *sendbuf, void *recv
res = NBC_Sched_commit(schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
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)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}

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

@ -5,7 +5,7 @@
* Corporation. All rights reserved.
* Copyright (c) 2006 The Technical University of Chemnitz. All
* 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.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
@ -51,8 +51,8 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
int rank, p, res;
ptrdiff_t gap, span;
NBC_Schedule *schedule;
void *tmpbuf = NULL;
char inplace;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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
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
schedule = OBJ_NEW(NBC_Schedule);
if (OPAL_UNLIKELY(NULL == schedule)) {
NBC_Return_handle (handle);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* ensure the schedule is released with the handle */
handle->schedule = schedule;
if(rank != 0) {
span = opal_datatype_span(&datatype->super, count, &gap);
handle->tmpbuf = malloc (span);
if (NULL == handle->tmpbuf) {
NBC_Return_handle (handle);
tmpbuf = malloc (span);
if (NULL == tmpbuf) {
OBJ_RELEASE(schedule);
return OMPI_ERR_OUT_OF_RESOURCE;
}
/* we have to wait until we have the data */
res = NBC_Sched_recv ((void *)(-gap), true, count, datatype, rank-1, schedule, true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
/* 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,
true);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
@ -122,14 +115,16 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
if (rank != p-1) {
res = NBC_Sched_send (recvbuf, false, count, datatype, rank+1, schedule, false);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
}
res = NBC_Sched_commit (schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
@ -164,14 +159,12 @@ int ompi_coll_libnbc_iscan(const void* sendbuf, void* recvbuf, int count, MPI_Da
}
#endif
res = NBC_Start(handle, schedule);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, tmpbuf);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
OBJ_RELEASE(schedule);
free(tmpbuf);
return res;
}
*request = (ompi_request_t *) handle;
/* tmpbuf is freed with the handle */
return OMPI_SUCCESS;
}

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

@ -10,7 +10,7 @@
* Copyright (c) 2013 The University of Tennessee and The University
* of Tennessee Research Foundation. 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.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
@ -52,7 +52,6 @@ int ompi_coll_libnbc_iscatter (const void* sendbuf, int sendcount, MPI_Datatype
MPI_Aint sndext = 0;
NBC_Schedule *schedule;
char *sbuf, inplace = 0;
NBC_Handle *handle;
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
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}
@ -183,7 +174,6 @@ int ompi_coll_libnbc_iscatter_inter (const void* sendbuf, int sendcount, MPI_Dat
MPI_Aint sndext;
NBC_Schedule *schedule;
char *sbuf;
NBC_Handle *handle;
ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
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;
}
res = NBC_Init_handle(comm, &handle, libnbc_module);
res = NBC_Schedule_request(schedule, comm, libnbc_module, request, NULL);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
OBJ_RELEASE(schedule);
return res;
}
res = NBC_Start(handle, schedule);
if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
NBC_Return_handle (handle);
return res;
}
*request = (ompi_request_t *) handle;
return OMPI_SUCCESS;
}

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

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