-static void action_allgatherv(simgrid::xbt::ReplayAction& action)
-{
- /* The structure of the allgatherv action for the rank 0 (total 4 processes) is the following:
- 0 allGatherV 275427 275427 275427 275427 204020
- where:
- 1) 275427 is the sendcount
- 2) The next four elements declare the recvcounts array
- 3) No more values mean that the datatype for sent and receive buffer is the default one, see
- simgrid::smpi::Datatype::decode().
- */
- double clock = smpi_process()->simulated_elapsed();
-
- unsigned long comm_size = MPI_COMM_WORLD->size();
- CHECK_ACTION_PARAMS(action, comm_size+1, 2)
- int sendcount = std::stoi(action[2]);
- std::shared_ptr<std::vector<int>> recvcounts(new std::vector<int>(comm_size));
- std::vector<int> disps(comm_size, 0);
-
- int datatype_index = 0, disp_index = 0;
- if (action.size() > 3 + 2 * comm_size) { /* datatype + disp are specified */
- datatype_index = 3 + comm_size;
- disp_index = datatype_index + 1;
- } else if (action.size() > 3 + 2 * comm_size) { /* disps specified; datatype is not specified; use the default one */
- datatype_index = -1;
- disp_index = 3 + comm_size;
- } else if (action.size() > 3 + comm_size) { /* only datatype, no disp specified */
- datatype_index = 3 + comm_size;
- }
-
- if (disp_index != 0) {
- for (unsigned int i = 0; i < comm_size; i++)
- disps[i] = std::stoi(action[disp_index + i]);
- }
-
- MPI_Datatype MPI_CURRENT_TYPE{(datatype_index > 0) ? simgrid::smpi::Datatype::decode(action[datatype_index])
- : MPI_DEFAULT_TYPE};
- MPI_Datatype MPI_CURRENT_TYPE2{(datatype_index > 0) ? simgrid::smpi::Datatype::decode(action[datatype_index])
- : MPI_DEFAULT_TYPE};
-
- void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* MPI_CURRENT_TYPE->size());
-
- for (unsigned int i = 0; i < comm_size; i++) {
- (*recvcounts)[i] = std::stoi(action[i + 3]);
- }
- int recv_sum = std::accumulate(recvcounts->begin(), recvcounts->end(), 0);
- void *recvbuf = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
-
- int my_proc_id = Actor::self()->getPid();
-
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::VarCollTIData("allGatherV", -1, sendcount, nullptr, -1, recvcounts,
- Datatype::encode(MPI_CURRENT_TYPE),
- Datatype::encode(MPI_CURRENT_TYPE2)));
-
- Colls::allgatherv(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts->data(), disps.data(), MPI_CURRENT_TYPE2,
- MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}
-