+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_REDUCE_SCATTER;
+ extra->send_size = 0;
+ extra->recvcounts= xbt_malloc(comm_size*sizeof(int));
+ for(i=0; i< comm_size; i++)//copy data to avoid bad free
+ extra->recvcounts[i] = recvcounts[i];
+ extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
+ extra->comp_size = comp_size;
+ extra->num_processes = comm_size;
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+
+ void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *recvbuf = smpi_get_tmp_recvbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE));
+
+ mpi_coll_reduce_scatter_fun(sendbuf, recvbuf, recvcounts, MPI_CURRENT_TYPE, MPI_OP_NULL,
+ MPI_COMM_WORLD);
+ smpi_execute_flops(comp_size);
+
+
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ xbt_free(recvcounts);
+ xbt_free(disps);
+ log_timed_action (action, clock);
+}
+
+static void action_allgather(const char *const *action) {
+ /*
+ The structure of the allgather action for the rank 0 (total 4 processes)
+ is the following:
+ 0 allGather 275427 275427
+
+ where:
+ 1) 275427 is the sendcount
+ 2) 275427 is the recvcount
+ 3) No more values mean that the datatype for sent and receive buffer
+ is the default one, see decode_datatype().
+
+ */
+
+ double clock = smpi_process_simulated_elapsed();
+
+ CHECK_ACTION_PARAMS(action, 2, 2);
+ int sendcount=atoi(action[2]);
+ int recvcount=atoi(action[3]);
+
+ MPI_Datatype MPI_CURRENT_TYPE2;
+
+ if(action[4]) {
+ MPI_CURRENT_TYPE = decode_datatype(action[3]);
+ MPI_CURRENT_TYPE2 = decode_datatype(action[4]);
+ } else {
+ MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
+ MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;
+ }
+ void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *recvbuf = smpi_get_tmp_recvbuffer(recvcount* smpi_datatype_size(MPI_CURRENT_TYPE2));
+
+ int rank = smpi_process_index();
+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_ALLGATHER;
+ extra->send_size = sendcount;
+ extra->recv_size= recvcount;
+ extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
+ extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL);
+ extra->num_processes = smpi_comm_size(MPI_COMM_WORLD);
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+
+ mpi_coll_allgather_fun(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcount, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
+
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ log_timed_action (action, clock);
+}
+
+static void action_allgatherv(const char *const *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 decode_datatype().
+
+ */
+
+ double clock = smpi_process_simulated_elapsed();
+
+ int comm_size = smpi_comm_size(MPI_COMM_WORLD);
+ CHECK_ACTION_PARAMS(action, comm_size+1, 2);
+ int i=0;
+ int sendcount=atoi(action[2]);
+ int *recvcounts = xbt_new0(int, comm_size);
+ int *disps = xbt_new0(int, comm_size);
+ int recv_sum=0;
+ MPI_Datatype MPI_CURRENT_TYPE2;
+
+ if(action[3+comm_size]) {
+ MPI_CURRENT_TYPE = decode_datatype(action[3+comm_size]);
+ MPI_CURRENT_TYPE2 = decode_datatype(action[4+comm_size]);
+ } else {
+ MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
+ MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;
+ }
+ void *sendbuf = smpi_get_tmp_sendbuffer(sendcount* smpi_datatype_size(MPI_CURRENT_TYPE));
+
+ for(i=0;i<comm_size;i++) {
+ recvcounts[i] = atoi(action[i+3]);
+ recv_sum=recv_sum+recvcounts[i];
+ }
+ void *recvbuf = smpi_get_tmp_recvbuffer(recv_sum* smpi_datatype_size(MPI_CURRENT_TYPE2));
+
+ int rank = smpi_process_index();
+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_ALLGATHERV;
+ extra->send_size = sendcount;
+ extra->recvcounts= xbt_malloc(comm_size*sizeof(int));
+ for(i=0; i< comm_size; i++)//copy data to avoid bad free
+ extra->recvcounts[i] = recvcounts[i];
+ extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
+ extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL);
+ extra->num_processes = comm_size;
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+
+ mpi_coll_allgatherv_fun(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts, disps, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
+
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ log_timed_action (action, clock);
+ xbt_free(recvcounts);
+ xbt_free(disps);
+}
+
+static void action_allToAllv(const char *const *action) {
+ /*
+ The structure of the allToAllV action for the rank 0 (total 4 processes)
+ is the following:
+ 0 allToAllV 100 1 7 10 12 100 1 70 10 5
+
+ where:
+ 1) 100 is the size of the send buffer *sizeof(int),
+ 2) 1 7 10 12 is the sendcounts array
+ 3) 100*sizeof(int) is the size of the receiver buffer
+ 4) 1 70 10 5 is the recvcounts array
+
+ */
+
+
+ double clock = smpi_process_simulated_elapsed();
+
+ int comm_size = smpi_comm_size(MPI_COMM_WORLD);
+ CHECK_ACTION_PARAMS(action, 2*comm_size+2, 2);
+ int send_buf_size=0,recv_buf_size=0,i=0;
+ int *sendcounts = xbt_new0(int, comm_size);
+ int *recvcounts = xbt_new0(int, comm_size);
+ int *senddisps = xbt_new0(int, comm_size);
+ int *recvdisps = xbt_new0(int, comm_size);
+
+ MPI_Datatype MPI_CURRENT_TYPE2;
+
+ send_buf_size=parse_double(action[2]);
+ recv_buf_size=parse_double(action[3+comm_size]);
+ if(action[4+2*comm_size]) {
+ MPI_CURRENT_TYPE=decode_datatype(action[4+2*comm_size]);
+ MPI_CURRENT_TYPE2=decode_datatype(action[5+2*comm_size]);
+ }
+ else {
+ MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
+ MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE;
+ }
+
+ void *sendbuf = smpi_get_tmp_sendbuffer(send_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE));
+ void *recvbuf = smpi_get_tmp_recvbuffer(recv_buf_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
+
+ for(i=0;i<comm_size;i++) {
+ sendcounts[i] = atoi(action[i+3]);
+ recvcounts[i] = atoi(action[i+4+comm_size]);
+ }
+
+
+ int rank = smpi_process_index();
+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_ALLTOALLV;
+ extra->recvcounts= xbt_malloc(comm_size*sizeof(int));
+ extra->sendcounts= xbt_malloc(comm_size*sizeof(int));
+ extra->num_processes = comm_size;
+
+ for(i=0; i< comm_size; i++){//copy data to avoid bad free
+ extra->send_size += sendcounts[i];
+ extra->sendcounts[i] = sendcounts[i];
+ extra->recv_size += recvcounts[i];
+ extra->recvcounts[i] = recvcounts[i];
+ }
+ extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
+ extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL);
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+
+ mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, MPI_CURRENT_TYPE,
+ recvbuf, recvcounts, recvdisps, MPI_CURRENT_TYPE,
+ MPI_COMM_WORLD);
+
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+ log_timed_action (action, clock);
+ xbt_free(sendcounts);
+ xbt_free(recvcounts);
+ xbt_free(senddisps);
+ xbt_free(recvdisps);
+}
+
+void smpi_replay_init(int *argc, char***argv){
+ smpi_process_init(argc, argv);
+ smpi_process_mark_as_initialized();
+ smpi_process_set_replaying(1);
+
+ int rank = smpi_process_index();
+ TRACE_smpi_init(rank);
+ TRACE_smpi_computing_init(rank);
+ instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+ extra->type = TRACING_INIT;
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra);
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+
+ if (!_xbt_replay_action_init()) {
+ xbt_replay_action_register("init", action_init);
+ xbt_replay_action_register("finalize", action_finalize);
+ xbt_replay_action_register("comm_size", action_comm_size);
+ xbt_replay_action_register("comm_split", action_comm_split);
+ xbt_replay_action_register("comm_dup", action_comm_dup);
+ xbt_replay_action_register("send", action_send);
+ xbt_replay_action_register("Isend", action_Isend);
+ xbt_replay_action_register("recv", action_recv);
+ xbt_replay_action_register("Irecv", action_Irecv);
+ xbt_replay_action_register("test", action_test);
+ xbt_replay_action_register("wait", action_wait);
+ xbt_replay_action_register("waitAll", action_waitall);
+ xbt_replay_action_register("barrier", action_barrier);
+ xbt_replay_action_register("bcast", action_bcast);
+ xbt_replay_action_register("reduce", action_reduce);
+ xbt_replay_action_register("allReduce", action_allReduce);
+ xbt_replay_action_register("allToAll", action_allToAll);
+ xbt_replay_action_register("allToAllV", action_allToAllv);
+ xbt_replay_action_register("gather", action_gather);
+ xbt_replay_action_register("gatherV", action_gatherv);
+ xbt_replay_action_register("allGather", action_allgather);
+ xbt_replay_action_register("allGatherV", action_allgatherv);
+ xbt_replay_action_register("reduceScatter", action_reducescatter);
+ xbt_replay_action_register("compute", action_compute);
+ }
+
+ //if we have a delayed start, sleep here.
+ if(*argc>2){
+ char *endptr;
+ double value = strtod((*argv)[2], &endptr);
+ if (*endptr != '\0')
+ THROWF(unknown_error, 0, "%s is not a double", (*argv)[2]);
+ XBT_VERB("Delayed start for instance - Sleeping for %f flops ",value );
+ smpi_execute_flops(value);
+ } else {
+ //UGLY done to force context switch to be sure that all MSG_processes begin initialization
+ XBT_DEBUG("Force context switch by smpi_execute_flops - Sleeping for 0.0 flops ");
+ smpi_execute_flops(0.0);
+ }
+