- int retval;
- smpi_bench_end();
-
- if (comm == MPI_COMM_NULL) {
- retval = MPI_ERR_COMM;
- } else if (not datatype->is_valid()) {
- retval = MPI_ERR_TYPE;
- } else if (op == MPI_OP_NULL) {
- retval = MPI_ERR_OP;
- } else if (recvcount < 0) {
- retval = MPI_ERR_ARG;
- } else if (request == nullptr){
- retval = MPI_ERR_ARG;
- } else {
- int count = comm->size();
-
- int rank = simgrid::s4u::this_actor::get_pid();
- int dt_send_size = datatype->is_replayable() ? 1 : datatype->size();
- std::vector<int>* trace_recvcounts = new std::vector<int>(recvcount * dt_send_size); // copy data to avoid bad free
-
- void* sendtmpbuf = sendbuf;
- if (sendbuf == MPI_IN_PLACE) {
- sendtmpbuf = static_cast<void*>(xbt_malloc(recvcount * count * datatype->size()));
- memcpy(sendtmpbuf, recvbuf, recvcount * count * datatype->size());
- }
-
- TRACE_smpi_comm_in(rank, request==MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block":"PMPI_Ireduce_scatter_block",
- new simgrid::instr::VarCollTIData(request==MPI_REQUEST_IGNORED ? "reducescatter":"ireducescatter", -1, 0, nullptr, -1, trace_recvcounts,
- simgrid::smpi::Datatype::encode(datatype), ""));
-
- int* recvcounts = new int[count];
- for (int i = 0; i < count; i++)
- recvcounts[i] = recvcount;
- if(request == MPI_REQUEST_IGNORED)
- simgrid::smpi::Colls::reduce_scatter(sendtmpbuf, recvbuf, recvcounts, datatype, op, comm);
- else
- simgrid::smpi::Colls::ireduce_scatter(sendtmpbuf, recvbuf, recvcounts, datatype, op, comm, request);
- delete[] recvcounts;
- retval = MPI_SUCCESS;
-
- TRACE_smpi_comm_out(rank);
-
- if (sendbuf == MPI_IN_PLACE)
- xbt_free(sendtmpbuf);
- }
-
- smpi_bench_begin();
- return retval;
-}
-int PMPI_Alltoall(void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
+ CHECK_COMM(6)
+ SET_BUF1(sendbuf)
+ SET_BUF2(recvbuf)
+ CHECK_TYPE(4, datatype)
+ CHECK_COUNT(3, recvcount)
+ CHECK_BUFFER(1, sendbuf, recvcount, datatype)
+ CHECK_BUFFER(2, recvbuf, recvcount, datatype)
+ CHECK_REQUEST(7)
+ CHECK_OP(5, op, datatype)
+ CHECK_COLLECTIVE(
+ comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block" : "PMPI_Ireduce_scatter_block") +
+ " with op " + op->name())
+
+ const SmpiBenchGuard suspend_bench;
+
+ int count = comm->size();
+
+ aid_t pid = simgrid::s4u::this_actor::get_pid();
+ auto trace_recvcounts = std::make_shared<std::vector<int>>(recvcount);
+
+ std::vector<unsigned char> tmp_sendbuf;
+ const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, recvcount * count, datatype);
+
+ TRACE_smpi_comm_in(
+ pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block" : "PMPI_Ireduce_scatter_block",
+ new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, -1,
+ nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
+
+ std::vector<int> recvcounts(count);
+ for (int i = 0; i < count; i++)
+ recvcounts[i] = recvcount;
+ if (request == MPI_REQUEST_IGNORED)
+ simgrid::smpi::colls::reduce_scatter(real_sendbuf, recvbuf, recvcounts.data(), datatype, op, comm);
+ else
+ simgrid::smpi::colls::ireduce_scatter(real_sendbuf, recvbuf, recvcounts.data(), datatype, op, comm, request);
+
+ TRACE_smpi_comm_out(pid);
+ return MPI_SUCCESS;
+}
+
+int PMPI_Alltoall(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,