1 /* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "smpi_coll.hpp"
8 #include "smpi_comm.hpp"
9 #include "smpi_request.hpp"
10 #include "smpi_datatype_derived.hpp"
11 #include "smpi_op.hpp"
12 #include "src/smpi/include/smpi_actor.hpp"
16 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(smpi_pmpi);
18 static const void* smpi_get_in_place_buf(const void* inplacebuf, const void* otherbuf,
19 std::vector<unsigned char>& tmp_sendbuf, int count, MPI_Datatype datatype)
21 if (inplacebuf == MPI_IN_PLACE) {
22 tmp_sendbuf.resize(count * datatype->get_extent());
23 simgrid::smpi::Datatype::copy(otherbuf, count, datatype, tmp_sendbuf.data(), count, datatype);
24 return tmp_sendbuf.data();
29 /* PMPI User level calls */
31 int PMPI_Barrier(MPI_Comm comm)
33 return PMPI_Ibarrier(comm, MPI_REQUEST_IGNORED);
36 int PMPI_Ibarrier(MPI_Comm comm, MPI_Request *request)
40 CHECK_COLLECTIVE(comm, request == MPI_REQUEST_IGNORED ? "PMPI_Barrier" : "PMPI_Ibarrier")
41 const SmpiBenchGuard suspend_bench;
42 aid_t pid = simgrid::s4u::this_actor::get_pid();
43 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Barrier" : "PMPI_Ibarrier",
44 new simgrid::instr::NoOpTIData(request == MPI_REQUEST_IGNORED ? "barrier" : "ibarrier"));
45 if (request == MPI_REQUEST_IGNORED) {
46 simgrid::smpi::colls::barrier(comm);
47 // Barrier can be used to synchronize RMA calls. Finish all requests from comm before.
48 comm->finish_rma_calls();
50 simgrid::smpi::colls::ibarrier(comm, request);
52 TRACE_smpi_comm_out(pid);
56 int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
58 return PMPI_Ibcast(buf, count, datatype, root, comm, MPI_REQUEST_IGNORED);
61 int PMPI_Ibcast(void* buf, int count, MPI_Datatype datatype, int root, MPI_Comm comm, MPI_Request* request)
66 CHECK_TYPE(3, datatype)
67 CHECK_BUFFER(1, buf, count, datatype)
70 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Bcast" : "PMPI_Ibcast") + " with root " +
73 const SmpiBenchGuard suspend_bench;
74 aid_t pid = simgrid::s4u::this_actor::get_pid();
75 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Bcast" : "PMPI_Ibcast",
76 new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "bcast" : "ibcast", root, -1.0,
78 simgrid::smpi::Datatype::encode(datatype), ""));
79 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
80 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
82 if (comm->size() > 1) {
83 if (request == MPI_REQUEST_IGNORED)
84 simgrid::smpi::colls::bcast(buf, count, datatype, root, comm);
86 simgrid::smpi::colls::ibcast(buf, count, datatype, root, comm, request);
88 if (request != MPI_REQUEST_IGNORED)
89 *request = MPI_REQUEST_NULL;
92 TRACE_smpi_comm_out(pid);
96 int PMPI_Gather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,void *recvbuf, int recvcount, MPI_Datatype recvtype,
97 int root, MPI_Comm comm){
98 return PMPI_Igather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, MPI_REQUEST_IGNORED);
101 int PMPI_Igather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
102 MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
106 int rank = comm->rank();
107 if(sendbuf != MPI_IN_PLACE){
108 CHECK_COUNT(2, sendcount)
109 CHECK_TYPE(3, sendtype)
110 CHECK_BUFFER(1,sendbuf, sendcount, sendtype)
114 CHECK_NOT_IN_PLACE_ROOT(4, recvbuf)
115 CHECK_TYPE(6, recvtype)
116 CHECK_COUNT(5, recvcount)
117 CHECK_BUFFER(4, recvbuf, recvcount, recvtype)
119 CHECK_NOT_IN_PLACE_ROOT(1, sendbuf)
123 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather") + +" with root " +
124 std::to_string(root))
126 const void* real_sendbuf = sendbuf;
127 int real_sendcount = sendcount;
128 MPI_Datatype real_sendtype = sendtype;
130 if (sendbuf == MPI_IN_PLACE) {
132 real_sendtype = recvtype;
133 } else if(recvtype->size() * recvcount != sendtype->size() * sendcount){
134 XBT_WARN("MPI_(I)Gather : received size at root differs from sent size : %zu vs %zu", recvtype->size() * recvcount , sendtype->size() * sendcount);
135 return MPI_ERR_TRUNCATE;
139 const SmpiBenchGuard suspend_bench;
141 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
142 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
144 aid_t pid = simgrid::s4u::this_actor::get_pid();
146 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Gather" : "PMPI_Igather",
147 new simgrid::instr::CollTIData(
148 request == MPI_REQUEST_IGNORED ? "gather" : "igather", root, -1.0,
149 real_sendcount, recvcount,
150 simgrid::smpi::Datatype::encode(real_sendtype), simgrid::smpi::Datatype::encode(recvtype)));
151 if (request == MPI_REQUEST_IGNORED)
152 simgrid::smpi::colls::gather(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcount, recvtype, root, comm);
154 simgrid::smpi::colls::igather(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcount, recvtype, root, comm,
157 TRACE_smpi_comm_out(pid);
161 int PMPI_Gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recvbuf, const int *recvcounts, const int *displs,
162 MPI_Datatype recvtype, int root, MPI_Comm comm){
163 return PMPI_Igatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm, MPI_REQUEST_IGNORED);
166 int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, const int* recvcounts, const int* displs,
167 MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
171 int rank = comm->rank();
172 if(sendbuf != MPI_IN_PLACE){
173 CHECK_TYPE(3, sendtype)
174 CHECK_COUNT(2, sendcount)
176 CHECK_BUFFER(1, sendbuf, sendcount, sendtype)
179 CHECK_NOT_IN_PLACE_ROOT(4, recvbuf)
180 CHECK_TYPE(6, recvtype)
181 CHECK_NULL(5, MPI_ERR_COUNT, recvcounts)
182 CHECK_NULL(6, MPI_ERR_ARG, displs)
184 CHECK_NOT_IN_PLACE_ROOT(1, sendbuf)
188 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Gatherv" : "PMPI_Igatherv") +
189 " with root " + std::to_string(root))
192 for (int i = 0; i < comm->size(); i++) {
193 CHECK_COUNT(5, recvcounts[i])
194 CHECK_BUFFER(4,recvbuf,recvcounts[i], recvtype)
198 const SmpiBenchGuard suspend_bench;
200 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
201 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
203 const void* real_sendbuf = sendbuf;
204 int real_sendcount = sendcount;
205 MPI_Datatype real_sendtype = sendtype;
206 if ((rank == root) && (sendbuf == MPI_IN_PLACE)) {
208 real_sendtype = recvtype;
211 aid_t pid = simgrid::s4u::this_actor::get_pid();
213 auto trace_recvcounts = std::make_shared<std::vector<int>>();
215 trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[comm->size()]);
216 else //this is not significant outside of root, put 0 as we don't know if recvcounts is initialized
217 trace_recvcounts->insert(trace_recvcounts->end(), comm->size(), 0);
219 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Gatherv" : "PMPI_Igatherv",
220 new simgrid::instr::VarCollTIData(
221 request == MPI_REQUEST_IGNORED ? "gatherv" : "igatherv", root,
223 nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(real_sendtype),
224 simgrid::smpi::Datatype::encode(recvtype)));
225 if (request == MPI_REQUEST_IGNORED)
226 simgrid::smpi::colls::gatherv(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcounts, displs, recvtype,
229 simgrid::smpi::colls::igatherv(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcounts, displs, recvtype,
230 root, comm, request);
232 TRACE_smpi_comm_out(pid);
236 int PMPI_Allgather(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
237 void *recvbuf, int recvcount, MPI_Datatype recvtype, MPI_Comm comm){
238 return PMPI_Iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, MPI_REQUEST_IGNORED);
241 int PMPI_Iallgather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
242 MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
247 int rank = comm->rank();
248 CHECK_NOT_IN_PLACE(4, recvbuf)
249 if(sendbuf != MPI_IN_PLACE){
250 CHECK_COUNT(2, sendcount)
251 CHECK_TYPE(3, sendtype)
253 CHECK_TYPE(6, recvtype)
254 CHECK_COUNT(5, recvcount)
255 CHECK_BUFFER(1, sendbuf, sendcount, sendtype)
256 CHECK_BUFFER(4, recvbuf, recvcount, recvtype)
258 CHECK_COLLECTIVE(comm, request == MPI_REQUEST_IGNORED ? "PMPI_Allgather" : "PMPI_Iallggather")
260 if (sendbuf == MPI_IN_PLACE) {
261 sendbuf = static_cast<char*>(recvbuf) + recvtype->get_extent() * recvcount * comm->rank();
262 sendcount = recvcount;
266 if(recvtype->size() * recvcount != sendtype->size() * sendcount){
267 XBT_WARN("MPI_(I)Allgather : received size from each process differs from sent size : %zu vs %zu", recvtype->size() * recvcount, sendtype->size() * sendcount);
268 return MPI_ERR_TRUNCATE;
271 const SmpiBenchGuard suspend_bench;
273 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
274 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
276 aid_t pid = simgrid::s4u::this_actor::get_pid();
278 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Allgather" : "PMPI_Iallggather",
279 new simgrid::instr::CollTIData(
280 request == MPI_REQUEST_IGNORED ? "allgather" : "iallgather", -1, -1.0,
281 sendcount, recvcount,
282 simgrid::smpi::Datatype::encode(sendtype), simgrid::smpi::Datatype::encode(recvtype)));
283 if (request == MPI_REQUEST_IGNORED)
284 simgrid::smpi::colls::allgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm);
286 simgrid::smpi::colls::iallgather(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, request);
288 TRACE_smpi_comm_out(pid);
292 int PMPI_Allgatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
293 void *recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype, MPI_Comm comm){
294 return PMPI_Iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm, MPI_REQUEST_IGNORED);
297 int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, const int* recvcounts, const int* displs,
298 MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
303 int rank = comm->rank();
304 if(sendbuf != MPI_IN_PLACE)
305 CHECK_TYPE(3, sendtype)
306 CHECK_TYPE(6, recvtype)
307 CHECK_NULL(5, MPI_ERR_COUNT, recvcounts)
308 CHECK_NULL(6, MPI_ERR_ARG, displs)
309 if(sendbuf != MPI_IN_PLACE){
310 CHECK_COUNT(2, sendcount)
311 CHECK_BUFFER(1, sendbuf, sendcount, sendtype)
314 CHECK_NOT_IN_PLACE(4, recvbuf)
315 for (int i = 0; i < comm->size(); i++) {
316 CHECK_COUNT(5, recvcounts[i])
317 CHECK_BUFFER(4, recvbuf, recvcounts[i], recvtype)
319 CHECK_COLLECTIVE(comm, MPI_REQUEST_IGNORED ? "PMPI_Allgatherv" : "PMPI_Iallgatherv")
321 const SmpiBenchGuard suspend_bench;
323 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
324 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
326 if (sendbuf == MPI_IN_PLACE) {
327 sendbuf = static_cast<char*>(recvbuf) + recvtype->get_extent() * displs[comm->rank()];
328 sendcount = recvcounts[comm->rank()];
331 aid_t pid = simgrid::s4u::this_actor::get_pid();
333 auto trace_recvcounts = std::make_shared<std::vector<int>>();
334 trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[comm->size()]);
337 pid, request == MPI_REQUEST_IGNORED ? "PMPI_Allgatherv" : "PMPI_Iallgatherv",
338 new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "allgatherv" : "iallgatherv", -1,
340 -1, trace_recvcounts, simgrid::smpi::Datatype::encode(sendtype),
341 simgrid::smpi::Datatype::encode(recvtype)));
342 if (request == MPI_REQUEST_IGNORED)
343 simgrid::smpi::colls::allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
345 simgrid::smpi::colls::iallgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm,
348 TRACE_smpi_comm_out(pid);
352 int PMPI_Scatter(const void *sendbuf, int sendcount, MPI_Datatype sendtype,
353 void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm){
354 return PMPI_Iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, MPI_REQUEST_IGNORED);
357 int PMPI_Iscatter(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
358 MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
362 int rank = comm->rank();
365 CHECK_NOT_IN_PLACE_ROOT(1, sendbuf)
366 CHECK_COUNT(2, sendcount)
367 CHECK_TYPE(3, sendtype)
368 CHECK_BUFFER(1, sendbuf, sendcount, sendtype)
370 CHECK_NOT_IN_PLACE_ROOT(4, recvbuf)
372 if(recvbuf != MPI_IN_PLACE){
373 CHECK_COUNT(5, recvcount)
374 CHECK_TYPE(6, recvtype)
375 CHECK_BUFFER(4, recvbuf, recvcount, recvtype)
379 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Scatter" : "PMPI_Iscatter") +
380 " with root " + std::to_string(root))
382 if (recvbuf == MPI_IN_PLACE) {
384 recvcount = sendcount;
387 if((rank == root) && (recvtype->size() * recvcount != sendtype->size() * sendcount)){
388 XBT_WARN("MPI_(I)Scatter : sent size to each process differs from receive size");
389 return MPI_ERR_TRUNCATE;
392 const SmpiBenchGuard suspend_bench;
394 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
395 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
397 aid_t pid = simgrid::s4u::this_actor::get_pid();
399 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Scatter" : "PMPI_Iscatter",
400 new simgrid::instr::CollTIData(
401 request == MPI_REQUEST_IGNORED ? "scatter" : "iscatter", root, -1.0,
402 sendcount, recvcount,
403 simgrid::smpi::Datatype::encode(sendtype), simgrid::smpi::Datatype::encode(recvtype)));
404 if (request == MPI_REQUEST_IGNORED)
405 simgrid::smpi::colls::scatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm);
407 simgrid::smpi::colls::iscatter(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm, request);
409 TRACE_smpi_comm_out(pid);
413 int PMPI_Scatterv(const void *sendbuf, const int *sendcounts, const int *displs,
414 MPI_Datatype sendtype, void *recvbuf, int recvcount, MPI_Datatype recvtype, int root, MPI_Comm comm){
415 return PMPI_Iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm, MPI_REQUEST_IGNORED);
418 int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs, MPI_Datatype sendtype, void* recvbuf, int recvcount,
419 MPI_Datatype recvtype, int root, MPI_Comm comm, MPI_Request* request)
423 int rank = comm->rank();
424 if(recvbuf != MPI_IN_PLACE){
425 CHECK_COUNT(5, recvcount)
426 CHECK_TYPE(7, recvtype)
427 CHECK_BUFFER(4, recvbuf, recvcount, recvtype)
433 CHECK_NOT_IN_PLACE_ROOT(1, sendbuf)
434 CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
435 CHECK_NULL(3, MPI_ERR_ARG, displs)
436 CHECK_TYPE(4, sendtype)
437 for (int i = 0; i < comm->size(); i++){
438 CHECK_COUNT(2, sendcounts[i])
439 CHECK_BUFFER(1, sendbuf, sendcounts[i], sendtype)
441 if (recvbuf == MPI_IN_PLACE) {
443 recvcount = sendcounts[rank];
446 CHECK_NOT_IN_PLACE_ROOT(4, recvbuf)
448 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Scatterv" : "PMPI_Iscatterv") +
449 " with root " + std::to_string(root))
451 const SmpiBenchGuard suspend_bench;
453 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
454 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
456 aid_t pid = simgrid::s4u::this_actor::get_pid();
458 auto trace_sendcounts = std::make_shared<std::vector<int>>();
460 trace_sendcounts->insert(trace_sendcounts->end(), &sendcounts[0], &sendcounts[comm->size()]);
461 else //this is not significant outside of root, put 0 as we don't know if sendcounts is initialized
462 trace_sendcounts->insert(trace_sendcounts->end(), comm->size(), 0);
465 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Scatterv" : "PMPI_Iscatterv",
466 new simgrid::instr::VarCollTIData(
467 request == MPI_REQUEST_IGNORED ? "scatterv" : "iscatterv", root, -1,
468 trace_sendcounts, recvcount,
469 nullptr, simgrid::smpi::Datatype::encode(sendtype),
470 simgrid::smpi::Datatype::encode(recvtype)));
471 if (request == MPI_REQUEST_IGNORED)
472 simgrid::smpi::colls::scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm);
474 simgrid::smpi::colls::iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm,
477 TRACE_smpi_comm_out(pid);
481 int PMPI_Reduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm)
483 return PMPI_Ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, MPI_REQUEST_IGNORED);
486 int PMPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm, MPI_Request* request)
490 int rank = comm->rank();
491 CHECK_TYPE(4, datatype)
492 CHECK_COUNT(3, count)
493 CHECK_BUFFER(1, sendbuf, count, datatype)
496 CHECK_NOT_IN_PLACE(2, recvbuf)
497 CHECK_BUFFER(5, recvbuf, count, datatype)
499 CHECK_OP(5, op, datatype)
502 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Reduce" : "PMPI_Ireduce") + " with op " +
503 op->name() + " and root " + std::to_string(root))
505 const SmpiBenchGuard suspend_bench;
507 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
508 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
510 aid_t pid = simgrid::s4u::this_actor::get_pid();
512 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce" : "PMPI_Ireduce",
513 new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "reduce" : "ireduce", root, 0,
515 simgrid::smpi::Datatype::encode(datatype), ""));
516 if (request == MPI_REQUEST_IGNORED)
517 simgrid::smpi::colls::reduce(sendbuf, recvbuf, count, datatype, op, root, comm);
519 simgrid::smpi::colls::ireduce(sendbuf, recvbuf, count, datatype, op, root, comm, request);
521 TRACE_smpi_comm_out(pid);
525 int PMPI_Reduce_local(const void* inbuf, void* inoutbuf, int count, MPI_Datatype datatype, MPI_Op op)
529 CHECK_TYPE(4, datatype)
530 CHECK_COUNT(3, count)
531 CHECK_BUFFER(1, inbuf, count, datatype)
532 CHECK_BUFFER(2, inoutbuf, count, datatype)
533 CHECK_OP(5, op, datatype)
535 const SmpiBenchGuard suspend_bench;
536 op->apply(inbuf, inoutbuf, &count, datatype);
540 int PMPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
542 return PMPI_Iallreduce(sendbuf, recvbuf, count, datatype, op, comm, MPI_REQUEST_IGNORED);
545 int PMPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request)
550 int rank = comm->rank();
551 CHECK_NOT_IN_PLACE(2, recvbuf)
552 CHECK_TYPE(4, datatype)
553 CHECK_OP(5, op, datatype)
554 CHECK_COUNT(3, count)
555 CHECK_BUFFER(1, sendbuf, count, datatype)
556 CHECK_BUFFER(2, recvbuf, count, datatype)
558 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Alleduce" : "PMPI_Iallreduce") +
559 " with op " + op->name())
561 const SmpiBenchGuard suspend_bench;
563 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
564 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
566 std::vector<unsigned char> tmp_sendbuf;
567 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
569 aid_t pid = simgrid::s4u::this_actor::get_pid();
571 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Allreduce" : "PMPI_Iallreduce",
572 new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "allreduce" : "iallreduce", -1, 0,
574 simgrid::smpi::Datatype::encode(datatype), ""));
576 if (request == MPI_REQUEST_IGNORED)
577 simgrid::smpi::colls::allreduce(real_sendbuf, recvbuf, count, datatype, op, comm);
579 simgrid::smpi::colls::iallreduce(real_sendbuf, recvbuf, count, datatype, op, comm, request);
581 TRACE_smpi_comm_out(pid);
585 int PMPI_Scan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
587 return PMPI_Iscan(sendbuf, recvbuf, count, datatype, op, comm, MPI_REQUEST_IGNORED);
590 int PMPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request* request)
595 CHECK_TYPE(4, datatype)
596 CHECK_COUNT(3, count)
597 CHECK_BUFFER(1,sendbuf,count, datatype)
598 CHECK_BUFFER(2,recvbuf,count, datatype)
600 CHECK_OP(5, op, datatype)
601 CHECK_COLLECTIVE(comm,
602 std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Scan" : "PMPI_Iscan") + " with op " + op->name())
604 const SmpiBenchGuard suspend_bench;
606 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
607 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
609 aid_t pid = simgrid::s4u::this_actor::get_pid();
610 std::vector<unsigned char> tmp_sendbuf;
611 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
613 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Scan" : "PMPI_Iscan",
614 new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "scan" : "iscan", -1, 0.0,
615 count, 0, simgrid::smpi::Datatype::encode(datatype), ""));
618 if (request == MPI_REQUEST_IGNORED)
619 retval = simgrid::smpi::colls::scan(real_sendbuf, recvbuf, count, datatype, op, comm);
621 retval = simgrid::smpi::colls::iscan(real_sendbuf, recvbuf, count, datatype, op, comm, request);
623 TRACE_smpi_comm_out(pid);
627 int PMPI_Exscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
629 return PMPI_Iexscan(sendbuf, recvbuf, count, datatype, op, comm, MPI_REQUEST_IGNORED);
632 int PMPI_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request* request){
636 CHECK_TYPE(4, datatype)
637 CHECK_COUNT(3, count)
638 CHECK_BUFFER(1, sendbuf, count, datatype)
639 CHECK_BUFFER(2, recvbuf, count, datatype)
641 CHECK_OP(5, op, datatype)
642 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Exscan" : "PMPI_Iexscan") + " with op " +
645 const SmpiBenchGuard suspend_bench;
647 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
648 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
650 aid_t pid = simgrid::s4u::this_actor::get_pid();
651 std::vector<unsigned char> tmp_sendbuf;
652 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
654 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Exscan" : "PMPI_Iexscan",
655 new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "exscan" : "iexscan", -1, 0.0,
656 count, 0, simgrid::smpi::Datatype::encode(datatype), ""));
659 if (request == MPI_REQUEST_IGNORED)
660 retval = simgrid::smpi::colls::exscan(real_sendbuf, recvbuf, count, datatype, op, comm);
662 retval = simgrid::smpi::colls::iexscan(real_sendbuf, recvbuf, count, datatype, op, comm, request);
664 TRACE_smpi_comm_out(pid);
668 int PMPI_Reduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
670 return PMPI_Ireduce_scatter(sendbuf, recvbuf, recvcounts, datatype, op, comm, MPI_REQUEST_IGNORED);
673 int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcounts, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, MPI_Request *request)
678 int rank = comm->rank();
679 CHECK_NOT_IN_PLACE(2, recvbuf)
680 CHECK_TYPE(4, datatype)
681 CHECK_NULL(3, MPI_ERR_COUNT, recvcounts)
683 CHECK_OP(5, op, datatype)
684 for (int i = 0; i < comm->size(); i++) {
685 CHECK_COUNT(3, recvcounts[i])
686 CHECK_BUFFER(1, sendbuf, recvcounts[i], datatype)
687 CHECK_BUFFER(2, recvbuf, recvcounts[i], datatype)
689 CHECK_COLLECTIVE(comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter" : "PMPI_Ireduce_scatter") +
690 " with op " + op->name())
692 const SmpiBenchGuard suspend_bench;
694 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
695 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
697 aid_t pid = simgrid::s4u::this_actor::get_pid();
698 auto trace_recvcounts = std::make_shared<std::vector<int>>();
699 trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[comm->size()]);
703 for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
704 totalcount += recvcounts[i];
706 std::vector<unsigned char> tmp_sendbuf;
707 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, totalcount, datatype);
709 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter" : "PMPI_Ireduce_scatter",
710 new simgrid::instr::VarCollTIData(
711 request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, -1, nullptr,
712 -1 , trace_recvcounts, std::to_string(0), simgrid::smpi::Datatype::encode(datatype)));
714 if (request == MPI_REQUEST_IGNORED)
715 simgrid::smpi::colls::reduce_scatter(real_sendbuf, recvbuf, recvcounts, datatype, op, comm);
717 simgrid::smpi::colls::ireduce_scatter(real_sendbuf, recvbuf, recvcounts, datatype, op, comm, request);
719 TRACE_smpi_comm_out(pid);
723 int PMPI_Reduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount,
724 MPI_Datatype datatype, MPI_Op op, MPI_Comm comm)
726 return PMPI_Ireduce_scatter_block(sendbuf, recvbuf, recvcount, datatype, op, comm, MPI_REQUEST_IGNORED);
729 int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount, MPI_Datatype datatype, MPI_Op op,
730 MPI_Comm comm, MPI_Request* request)
735 CHECK_TYPE(4, datatype)
736 CHECK_COUNT(3, recvcount)
737 CHECK_BUFFER(1, sendbuf, recvcount, datatype)
738 CHECK_BUFFER(2, recvbuf, recvcount, datatype)
740 CHECK_OP(5, op, datatype)
742 comm, std::string(request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block" : "PMPI_Ireduce_scatter_block") +
743 " with op " + op->name())
745 const SmpiBenchGuard suspend_bench;
747 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
748 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
750 int count = comm->size();
752 aid_t pid = simgrid::s4u::this_actor::get_pid();
753 auto trace_recvcounts = std::make_shared<std::vector<int>>(recvcount);
755 std::vector<unsigned char> tmp_sendbuf;
756 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, recvcount * count, datatype);
759 pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block" : "PMPI_Ireduce_scatter_block",
760 new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, -1,
761 nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
763 std::vector<int> recvcounts(count);
764 for (int i = 0; i < count; i++)
765 recvcounts[i] = recvcount;
766 if (request == MPI_REQUEST_IGNORED)
767 simgrid::smpi::colls::reduce_scatter(real_sendbuf, recvbuf, recvcounts.data(), datatype, op, comm);
769 simgrid::smpi::colls::ireduce_scatter(real_sendbuf, recvbuf, recvcounts.data(), datatype, op, comm, request);
771 TRACE_smpi_comm_out(pid);
775 int PMPI_Alltoall(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
776 MPI_Datatype recvtype, MPI_Comm comm){
777 return PMPI_Ialltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm, MPI_REQUEST_IGNORED);
780 int PMPI_Ialltoall(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void* recvbuf, int recvcount,
781 MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
786 if(sendbuf != MPI_IN_PLACE){
787 CHECK_TYPE(3, sendtype)
788 CHECK_COUNT(2, sendcount)
789 CHECK_BUFFER(1, sendbuf, sendcount, sendtype)
791 CHECK_TYPE(6, recvtype)
792 CHECK_COUNT(5, recvcount)
793 CHECK_COUNT(5, recvcount)
794 CHECK_BUFFER(4, recvbuf, recvcount, recvtype)
796 CHECK_COLLECTIVE(comm, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoall" : "PMPI_Ialltoall")
798 aid_t pid = simgrid::s4u::this_actor::get_pid();
799 int real_sendcount = sendcount;
800 MPI_Datatype real_sendtype = sendtype;
802 std::vector<unsigned char> tmp_sendbuf;
803 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, recvcount * comm->size(), recvtype);
805 if (sendbuf == MPI_IN_PLACE) {
806 real_sendcount = recvcount;
807 real_sendtype = recvtype;
810 if(recvtype->size() * recvcount != real_sendtype->size() * real_sendcount){
811 XBT_WARN("MPI_(I)Alltoall : receive size from each process differs from sent size : %zu vs %zu", recvtype->size() * recvcount, real_sendtype->size() * real_sendcount);
812 return MPI_ERR_TRUNCATE;
815 const SmpiBenchGuard suspend_bench;
817 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
818 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
820 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoall" : "PMPI_Ialltoall",
821 new simgrid::instr::CollTIData(
822 request == MPI_REQUEST_IGNORED ? "alltoall" : "ialltoall", -1, -1.0,
823 real_sendcount, recvcount,
824 simgrid::smpi::Datatype::encode(real_sendtype), simgrid::smpi::Datatype::encode(recvtype)));
826 if (request == MPI_REQUEST_IGNORED)
828 simgrid::smpi::colls::alltoall(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcount, recvtype, comm);
830 retval = simgrid::smpi::colls::ialltoall(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcount, recvtype,
833 TRACE_smpi_comm_out(pid);
837 int PMPI_Alltoallv(const void* sendbuf, const int* sendcounts, const int* senddispls, MPI_Datatype sendtype, void* recvbuf,
838 const int* recvcounts, const int* recvdispls, MPI_Datatype recvtype, MPI_Comm comm)
840 return PMPI_Ialltoallv(sendbuf, sendcounts, senddispls, sendtype, recvbuf, recvcounts, recvdispls, recvtype, comm, MPI_REQUEST_IGNORED);
843 int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* senddispls, MPI_Datatype sendtype, void* recvbuf,
844 const int* recvcounts, const int* recvdispls, MPI_Datatype recvtype, MPI_Comm comm, MPI_Request* request)
849 if(sendbuf != MPI_IN_PLACE){
850 CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
851 CHECK_NULL(3, MPI_ERR_ARG, senddispls)
852 CHECK_TYPE(4, sendtype)
854 CHECK_TYPE(8, recvtype)
855 CHECK_NULL(6, MPI_ERR_COUNT, recvcounts)
856 CHECK_NULL(7, MPI_ERR_ARG, recvdispls)
858 CHECK_COLLECTIVE(comm, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoallv" : "PMPI_Ialltoallv")
860 aid_t pid = simgrid::s4u::this_actor::get_pid();
861 int size = comm->size();
862 for (int i = 0; i < size; i++) {
863 if(sendbuf != MPI_IN_PLACE){
864 CHECK_BUFFER(1, sendbuf, sendcounts[i], sendtype)
865 CHECK_COUNT(2, sendcounts[i])
867 CHECK_BUFFER(5, recvbuf, recvcounts[i], recvtype)
868 CHECK_COUNT(6, recvcounts[i])
871 const SmpiBenchGuard suspend_bench;
873 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
874 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
878 auto trace_sendcounts = std::make_shared<std::vector<int>>();
879 auto trace_recvcounts = std::make_shared<std::vector<int>>();
880 trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[size]);
882 int dt_size_recv = recvtype->size();
884 const int* real_sendcounts = sendcounts;
885 const int* real_senddispls = senddispls;
886 MPI_Datatype real_sendtype = sendtype;
888 std::vector<unsigned char> tmp_sendbuf;
889 std::vector<int> tmp_sendcounts;
890 std::vector<int> tmp_senddispls;
891 const void* real_sendbuf;
893 if (sendbuf == MPI_IN_PLACE) {
894 tmp_sendcounts.assign(recvcounts, recvcounts + size);
895 real_sendcounts = tmp_sendcounts.data();
896 tmp_senddispls.assign(recvdispls, recvdispls + size);
897 real_senddispls = tmp_senddispls.data();
898 real_sendtype = recvtype;
901 for (int i = 0; i < size; i++) { // copy data to avoid bad free
902 send_size += real_sendcounts[i] ;
903 recv_size += recvcounts[i];
904 if (((recvdispls[i] + recvcounts[i]) * dt_size_recv) > maxsize)
905 maxsize = (recvdispls[i] + recvcounts[i]) * dt_size_recv;
907 real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
909 if(recvtype->size() * recvcounts[comm->rank()] != real_sendtype->size() * real_sendcounts[comm->rank()]){
910 XBT_WARN("MPI_(I)Alltoallv : receive size from me differs from sent size to me : %zu vs %zu", recvtype->size() * recvcounts[comm->rank()], real_sendtype->size() * real_sendcounts[comm->rank()]);
911 return MPI_ERR_TRUNCATE;
914 trace_sendcounts->insert(trace_sendcounts->end(), &real_sendcounts[0], &real_sendcounts[size]);
916 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoallv" : "PMPI_Ialltoallv",
917 new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "alltoallv" : "ialltoallv", -1,
918 send_size, trace_sendcounts, recv_size, trace_recvcounts,
919 simgrid::smpi::Datatype::encode(real_sendtype),
920 simgrid::smpi::Datatype::encode(recvtype)));
923 if (request == MPI_REQUEST_IGNORED)
924 retval = simgrid::smpi::colls::alltoallv(real_sendbuf, real_sendcounts, real_senddispls, real_sendtype, recvbuf,
925 recvcounts, recvdispls, recvtype, comm);
927 retval = simgrid::smpi::colls::ialltoallv(real_sendbuf, real_sendcounts, real_senddispls, real_sendtype, recvbuf,
928 recvcounts, recvdispls, recvtype, comm, request);
930 TRACE_smpi_comm_out(pid);
934 int PMPI_Alltoallw(const void* sendbuf, const int* sendcounts, const int* senddispls, const MPI_Datatype* sendtypes, void* recvbuf,
935 const int* recvcounts, const int* recvdispls, const MPI_Datatype* recvtypes, MPI_Comm comm)
937 return PMPI_Ialltoallw(sendbuf, sendcounts, senddispls, sendtypes, recvbuf, recvcounts, recvdispls, recvtypes, comm, MPI_REQUEST_IGNORED);
940 int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* senddispls, const MPI_Datatype* sendtypes, void* recvbuf,
941 const int* recvcounts, const int* recvdispls, const MPI_Datatype* recvtypes, MPI_Comm comm, MPI_Request* request)
946 if(sendbuf != MPI_IN_PLACE){
947 CHECK_NULL(2, MPI_ERR_COUNT, sendcounts)
948 CHECK_NULL(3, MPI_ERR_ARG, senddispls)
949 CHECK_NULL(4, MPI_ERR_TYPE, sendtypes)
951 CHECK_NULL(6, MPI_ERR_COUNT, recvcounts)
952 CHECK_NULL(7, MPI_ERR_ARG, recvdispls)
953 CHECK_NULL(8, MPI_ERR_TYPE, recvtypes)
955 aid_t pid = simgrid::s4u::this_actor::get_pid();
956 int size = comm->size();
957 for (int i = 0; i < size; i++) {
958 if(sendbuf != MPI_IN_PLACE){
959 CHECK_COUNT(2, sendcounts[i])
960 CHECK_TYPE(4, sendtypes[i])
961 CHECK_BUFFER(1, sendbuf, sendcounts[i], sendtypes[i])
963 CHECK_COUNT(6, recvcounts[i])
964 CHECK_TYPE(8, recvtypes[i])
965 CHECK_BUFFER(5, recvbuf, recvcounts[i], recvtypes[i])
967 CHECK_COLLECTIVE(comm, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoallw" : "PMPI_Ialltoallw")
969 const SmpiBenchGuard suspend_bench;
971 if (simgrid::config::get_value<bool>("smpi/barrier-collectives"))
972 smpi_deployment_startup_barrier(smpi_process()->get_instance_id());
976 auto trace_sendcounts = std::make_shared<std::vector<int>>();
977 auto trace_recvcounts = std::make_shared<std::vector<int>>();
978 trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[size]);
980 const int* real_sendcounts = sendcounts;
981 const int* real_senddispls = senddispls;
982 const MPI_Datatype* real_sendtypes = sendtypes;
984 unsigned long maxsize = 0;
985 for (int i = 0; i < size; i++) { // copy data to avoid bad free
986 if (recvtypes[i] == MPI_DATATYPE_NULL)
988 recv_size += recvcounts[i] * recvtypes[i]->size();
989 if ((recvdispls[i] + (recvcounts[i] * recvtypes[i]->size())) > maxsize)
990 maxsize = recvdispls[i] + (recvcounts[i] * recvtypes[i]->size());
993 std::vector<unsigned char> tmp_sendbuf;
994 std::vector<int> tmp_sendcounts;
995 std::vector<int> tmp_senddispls;
996 std::vector<MPI_Datatype> tmp_sendtypes;
997 const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, maxsize, MPI_CHAR);
998 if (sendbuf == MPI_IN_PLACE) {
999 tmp_sendcounts.assign(recvcounts, recvcounts + size);
1000 real_sendcounts = tmp_sendcounts.data();
1001 tmp_senddispls.assign(recvdispls, recvdispls + size);
1002 real_senddispls = tmp_senddispls.data();
1003 tmp_sendtypes.assign(recvtypes, recvtypes + size);
1004 real_sendtypes = tmp_sendtypes.data();
1008 if(recvtypes[comm->rank()]->size() * recvcounts[comm->rank()] != real_sendtypes[comm->rank()]->size() * real_sendcounts[comm->rank()]){
1009 XBT_WARN("MPI_(I)Alltoallw : receive size from me differs from sent size to me : %zu vs %zu", recvtypes[comm->rank()]->size() * recvcounts[comm->rank()], real_sendtypes[comm->rank()]->size() * real_sendcounts[comm->rank()]);
1010 return MPI_ERR_TRUNCATE;
1013 trace_sendcounts->insert(trace_sendcounts->end(), &real_sendcounts[0], &real_sendcounts[size]);
1014 for (int i = 0; i < size; i++) { // copy data to avoid bad free
1015 send_size += real_sendcounts[i] * real_sendtypes[i]->size();
1018 TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Alltoallw" : "PMPI_Ialltoallw",
1019 new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "alltoallv" : "ialltoallv", -1,
1020 send_size, trace_sendcounts, recv_size, trace_recvcounts,
1021 simgrid::smpi::Datatype::encode(real_sendtypes[0]),
1022 simgrid::smpi::Datatype::encode(recvtypes[0])));
1025 if (request == MPI_REQUEST_IGNORED)
1026 retval = simgrid::smpi::colls::alltoallw(real_sendbuf, real_sendcounts, real_senddispls, real_sendtypes, recvbuf,
1027 recvcounts, recvdispls, recvtypes, comm);
1029 retval = simgrid::smpi::colls::ialltoallw(real_sendbuf, real_sendcounts, real_senddispls, real_sendtypes, recvbuf,
1030 recvcounts, recvdispls, recvtypes, comm, request);
1032 TRACE_smpi_comm_out(pid);