diff --git a/src/mca/coll/base/coll_base_comm_select.c b/src/mca/coll/base/coll_base_comm_select.c index 849e09e329..06ba91f4ca 100644 --- a/src/mca/coll/base/coll_base_comm_select.c +++ b/src/mca/coll/base/coll_base_comm_select.c @@ -31,8 +31,8 @@ static mca_coll_1_0_0_t null_actions = { /* Collective function pointers */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, - false, NULL, NULL, NULL, NULL, - false, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; @@ -74,7 +74,7 @@ static int module_init(const mca_coll_1_0_0_t *module, ompi_communicator_t *comm); static int query_basic(ompi_communicator_t *comm); -static void replace_null_with_basic(ompi_communicator_t *comm); +static int replace_null_with_basic(ompi_communicator_t *comm); /* @@ -295,11 +295,11 @@ static ompi_list_t *check_components(ompi_list_t *components, { int i, priority; const mca_base_module_t *component; - ompi_list_item_t *item, *next; + ompi_list_item_t *item, *next, *item2; const mca_coll_1_0_0_t *actions; bool want_to_check; ompi_list_t *selectable; - avail_coll_t *avail; + avail_coll_t *avail, *avail2; /* Make a list of the components that query successfully */ @@ -342,18 +342,33 @@ static ompi_list_t *check_components(ompi_list_t *components, avail = OBJ_NEW(avail_coll_t); avail->ac_priority = 0; avail->ac_component = (mca_coll_base_module_1_0_0_t *) component; - ompi_list_append(selectable, item); - } else { - ompi_list_remove_item(components, item); + + /* Put this item on the list in priority order (highest + priority first). Should it go first? */ + + item2 = ompi_list_get_first(selectable); + avail2 = (avail_coll_t *) item2; + if (avail->ac_priority > avail2->ac_priority) { + ompi_list_prepend(selectable, item); + } else { + for (i = 1; item2 != ompi_list_get_end(selectable); + item2 = ompi_list_get_next(selectable), ++i) { + avail2 = (avail_coll_t *) item2; + if (avail->ac_priority > avail2->ac_priority) { + ompi_list_insert(selectable, item, i); + break; + } + } + + /* If we didn't find a place to put it in the list, then + append it (because it has the lowest priority found so + far) */ + if (ompi_list_get_end(selectable) == item2) { + ompi_list_append(selectable, item); + } + } } } - - /* If we didn't want to check, then eliminate this entry from the - list */ - - else { - ompi_list_remove_item(components, item); - } } /* If we didn't find any available components, return an error */ @@ -531,11 +546,15 @@ static int query_basic(ompi_communicator_t *comm) /* * Replace the NULL pointers by corresponsing ompi_basic pointers */ -static void replace_null_with_basic(ompi_communicator_t *comm) +static int replace_null_with_basic(ompi_communicator_t *comm) { + int err; + #define CHECK(name) \ if (NULL == comm->c_coll.coll_##name) { \ - query_basic(comm); \ + if (OMPI_SUCCESS != (err = query_basic(comm))) { \ + return err; \ + } \ comm->c_coll.coll_##name = comm->c_coll_basic_module->coll_##name; \ } @@ -555,4 +574,8 @@ static void replace_null_with_basic(ompi_communicator_t *comm) CHECK(scan); CHECK(scatter); CHECK(scatterv); + + /* Happiness; all done */ + + return OMPI_SUCCESS; } diff --git a/src/mca/coll/basic/src/coll_basic.c b/src/mca/coll/basic/src/coll_basic.c index 034ada7295..86d6f683a2 100644 --- a/src/mca/coll/basic/src/coll_basic.c +++ b/src/mca/coll/basic/src/coll_basic.c @@ -40,12 +40,10 @@ static const mca_coll_1_0_0_t intra_linear = { mca_coll_basic_alltoallv_intra, mca_coll_basic_alltoallw_intra, mca_coll_basic_barrier_intra_lin, - true, mca_coll_basic_bcast_lin_intra, mca_coll_basic_exscan_intra, mca_coll_basic_gather_intra, mca_coll_basic_gatherv_intra, - true, mca_coll_basic_reduce_lin_intra, mca_coll_basic_reduce_scatter_intra, mca_coll_basic_scan_intra, @@ -82,12 +80,10 @@ static const mca_coll_1_0_0_t intra_log = { mca_coll_basic_alltoallv_intra, mca_coll_basic_alltoallw_intra, mca_coll_basic_barrier_intra_log, - true, mca_coll_basic_bcast_log_intra, mca_coll_basic_exscan_intra, mca_coll_basic_gather_intra, mca_coll_basic_gatherv_intra, - true, mca_coll_basic_reduce_log_intra, mca_coll_basic_reduce_scatter_intra, mca_coll_basic_scan_intra, @@ -122,12 +118,10 @@ static const mca_coll_1_0_0_t inter_linear = { mca_coll_basic_alltoallv_inter, mca_coll_basic_alltoallw_inter, mca_coll_basic_barrier_inter_lin, - true, mca_coll_basic_bcast_lin_inter, mca_coll_basic_exscan_inter, mca_coll_basic_gather_inter, mca_coll_basic_gatherv_inter, - true, mca_coll_basic_reduce_lin_inter, mca_coll_basic_reduce_scatter_inter, NULL, @@ -164,12 +158,10 @@ static const mca_coll_1_0_0_t inter_log = { mca_coll_basic_alltoallv_inter, mca_coll_basic_alltoallw_inter, mca_coll_basic_barrier_inter_log, - true, mca_coll_basic_bcast_log_inter, mca_coll_basic_exscan_inter, mca_coll_basic_gather_inter, mca_coll_basic_gatherv_inter, - true, mca_coll_basic_reduce_log_inter, mca_coll_basic_reduce_scatter_inter, NULL, diff --git a/src/mca/coll/basic/src/coll_basic_reduce.c b/src/mca/coll/basic/src/coll_basic_reduce.c index c572b84ea5..d27683e190 100644 --- a/src/mca/coll/basic/src/coll_basic_reduce.c +++ b/src/mca/coll/basic/src/coll_basic_reduce.c @@ -281,8 +281,11 @@ int mca_coll_basic_reduce_log_intra(void *sbuf, void *rbuf, int count, } pml_buffer = free_buffer - lb; - /* read the comment about commutative operations (few lines down the page) */ - if( ompi_op_is_commute(op) ) rcv_buffer = pml_buffer; + /* read the comment about commutative operations (few lines down + the page) */ + if( ompi_op_is_commute(op) ) { + rcv_buffer = pml_buffer; + } else rcv_buffer = rbuf; } @@ -325,13 +328,16 @@ int mca_coll_basic_reduce_log_intra(void *sbuf, void *rbuf, int count, } fl_recv = 1; - /* Most of the time (all except the first one for commutative operations) we - * receive in the user provided buffer (rbuf). But the exception is here to allow - * us to dont have to copy from the sbuf to a temporary location. If the operation - * is commutative we dont care in which order we apply the operation, so for the - * first time we can receive the data in the pml_buffer and then apply to - * operation between this buffer and the user provided data. - */ + + /* Most of the time (all except the first one for commutative + operations) we receive in the user provided buffer + (rbuf). But the exception is here to allow us to dont have + to copy from the sbuf to a temporary location. If the + operation is commutative we dont care in which order we + apply the operation, so for the first time we can receive + the data in the pml_buffer and then apply to operation + between this buffer and the user provided data. */ + err = mca_pml.pml_recv( rcv_buffer, count, dtype, peer, MCA_COLL_BASE_TAG_REDUCE, comm, MPI_STATUS_IGNORE ); @@ -349,19 +355,22 @@ int mca_coll_basic_reduce_log_intra(void *sbuf, void *rbuf, int count, ompi_op_reduce(op, rcv_buffer, pml_buffer, count, dtype); } else { /* If we're commutative, we don't care about the order of - * operations and we can just reduce the operations now. - * If we are not commutative, we have to copy the send - * buffer into a temp buffer (pml_buffer) and then reduce - * what we just received against it. - */ + operations and we can just reduce the operations now. + If we are not commutative, we have to copy the send + buffer into a temp buffer (pml_buffer) and then reduce + what we just received against it. */ if( !ompi_op_is_commute(op) ) { ompi_ddt_sndrcv( sbuf, count, dtype, pml_buffer, count, dtype, MCA_COLL_BASE_TAG_REDUCE, comm); ompi_op_reduce( op, rbuf, pml_buffer, count, dtype ); - } else + } else { ompi_op_reduce(op, sbuf, pml_buffer, count, dtype); - snd_buffer = pml_buffer; /* now we have to send the buffer containing the computed data */ - rcv_buffer = rbuf; /* starting from now we always receive in the user provided buffer */ + } + /* now we have to send the buffer containing the computed data */ + snd_buffer = pml_buffer; + /* starting from now we always receive in the user + provided buffer */ + rcv_buffer = rbuf; } } } @@ -378,10 +387,12 @@ int mca_coll_basic_reduce_log_intra(void *sbuf, void *rbuf, int count, MCA_PML_BASE_SEND_STANDARD, comm); } } else if (rank == root) { - err = mca_pml.pml_recv( rcv_buffer, count, dtype, 0, MCA_COLL_BASE_TAG_REDUCE, + err = mca_pml.pml_recv( rcv_buffer, count, dtype, 0, + MCA_COLL_BASE_TAG_REDUCE, comm, MPI_STATUS_IGNORE); - if( rcv_buffer != rbuf ) + if( rcv_buffer != rbuf ) { ompi_op_reduce(op, rcv_buffer, rbuf, count, dtype); + } } if (NULL != free_buffer) { diff --git a/src/mca/coll/coll.h b/src/mca/coll/coll.h index 909b4025e5..7c993d69e9 100644 --- a/src/mca/coll/coll.h +++ b/src/mca/coll/coll.h @@ -170,12 +170,10 @@ struct mca_coll_1_0_0_t { mca_coll_base_alltoallv_fn_t coll_alltoallv; mca_coll_base_alltoallw_fn_t coll_alltoallw; mca_coll_base_barrier_fn_t coll_barrier; - bool coll_bcast_optimization; mca_coll_base_bcast_fn_t coll_bcast; mca_coll_base_exscan_fn_t coll_exscan; mca_coll_base_gather_fn_t coll_gather; mca_coll_base_gatherv_fn_t coll_gatherv; - bool coll_reduce_optimization; mca_coll_base_reduce_fn_t coll_reduce; mca_coll_base_reduce_scatter_fn_t coll_reduce_scatter; mca_coll_base_scan_fn_t coll_scan; diff --git a/src/mpi/c/allgather.c b/src/mpi/c/allgather.c index 437fbc2853..a33d215f57 100644 --- a/src/mpi/c/allgather.c +++ b/src/mpi/c/allgather.c @@ -32,20 +32,18 @@ int MPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Unrooted operation -- same checks for all ranks on both intracommunicators and intercommunicators */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { - return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, - FUNC_NAME); - } - - if ((MPI_DATATYPE_NULL == sendtype) || - (MPI_DATATYPE_NULL == recvtype)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if ((sendcount < 0) || (recvcount < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); + } else if (MPI_DATATYPE_NULL == recvtype) { + err = MPI_ERR_TYPE; + } else if (recvcount < 0) { + err = MPI_ERR_COUNT; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Invoke the coll component to perform the back-end operation */ diff --git a/src/mpi/c/allgatherv.c b/src/mpi/c/allgatherv.c index 46277d1b10..58f2e6e072 100644 --- a/src/mpi/c/allgatherv.c +++ b/src/mpi/c/allgatherv.c @@ -32,25 +32,22 @@ int MPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Unrooted operation -- same checks for all ranks on both intracommunicators and intercommunicators */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } - if ((MPI_DATATYPE_NULL == sendtype) || - (MPI_DATATYPE_NULL == recvtype)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); size = ompi_comm_size(comm); for (i = 0; i < size; ++i) { if (recvcounts[i] < 0) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + } else if (MPI_DATATYPE_NULL == recvtype) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } } diff --git a/src/mpi/c/allreduce.c b/src/mpi/c/allreduce.c index 106ca66c2f..f810db09f1 100644 --- a/src/mpi/c/allreduce.c +++ b/src/mpi/c/allreduce.c @@ -32,28 +32,21 @@ int MPI_Allreduce(void *sendbuf, void *recvbuf, int count, /* Unrooted operation -- same checks for all ranks on both intracommunicators and intercommunicators */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); - } - - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (MPI_OP_NULL == op) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED && - -1 == ompi_op_ddt_map[datatype->id]) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (count < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + } else if (MPI_OP_NULL == op) { + err = MPI_ERR_OP; + } else if (ompi_op_is_intrinsic(op) && + datatype->id < DT_MAX_PREDEFINED && + -1 == ompi_op_ddt_map[datatype->id]) { + err = MPI_ERR_OP; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Invoke the coll component to perform the back-end operation */ diff --git a/src/mpi/c/alltoall.c b/src/mpi/c/alltoall.c index f0dae2f10c..5324261f1d 100644 --- a/src/mpi/c/alltoall.c +++ b/src/mpi/c/alltoall.c @@ -32,20 +32,19 @@ int MPI_Alltoall(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Unrooted operation -- same checks for all ranks on both intracommunicators and intercommunicators */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); + } else if (MPI_DATATYPE_NULL == recvtype) { + err = MPI_ERR_TYPE; + } else if (recvcount < 0) { + err = MPI_ERR_COUNT; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); } - - if ((MPI_DATATYPE_NULL == sendtype) || - (MPI_DATATYPE_NULL == recvtype)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if ((sendcount < 0) || (recvcount < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Invoke the coll component to perform the back-end operation */ diff --git a/src/mpi/c/alltoallv.c b/src/mpi/c/alltoallv.c index bcdefa5abc..495861fde0 100644 --- a/src/mpi/c/alltoallv.c +++ b/src/mpi/c/alltoallv.c @@ -32,6 +32,7 @@ int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls, /* Unrooted operation -- same checks for all ranks */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -43,24 +44,21 @@ int MPI_Alltoallv(void *sendbuf, int *sendcounts, int *sdispls, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } - if ((MPI_DATATYPE_NULL == sendtype) || - (MPI_DATATYPE_NULL == recvtype)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - /* Use a different size for intracommunicators and + /* We always define the remote group to be the same as the local + group in the case of an intracommunicator, so it's safe to + get the size of the remote group here for both intra- and intercommunicators */ - if (OMPI_COMM_IS_INTRA(comm)) { - size = ompi_comm_size(comm); - } else { - size = ompi_comm_remote_size(comm); - } - + size = ompi_comm_remote_size(comm); for (i = 0; i < size; ++i) { - if ((sendcounts[i] < 0) || (recvcounts[i] < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + if (recvcounts[i] < 0) { + err = MPI_ERR_COUNT; + } else if (MPI_DATATYPE_NULL == recvtype) { + err = MPI_ERR_TYPE; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } diff --git a/src/mpi/c/alltoallw.c b/src/mpi/c/alltoallw.c index c08fc4c5a6..6dde1f9313 100644 --- a/src/mpi/c/alltoallw.c +++ b/src/mpi/c/alltoallw.c @@ -32,35 +32,33 @@ int MPI_Alltoallw(void *sendbuf, int *sendcounts, int *sdispls, /* Unrooted operation -- same checks for all ranks */ + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); } - if ((NULL == sendcounts) || (NULL == sdispls) || - (NULL == recvcounts) || (NULL == rdispls)) { + if ((NULL == sendcounts) || (NULL == sdispls) || (NULL == sendtypes) || + (NULL == recvcounts) || (NULL == rdispls) || (NULL == recvtypes)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } - /* Use a different size for intracommunicators and + /* We always define the remote group to be the same as the local + group in the case of an intracommunicator, so it's safe to + get the size of the remote group here for both intra- and intercommunicators */ - if (OMPI_COMM_IS_INTRA(comm)) { - size = ompi_comm_size(comm); - } else { - size = ompi_comm_remote_size(comm); - } - + size = ompi_comm_remote_size(comm); for (i = 0; i < size; ++i) { - if ((MPI_DATATYPE_NULL == sendtypes[i]) || - (MPI_DATATYPE_NULL == recvtypes[i])) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if ((sendcounts[i] < 0) || (recvcounts[i] < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + if (recvcounts[i] < 0) { + err = MPI_ERR_COUNT; + } else if (MPI_DATATYPE_NULL == recvtypes[i]) { + err = MPI_ERR_TYPE; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtypes[i], sendcounts[i]); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } diff --git a/src/mpi/c/bcast.c b/src/mpi/c/bcast.c index d9f04c9e0f..59ee8ffd26 100644 --- a/src/mpi/c/bcast.c +++ b/src/mpi/c/bcast.c @@ -26,6 +26,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -34,13 +35,8 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, /* Errors for all ranks */ - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (count < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); /* Errors for intracommunicators */ @@ -54,7 +50,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, else { if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { + MPI_ROOT == root || MPI_PROC_NULL == root)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } } @@ -68,7 +64,7 @@ int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, /* Can we optimize? */ - if (count == 0 && comm->c_coll.coll_bcast_optimization) { + if (count == 0) { return MPI_SUCCESS; } diff --git a/src/mpi/c/exscan.c b/src/mpi/c/exscan.c index 85d860c8ca..e6d69a554b 100644 --- a/src/mpi/c/exscan.c +++ b/src/mpi/c/exscan.c @@ -28,6 +28,7 @@ int MPI_Exscan(void *sendbuf, void *recvbuf, int count, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -37,22 +38,16 @@ int MPI_Exscan(void *sendbuf, void *recvbuf, int count, /* Unrooted operation -- same checks for intracommunicators and intercommunicators */ - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (MPI_OP_NULL == op) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED && - -1 == ompi_op_ddt_map[datatype->id]) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); + else if (MPI_OP_NULL == op) { + err = MPI_ERR_OP; + } else if (ompi_op_is_intrinsic(op) && + datatype->id < DT_MAX_PREDEFINED && + -1 == ompi_op_ddt_map[datatype->id]) { + err = MPI_ERR_OP; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count); } - - if (count < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Invoke the coll component to perform the back-end operation */ diff --git a/src/mpi/c/gather.c b/src/mpi/c/gather.c index 8feca31e7e..128a9f2094 100644 --- a/src/mpi/c/gather.c +++ b/src/mpi/c/gather.c @@ -27,6 +27,7 @@ int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -43,13 +44,8 @@ int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); /* Errors for the root. Some of these could have been combined into compound if statements above, but since @@ -71,21 +67,16 @@ int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Errors for intercommunicators */ else { - if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { + if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || + MPI_ROOT == root || MPI_PROC_NULL == root)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } /* Errors for the senders */ - if (root != MPI_ROOT && root != MPI_PROC_NULL) { - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } + if (MPI_ROOT != root && MPI_PROC_NULL != root) { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Errors for the root. Ditto on the comment above -- these @@ -97,7 +88,7 @@ int MPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); } - if (recvtype == MPI_DATATYPE_NULL) { + if (MPI_DATATYPE_NULL == recvtype) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } } diff --git a/src/mpi/c/gatherv.c b/src/mpi/c/gatherv.c index 91aadcdf2c..0db2a8a6fb 100644 --- a/src/mpi/c/gatherv.c +++ b/src/mpi/c/gatherv.c @@ -28,6 +28,7 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int i, size, err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -41,16 +42,11 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Errors for all ranks */ if ((root >= ompi_comm_size(comm)) || (root < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); - } - - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); + err = MPI_ERR_ROOT; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); /* Errors for the root. Some of these could have been combined into compound if statements above, but since @@ -59,10 +55,6 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, them out into individual tests. */ if (ompi_comm_rank(comm) == root) { - if (recvtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - if (NULL == displs) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } @@ -75,6 +67,8 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, for (i = 0; i < size; ++i) { if (recvcounts[i] < 0) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + } else if (MPI_DATATYPE_NULL == recvtype) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } } } @@ -84,20 +78,15 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, else { if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { + MPI_ROOT == root || MPI_PROC_NULL == root)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } /* Errors for the senders */ - if (root != MPI_ROOT && root != MPI_PROC_NULL) { - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } + if (MPI_ROOT != root && MPI_PROC_NULL != root) { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Errors for the root. Ditto on the comment above -- these @@ -117,6 +106,8 @@ int MPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, for (i = 0; i < size; ++i) { if (recvcounts[i] < 0) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + } else if (MPI_DATATYPE_NULL == recvtype) { + return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } } } diff --git a/src/mpi/c/reduce.c b/src/mpi/c/reduce.c index 6fc7920997..aae86ebfec 100644 --- a/src/mpi/c/reduce.c +++ b/src/mpi/c/reduce.c @@ -28,6 +28,7 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -36,28 +37,22 @@ int MPI_Reduce(void *sendbuf, void *recvbuf, int count, /* Checks for all ranks */ - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (MPI_OP_NULL == op) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED && - -1 == ompi_op_ddt_map[datatype->id]) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (count < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); + else if (MPI_OP_NULL == op) { + err = MPI_ERR_OP; + } else if (ompi_op_is_intrinsic(op) && + datatype->id < DT_MAX_PREDEFINED && + -1 == ompi_op_ddt_map[datatype->id]) { + err = MPI_ERR_OP; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); /* Intercommunicator errors */ if (!OMPI_COMM_IS_INTRA(comm)) { if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { + MPI_ROOT == root || MPI_PROC_NULL == root)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } } diff --git a/src/mpi/c/reduce_scatter.c b/src/mpi/c/reduce_scatter.c index d785ad2b9b..ef124a4013 100644 --- a/src/mpi/c/reduce_scatter.c +++ b/src/mpi/c/reduce_scatter.c @@ -28,6 +28,7 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, int i, err, size; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -37,32 +38,26 @@ int MPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, /* Unrooted operation; same checks for all ranks on both intracommunicators and intercommunicators */ - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (MPI_OP_NULL == op) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); + else if (MPI_OP_NULL == op) { + err = MPI_ERR_OP; + } else if (ompi_op_is_intrinsic(op) && + datatype->id < DT_MAX_PREDEFINED && + -1 == ompi_op_ddt_map[datatype->id]) { + err = MPI_ERR_OP; + } else if (NULL == recvcounts) { + err = MPI_ERR_COUNT; } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); - if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED && - -1 == ompi_op_ddt_map[datatype->id]) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } + /* We always define the remote group to be the same as the local + group in the case of an intracommunicator, so it's safe to + get the size of the remote group here for both intra- and + intercommunicators */ - if (NULL == recvcounts) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (OMPI_COMM_IS_INTRA(comm)) { - size = ompi_comm_size(comm); - } else { - size = ompi_comm_remote_size(comm); - } + size = ompi_comm_remote_size(comm); for (i = 0; i < size; ++i) { - if (recvcounts[i] < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, recvcounts[i]); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } diff --git a/src/mpi/c/scan.c b/src/mpi/c/scan.c index 63672dff4f..d1fe73361c 100644 --- a/src/mpi/c/scan.c +++ b/src/mpi/c/scan.c @@ -28,6 +28,7 @@ int MPI_Scan(void *sendbuf, void *recvbuf, int count, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -37,28 +38,22 @@ int MPI_Scan(void *sendbuf, void *recvbuf, int count, /* No intercommunicators allowed! (MPI does not define MPI_SCAN on intercommunicators) */ - if (OMPI_COMM_IS_INTER(comm)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COMM, FUNC_NAME); + else if (OMPI_COMM_IS_INTER(comm)) { + err = MPI_ERR_COMM; } /* Unrooted operation; checks for all ranks */ - if (MPI_DATATYPE_NULL == datatype) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (MPI_OP_NULL == op) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); - } - - if (ompi_op_is_intrinsic(op) && datatype->id < DT_MAX_PREDEFINED && - -1 == ompi_op_ddt_map[datatype->id]) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, FUNC_NAME); + else if (MPI_OP_NULL == op) { + err = MPI_ERR_OP; + } else if (ompi_op_is_intrinsic(op) && + datatype->id < DT_MAX_PREDEFINED && + -1 == ompi_op_ddt_map[datatype->id]) { + err = MPI_ERR_OP; + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count); } - - if (count < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Call the coll component to actually perform the allgather */ diff --git a/src/mpi/c/scatter.c b/src/mpi/c/scatter.c index 5a77a9ef5d..c5f69a9f2d 100644 --- a/src/mpi/c/scatter.c +++ b/src/mpi/c/scatter.c @@ -28,6 +28,7 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, int err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -41,15 +42,11 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, /* Errors for all ranks */ if ((root >= ompi_comm_size(comm)) || (root < 0)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); - } - - if (recvcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (recvtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); + err = MPI_ERR_ROOT; + } else if (recvcount < 0) { + err = MPI_ERR_COUNT; + } else if (MPI_DATATYPE_NULL == recvtype) { + err = MPI_ERR_TYPE; } /* Errors for the root. Some of these could have been @@ -58,34 +55,27 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, run time) for efficiency, it's more clear to separate them out into individual tests. */ - if (ompi_comm_rank(comm) == root) { - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + else if (ompi_comm_rank(comm) == root) { + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } /* Errors for intercommunicators */ else { if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); + MPI_ROOT == root || MPI_PROC_NULL == root)) { + err = MPI_ERR_ROOT; } /* Errors for the receivers */ - if (root != MPI_ROOT && root != MPI_PROC_NULL) { + else if (MPI_ROOT != root && MPI_PROC_NULL != root) { if (recvcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (recvtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); + err = MPI_ERR_COUNT; + } else if (MPI_DATATYPE_NULL == recvtype) { + err = MPI_ERR_TYPE; } } @@ -94,14 +84,9 @@ int MPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, make the code easier to read. */ else if (MPI_ROOT == root) { - if (sendcount < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } - - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcount); } + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } diff --git a/src/mpi/c/scatterv.c b/src/mpi/c/scatterv.c index ad6db3524a..dad40dbe2a 100644 --- a/src/mpi/c/scatterv.c +++ b/src/mpi/c/scatterv.c @@ -28,6 +28,7 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, int i, size, err; if (MPI_PARAM_CHECK) { + err = MPI_SUCCESS; OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, @@ -48,7 +49,7 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); } - if (recvtype == MPI_DATATYPE_NULL) { + if (MPI_DATATYPE_NULL == recvtype) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } @@ -59,10 +60,6 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, them out into individual tests. */ if (ompi_comm_rank(comm) == root) { - if (sendtype == MPI_DATATYPE_NULL) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); - } - if (NULL == displs) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME); } @@ -73,9 +70,8 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, size = ompi_comm_size(comm); for (i = 0; i < size; ++i) { - if (sendcounts[i] < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } } @@ -84,18 +80,18 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, else { if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) || - root == MPI_ROOT || root == MPI_PROC_NULL)) { + MPI_ROOT == root || MPI_PROC_NULL == root)) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME); } /* Errors for the receivers */ - if (root != MPI_ROOT && root != MPI_PROC_NULL) { + if (MPI_ROOT != root && MPI_PROC_NULL != root) { if (recvcount < 0) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); } - if (recvtype == MPI_DATATYPE_NULL) { + if (MPI_DATATYPE_NULL == recvtype) { return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_TYPE, FUNC_NAME); } } @@ -115,9 +111,8 @@ int MPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, size = ompi_comm_size(comm); for (i = 0; i < size; ++i) { - if (sendcounts[i] < 0) { - return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_COUNT, FUNC_NAME); - } + OMPI_CHECK_DATATYPE_FOR_SEND(err, sendtype, sendcounts[i]); + OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME); } } } diff --git a/src/mpi/c/send.c b/src/mpi/c/send.c index 89947d73b5..fcafa25e62 100644 --- a/src/mpi/c/send.c +++ b/src/mpi/c/send.c @@ -34,12 +34,15 @@ int MPI_Send(void *buf, int count, MPI_Datatype type, int dest, OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_comm_invalid(comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); + } else if (count < 0) { + rc = MPI_ERR_COUNT; } else if (tag < 0 || tag > MPI_TAG_UB_VALUE) { rc = MPI_ERR_TAG; } else if (ompi_comm_peer_invalid(comm, dest)) { rc = MPI_ERR_RANK; - } else - OMPI_CHECK_DATATYPE_FOR_SEND( rc, type, count ); + } else { + OMPI_CHECK_DATATYPE_FOR_SEND(rc, type, count); + } OMPI_ERRHANDLER_CHECK(rc, comm, rc, FUNC_NAME); }