+static void action_scatterv(const char* const* action)
+{
+ /* The structure of the scatterv action for the rank 0 (total 4 processes) is the following:
+ 0 gather 68 10 10 10 68 0 0 0
+ where:
+ 1) 68 10 10 10 is the sendcounts
+ 2) 68 is the recvcount
+ 3) 0 is the root node
+ 4) 0 is the send datatype id, see decode_datatype()
+ 5) 0 is the recv datatype id, see decode_datatype()
+ */
+ double clock = smpi_process()->simulated_elapsed();
+ int comm_size = MPI_COMM_WORLD->size();
+ CHECK_ACTION_PARAMS(action, comm_size + 1, 2)
+ int recv_size = parse_double(action[2 + comm_size]);
+ int disps[comm_size];
+ int sendcounts[comm_size];
+ int send_sum = 0;
+
+ MPI_Datatype MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;
+ if (action[4 + comm_size] && action[5 + comm_size]) {
+ MPI_CURRENT_TYPE = decode_datatype(action[4 + comm_size]);
+ MPI_CURRENT_TYPE2 = decode_datatype(action[5 + comm_size]);
+ } else
+ MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
+
+ void* send = nullptr;
+ void* recv = smpi_get_tmp_recvbuffer(recv_size * MPI_CURRENT_TYPE->size());
+ for (int i = 0; i < comm_size; i++) {
+ sendcounts[i] = atoi(action[i + 2]);
+ send_sum += sendcounts[i];
+ disps[i] = 0;
+ }
+
+ int root = atoi(action[3 + comm_size]);
+ int rank = MPI_COMM_WORLD->rank();
+
+ if (rank == root)
+ send = smpi_get_tmp_sendbuffer(send_sum * MPI_CURRENT_TYPE2->size());
+
+ std::vector<int>* trace_sendcounts = new std::vector<int>;
+ for (int i = 0; i < comm_size; i++) // copy data to avoid bad free
+ trace_sendcounts->push_back(sendcounts[i]);
+
+ TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
+ "gatherV", root, -1, trace_sendcounts, recv_size, nullptr,
+ encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
+
+ Colls::scatterv(send, sendcounts, disps, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
+
+ TRACE_smpi_comm_out(smpi_process()->index());
+ log_timed_action(action, clock);
+}
+