-/* Copyright (c) 2013-2019. The SimGrid Team.
+/* Copyright (c) 2013-2021. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
namespace simgrid{
namespace smpi{
-int Coll_reduce_scatter_mpich_pair::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
- MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int reduce_scatter__mpich_pair(const void *sendbuf, void *recvbuf, const int recvcounts[],
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int rank, comm_size, i;
MPI_Aint extent, true_extent, true_lb;
unsigned char* tmp_recvbuf;
int mpi_errno = MPI_SUCCESS;
int total_count, dst, src;
- int is_commutative;
comm_size = comm->size();
rank = comm->rank();
extent =datatype->get_extent();
datatype->extent(&true_lb, &true_extent);
- if (op->is_commutative()) {
- is_commutative = 1;
- }
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
int* disps = new int[comm_size];
/* copy result back into recvbuf */
mpi_errno =
Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype, recvbuf, recvcounts[rank], datatype);
- if (mpi_errno)
+ if (mpi_errno) {
+ delete[] disps;
+ smpi_free_tmp_buffer(tmp_recvbuf);
return (mpi_errno);
+ }
}
else {
if (op != MPI_OP_NULL)
/* copy result back into recvbuf */
mpi_errno = Datatype::copy(tmp_recvbuf, recvcounts[rank], datatype,
((char*)recvbuf + disps[rank] * extent), recvcounts[rank], datatype);
- if (mpi_errno)
+ if (mpi_errno) {
+ delete[] disps;
+ smpi_free_tmp_buffer(tmp_recvbuf);
return (mpi_errno);
+ }
}
}
}
recvcounts[rank], datatype,
recvbuf,
recvcounts[rank], datatype );
- if (mpi_errno) return(mpi_errno);
+ if (mpi_errno) {
+ delete[] disps;
+ smpi_free_tmp_buffer(tmp_recvbuf);
+ return (mpi_errno);
+ }
}
delete[] disps;
}
-int Coll_reduce_scatter_mpich_noncomm::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
- MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
+int reduce_scatter__mpich_noncomm(const void *sendbuf, void *recvbuf, const int recvcounts[],
+ MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int mpi_errno = MPI_SUCCESS;
int comm_size = comm->size() ;
-int Coll_reduce_scatter_mpich_rdb::reduce_scatter(const void *sendbuf, void *recvbuf, const int recvcounts[],
+int reduce_scatter__mpich_rdb(const void *sendbuf, void *recvbuf, const int recvcounts[],
MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
{
int rank, comm_size, i;
int mask, dst_tree_root, my_tree_root, j, k;
int received;
MPI_Datatype sendtype, recvtype;
- int nprocs_completed, tmp_mask, tree_root, is_commutative=0;
+ int nprocs_completed, tmp_mask, tree_root;
comm_size = comm->size();
rank = comm->rank();
extent =datatype->get_extent();
datatype->extent(&true_lb, &true_extent);
- if ((op==MPI_OP_NULL) || op->is_commutative()) {
- is_commutative = 1;
- }
+ bool is_commutative = (op == MPI_OP_NULL || op->is_commutative());
int* disps = new int[comm_size];
else
mpi_errno = Datatype::copy(recvbuf, total_count, datatype, tmp_results, total_count, datatype);
- if (mpi_errno)
+ if (mpi_errno) {
+ delete[] disps;
return (mpi_errno);
+ }
mask = 0x1;
i = 0;