- int rank = request->comm() != MPI_COMM_NULL ? request->comm()->rank() : -1;
-
- MPI_Group group = request->comm()->group();
- int src_traced = group->rank(request->src());
- int dst_traced = group->rank(request->dst());
- int is_wait_for_receive = (request->flags() & RECV);
- TRACE_smpi_comm_in(rank, __FUNCTION__, new simgrid::instr::NoOpTIData("wait"));
-
- Request::wait(&request, &status);
-
- TRACE_smpi_comm_out(rank);
- if (is_wait_for_receive)
- TRACE_smpi_recv(src_traced, dst_traced, 0);
- log_timed_action (action, clock);
-}
-
-static void action_waitall(const char *const *action){
- CHECK_ACTION_PARAMS(action, 0, 0)
- double clock = smpi_process()->simulated_elapsed();
- const unsigned int count_requests = get_reqq_self()->size();
-
- if (count_requests>0) {
- MPI_Status status[count_requests];
-
- int my_proc_id_traced = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id_traced, __FUNCTION__,
- new simgrid::instr::Pt2PtTIData("waitAll", -1, count_requests, ""));
- int recvs_snd[count_requests];
- int recvs_rcv[count_requests];
- for (unsigned int i = 0; i < count_requests; i++) {
- const auto& req = (*get_reqq_self())[i];
- if (req && (req->flags() & RECV)) {
- recvs_snd[i] = req->src();
- recvs_rcv[i] = req->dst();
- } else
- recvs_snd[i] = -100;
- }
- Request::waitall(count_requests, &(*get_reqq_self())[0], status);
-
- for (unsigned i = 0; i < count_requests; i++) {
- if (recvs_snd[i]!=-100)
- TRACE_smpi_recv(recvs_snd[i], recvs_rcv[i],0);
- }
- TRACE_smpi_comm_out(my_proc_id_traced);
- }
- log_timed_action (action, clock);
-}
-
-static void action_barrier(const char *const *action){
- double clock = smpi_process()->simulated_elapsed();
- int my_proc_id = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::NoOpTIData("barrier"));
-
- Colls::barrier(MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}
-
-static void action_bcast(const char *const *action)
-{
- CHECK_ACTION_PARAMS(action, 1, 2)
- double size = parse_double(action[2]);
- double clock = smpi_process()->simulated_elapsed();
- int root = (action[3]) ? atoi(action[3]) : 0;
- /* Initialize MPI_CURRENT_TYPE in order to decrease the number of the checks */
- MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;
-
- MPI_CURRENT_TYPE = (action[3] && action[4]) ? decode_datatype(action[4]) : MPI_DEFAULT_TYPE;
-
- int my_proc_id = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::CollTIData("bcast", MPI_COMM_WORLD->group()->actor(root)->getPid(), -1.0, size,
- -1, encode_datatype(MPI_CURRENT_TYPE), ""));
-
- void *sendbuf = smpi_get_tmp_sendbuffer(size* MPI_CURRENT_TYPE->size());
-
- Colls::bcast(sendbuf, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}
-
-static void action_reduce(const char *const *action)
-{
- CHECK_ACTION_PARAMS(action, 2, 2)
- double comm_size = parse_double(action[2]);
- double comp_size = parse_double(action[3]);
- double clock = smpi_process()->simulated_elapsed();
- int root = (action[4]) ? atoi(action[4]) : 0;
-
- MPI_CURRENT_TYPE = (action[4] && action[5]) ? decode_datatype(action[5]) : MPI_DEFAULT_TYPE;
-
- int my_proc_id = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::CollTIData("reduce", MPI_COMM_WORLD->group()->actor(root)->getPid(), comp_size,
- comm_size, -1, encode_datatype(MPI_CURRENT_TYPE), ""));
-
- void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
- void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
- Colls::reduce(sendbuf, recvbuf, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD);
- smpi_execute_flops(comp_size);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}
-
-static void action_allReduce(const char *const *action) {
- CHECK_ACTION_PARAMS(action, 2, 1)
- double comm_size = parse_double(action[2]);
- double comp_size = parse_double(action[3]);
-
- MPI_CURRENT_TYPE = (action[4]) ? decode_datatype(action[4]) : MPI_DEFAULT_TYPE;
-
- double clock = smpi_process()->simulated_elapsed();
- int my_proc_id = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__, new simgrid::instr::CollTIData("allReduce", -1, comp_size, comm_size, -1,
- encode_datatype(MPI_CURRENT_TYPE), ""));
-
- void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
- void *sendbuf = smpi_get_tmp_sendbuffer(comm_size* MPI_CURRENT_TYPE->size());
- Colls::allreduce(sendbuf, recvbuf, comm_size, 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);
-}
-
-static void action_allToAll(const char *const *action) {
- CHECK_ACTION_PARAMS(action, 2, 2) //two mandatory (send and recv volumes) and two optional (corresponding datatypes)
- double clock = smpi_process()->simulated_elapsed();
- int comm_size = MPI_COMM_WORLD->size();
- int send_size = parse_double(action[2]);
- int recv_size = parse_double(action[3]);
- MPI_CURRENT_TYPE = (action[4] && action[5]) ? decode_datatype(action[4]) : MPI_DEFAULT_TYPE;
- MPI_Datatype MPI_CURRENT_TYPE2{(action[4] && action[5]) ? decode_datatype(action[5]) : MPI_DEFAULT_TYPE};
-
- void *send = smpi_get_tmp_sendbuffer(send_size*comm_size* MPI_CURRENT_TYPE->size());
- void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* MPI_CURRENT_TYPE2->size());
-
- int my_proc_id = Actor::self()->getPid();
- TRACE_smpi_comm_in(my_proc_id, __FUNCTION__,
- new simgrid::instr::CollTIData("allToAll", -1, -1.0, send_size, recv_size,
- encode_datatype(MPI_CURRENT_TYPE),
- encode_datatype(MPI_CURRENT_TYPE2)));
-
- Colls::alltoall(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
-
- TRACE_smpi_comm_out(my_proc_id);
- log_timed_action (action, clock);
-}
-
-static void action_gather(const char *const *action) {
- /* The structure of the gather action for the rank 0 (total 4 processes) is the following:
- 0 gather 68 68 0 0 0
- where:
- 1) 68 is the sendcounts
- 2) 68 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()
- */
- CHECK_ACTION_PARAMS(action, 2, 3)
- double clock = smpi_process()->simulated_elapsed();
- int comm_size = MPI_COMM_WORLD->size();
- int send_size = parse_double(action[2]);
- int recv_size = parse_double(action[3]);
- MPI_CURRENT_TYPE = (action[5] && action[6]) ? decode_datatype(action[5]) : MPI_DEFAULT_TYPE;
- MPI_Datatype MPI_CURRENT_TYPE2{(action[5] && action[6]) ? decode_datatype(action[6]) : MPI_DEFAULT_TYPE};
-
- void *send = smpi_get_tmp_sendbuffer(send_size* MPI_CURRENT_TYPE->size());
- void *recv = nullptr;
- int root = (action[4]) ? atoi(action[4]) : 0;
- 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::gather(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_scatter(const char* const* action)
-{
- /* The structure of the scatter action for the rank 0 (total 4 processes) is the following:
- 0 gather 68 68 0 0 0
- where:
- 1) 68 is the sendcounts
- 2) 68 is the recvcounts