+#ifdef HAVE_TRACING
+ 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);
+ extra->comp_size = comp_size;
+ extra->num_processes = comm_size;
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+#endif
+ 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);
+
+
+#ifdef HAVE_TRACING
+ TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
+#endif
+ xbt_free(recvcounts);
+ xbt_free(disps);
+ 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);
+ 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));
+
+#ifdef HAVE_TRACING
+ 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);
+ extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2);
+ extra->num_processes = comm_size;
+
+ TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra);
+#endif
+
+ mpi_coll_allgatherv_fun(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts, disps, MPI_CURRENT_TYPE2, MPI_COMM_WORLD);
+