Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / smpi / smpi_replay.c
index 23c57ce..c2002b5 100644 (file)
@@ -14,7 +14,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_replay,smpi,"Trace Replay with SMPI");
 
 int communicator_size = 0;
 static int active_processes = 0;
-xbt_dynar_t *reqq;
+xbt_dynar_t *reqq = NULL;
 
 MPI_Datatype MPI_DEFAULT_TYPE, MPI_CURRENT_TYPE;
 
@@ -95,10 +95,12 @@ static void action_init(const char *const *action)
   /*initialize the number of active processes */
   active_processes = smpi_process_count();
 
-  reqq=xbt_new0(xbt_dynar_t,active_processes);
+  if (!reqq) {
+    reqq=xbt_new0(xbt_dynar_t,active_processes);
   
-  for(i=0;i<active_processes;i++){
-    reqq[i]=xbt_dynar_new(sizeof(MPI_Request),NULL);
+    for(i=0;i<active_processes;i++){
+      reqq[i]=xbt_dynar_new(sizeof(MPI_Request),NULL);
+    }
   }
 }
 
@@ -450,7 +452,7 @@ static void action_reduce(const char *const *action)
   int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), 0);
   TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__);
 #endif
-   smpi_mpi_reduce(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD);
+   mpi_coll_reduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD);
    smpi_execute_flops(comp_size);
 #ifdef HAVE_TRACING
   TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__);
@@ -473,9 +475,9 @@ static void action_allReduce(const char *const *action) {
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
-  smpi_mpi_reduce(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, 0, MPI_COMM_WORLD);
+   mpi_coll_reduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, 0, MPI_COMM_WORLD);
   smpi_execute_flops(comp_size);
-  smpi_mpi_bcast(NULL, comm_size, MPI_CURRENT_TYPE, 0, MPI_COMM_WORLD);
+   mpi_coll_bcast_fun(NULL, comm_size, MPI_CURRENT_TYPE, 0, MPI_COMM_WORLD);
 #ifdef HAVE_TRACING
   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
   TRACE_smpi_computing_in(rank);
@@ -487,8 +489,8 @@ static void action_allReduce(const char *const *action) {
 static void action_allToAll(const char *const *action) {
   double clock = smpi_process_simulated_elapsed();
   int comm_size = smpi_comm_size(MPI_COMM_WORLD);
-  int send_size = atoi(action[2]);
-  int recv_size = atoi(action[3]);
+  int send_size = parse_double(action[2]);
+  int recv_size = parse_double(action[3]);
   void *send = xbt_new0(int, send_size*comm_size);  
   void *recv = xbt_new0(int, send_size*comm_size);
   
@@ -500,21 +502,8 @@ static void action_allToAll(const char *const *action) {
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
-
-  if (send_size < 200 && comm_size > 12) {
-    smpi_coll_tuned_alltoall_bruck(send, send_size, MPI_CURRENT_TYPE,
-                                   recv, recv_size, MPI_CURRENT_TYPE,
-                                   MPI_COMM_WORLD);
-  } else if (send_size < 3000) {
   
-    smpi_coll_tuned_alltoall_basic_linear(send, send_size, MPI_CURRENT_TYPE,
-                                          recv, recv_size, MPI_CURRENT_TYPE,
-                                          MPI_COMM_WORLD);
-  } else {
-    smpi_coll_tuned_alltoall_pairwise(send, send_size, MPI_CURRENT_TYPE,
-                                      recv, recv_size, MPI_CURRENT_TYPE,
-                                      MPI_COMM_WORLD);
-  }
+  mpi_coll_alltoall_fun(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE, MPI_COMM_WORLD);
 
 #ifdef HAVE_TRACING
   TRACE_smpi_collective_out(rank, -1, __FUNCTION__);
@@ -552,8 +541,8 @@ static void action_allToAllv(const char *const *action) {
   int *senddisps = xbt_new0(int, comm_size);  
   int *recvdisps = xbt_new0(int, comm_size);  
   
-  send_buf_size=atoi(action[2]);
-  recv_buf_size=atoi(action[3+2*comm_size]);
+  send_buf_size=parse_double(action[2]);
+  recv_buf_size=parse_double(action[3+2*comm_size]);
 
   int *sendbuf = xbt_new0(int, send_buf_size);  
   int *recvbuf = xbt_new0(int, recv_buf_size);  
@@ -574,7 +563,7 @@ static void action_allToAllv(const char *const *action) {
   TRACE_smpi_computing_out(rank);
   TRACE_smpi_collective_in(rank, -1, __FUNCTION__);
 #endif
-    smpi_coll_basic_alltoallv(sendbuf, sendcounts, senddisps,  MPI_CURRENT_TYPE,
+    mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps,     MPI_CURRENT_TYPE,
                                recvbuf, recvcounts, recvdisps, MPI_CURRENT_TYPE,
                                MPI_COMM_WORLD);
 #ifdef HAVE_TRACING
@@ -624,13 +613,17 @@ int smpi_replay_finalize(){
   double sim_time= 1.;
   /* One active process will stop. Decrease the counter*/
   active_processes--;
+  XBT_DEBUG("There are %lu elements in reqq[*]",
+            xbt_dynar_length(reqq[smpi_comm_rank(MPI_COMM_WORLD)]));
+  xbt_dynar_free(&reqq[smpi_comm_rank(MPI_COMM_WORLD)]);
   if(!active_processes){
     /* Last process alive speaking */
     /* end the simulated timer */
-    xbt_dynar_free(reqq);
     sim_time = smpi_process_simulated_elapsed();
     XBT_INFO("Simulation time %g", sim_time);
     _xbt_replay_action_exit();
+    xbt_free(reqq);
+    reqq = NULL;
   }
   return PMPI_Finalize();
 }