- void* send = smpi_get_tmp_sendbuffer(send_size * MPI_CURRENT_TYPE->size());
- void* recv = nullptr;
- int root = 0;
- if (action[4])
- root = atoi(action[4]);
- int rank = MPI_COMM_WORLD->rank();
-
- if (rank == root)
- recv = smpi_get_tmp_recvbuffer(recv_size * comm_size * MPI_CURRENT_TYPE2->size());
-
- TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::CollTIData("gather", root, -1.0, send_size, recv_size,
- encode_datatype(MPI_CURRENT_TYPE),
- encode_datatype(MPI_CURRENT_TYPE2)));
-
- Colls::scatter(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(Actor::self()->getPid());
- log_timed_action(action, clock);
-}
-
-static void action_gatherv(const char *const *action) {
- /* The structure of the gatherv action for the rank 0 (total 4 processes) is the following:
- 0 gather 68 68 10 10 10 0 0 0
- where:
- 1) 68 is the sendcount
- 2) 68 10 10 10 is the recvcounts
- 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 send_size = parse_double(action[2]);
- int disps[comm_size];
- int recvcounts[comm_size];
- int recv_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 = smpi_get_tmp_sendbuffer(send_size* MPI_CURRENT_TYPE->size());
- void *recv = nullptr;
- for(int i=0;i<comm_size;i++) {
- recvcounts[i] = atoi(action[i+3]);
- recv_sum=recv_sum+recvcounts[i];
- disps[i]=0;
- }
-
- int root=atoi(action[3+comm_size]);
- int rank = MPI_COMM_WORLD->rank();
-
- if(rank==root)
- recv = smpi_get_tmp_recvbuffer(recv_sum* MPI_CURRENT_TYPE2->size());
-
- std::vector<int>* trace_recvcounts = new std::vector<int>;
- for (int i = 0; i < comm_size; i++) // copy data to avoid bad free
- trace_recvcounts->push_back(recvcounts[i]);
-
- TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::VarCollTIData(
- "gatherV", root, send_size, nullptr, -1, trace_recvcounts,
- encode_datatype(MPI_CURRENT_TYPE), encode_datatype(MPI_CURRENT_TYPE2)));
-
- Colls::gatherv(send, send_size, MPI_CURRENT_TYPE, recv, recvcounts, disps, MPI_CURRENT_TYPE2, root, MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(Actor::self()->getPid());
- log_timed_action (action, clock);
-}
-
-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(Actor::self()->getPid());
- log_timed_action(action, clock);
-}
-
-static void action_reducescatter(const char *const *action) {
- /* The structure of the reducescatter action for the rank 0 (total 4 processes) is the following:
- 0 reduceScatter 275427 275427 275427 204020 11346849 0
- where:
- 1) The first four values after the name of the action declare the recvcounts array
- 2) The value 11346849 is the amount of instructions
- 3) The last value corresponds to the datatype, see decode_datatype().
-*/
- double clock = smpi_process()->simulated_elapsed();
- int comm_size = MPI_COMM_WORLD->size();
- CHECK_ACTION_PARAMS(action, comm_size+1, 1)
- int comp_size = parse_double(action[2+comm_size]);
- int recvcounts[comm_size];
- int my_proc_id = Actor::self()->getPid();
- int size = 0;
- std::vector<int>* trace_recvcounts = new std::vector<int>;
- if(action[3+comm_size])
- MPI_CURRENT_TYPE=decode_datatype(action[3+comm_size]);
- else
- MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
-
- for(int i=0;i<comm_size;i++) {
- recvcounts[i] = atoi(action[i+2]);
- trace_recvcounts->push_back(recvcounts[i]);
- size+=recvcounts[i];
- }
-
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::VarCollTIData("reduceScatter", -1, 0, nullptr, -1, trace_recvcounts,
- std::to_string(comp_size), /* ugly hack to print comp_size */
- encode_datatype(MPI_CURRENT_TYPE)));
-
- void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
- void *recvbuf = smpi_get_tmp_recvbuffer(size* MPI_CURRENT_TYPE->size());
-
- Colls::reduce_scatter(sendbuf, recvbuf, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL, MPI_COMM_WORLD);
- smpi_execute_flops(comp_size);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}