Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
sed -i -e 's/\t/ /g' [sources] Please people, stop using tabs
[simgrid.git] / src / smpi / smpi_replay.c
index ef4cc43..f1f5caa 100644 (file)
@@ -60,7 +60,7 @@ static void set_reqq_self(xbt_dynar_t mpi_request){
 //allocate a single buffer for all sends, growing it if needed
 void* smpi_get_tmp_sendbuffer(int size){
   if (!smpi_process_get_replaying())
-       return xbt_malloc(size);
+  return xbt_malloc(size);
   if (sendbuffer_size<size){
     sendbuffer=xbt_realloc(sendbuffer,size);
     sendbuffer_size=size;
@@ -70,7 +70,7 @@ void* smpi_get_tmp_sendbuffer(int size){
 //allocate a single buffer for all recv
 void* smpi_get_tmp_recvbuffer(int size){
   if (!smpi_process_get_replaying())
-       return xbt_malloc(size);
+  return xbt_malloc(size);
   if (recvbuffer_size<size){
     recvbuffer=xbt_realloc(recvbuffer,size);
     recvbuffer_size=size;
@@ -393,20 +393,20 @@ static void action_test(const char *const *action){
   //Different times in traced application and replayed version may lead to this 
   //In this case, ignore the extra calls.
   if(request){
-         int rank = smpi_process_index();
-         instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
-         extra->type=TRACING_TEST;
-         TRACE_smpi_testing_in(rank, extra);
+    int rank = smpi_process_index();
+    instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
+    extra->type=TRACING_TEST;
+    TRACE_smpi_testing_in(rank, extra);
 
-         flag = smpi_mpi_test(&request, &status);
+    flag = smpi_mpi_test(&request, &status);
 
-         XBT_DEBUG("MPI_Test result: %d", flag);
-         /* push back request in dynar to be caught by a subsequent wait. if the test
-          * did succeed, the request is now NULL.
-          */
-         xbt_dynar_push_as(get_reqq_self(),MPI_Request, request);
+    XBT_DEBUG("MPI_Test result: %d", flag);
+    /* push back request in dynar to be caught by a subsequent wait. if the test
+     * did succeed, the request is now NULL.
+     */
+    xbt_dynar_push_as(get_reqq_self(),MPI_Request, request);
 
-         TRACE_smpi_testing_out(rank);
+    TRACE_smpi_testing_out(rank);
   }
   log_timed_action (action, clock);
 }
@@ -636,20 +636,23 @@ static void action_allReduce(const char *const *action) {
 }
 
 static void action_allToAll(const char *const *action) {
+  CHECK_ACTION_PARAMS(action, 2, 2); //two mandatory (send and recv volumes)
+                                     //two optional (corresponding datatypes)
   double clock = smpi_process_simulated_elapsed();
   int comm_size = smpi_comm_size(MPI_COMM_WORLD);
   int send_size = parse_double(action[2]);
   int recv_size = parse_double(action[3]);
   MPI_Datatype MPI_CURRENT_TYPE2;
 
-  if(action[4]) {
+  if(action[4] && action[5]) {
     MPI_CURRENT_TYPE=decode_datatype(action[4]);
     MPI_CURRENT_TYPE2=decode_datatype(action[5]);
   }
-  else {
+  else{
     MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
     MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE;
   }
+
   void *send = smpi_get_tmp_sendbuffer(send_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE));
   void *recv = smpi_get_tmp_recvbuffer(recv_size*comm_size* smpi_datatype_size(MPI_CURRENT_TYPE2));
 
@@ -749,7 +752,7 @@ static void action_gatherv(const char *const *action) {
   int i=0,recv_sum=0;
 
   MPI_Datatype MPI_CURRENT_TYPE2;
-  if(action[4+comm_size]) {
+  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 {
@@ -877,9 +880,9 @@ static void action_allgather(const char *const *action) {
 
   MPI_Datatype MPI_CURRENT_TYPE2;
 
-  if(action[4]) {
-    MPI_CURRENT_TYPE = decode_datatype(action[3]);
-    MPI_CURRENT_TYPE2 = decode_datatype(action[4]);
+  if(action[4] && action[5]) {
+    MPI_CURRENT_TYPE = decode_datatype(action[4]);
+    MPI_CURRENT_TYPE2 = decode_datatype(action[5]);
   } else {
     MPI_CURRENT_TYPE = MPI_DEFAULT_TYPE;
     MPI_CURRENT_TYPE2 = MPI_DEFAULT_TYPE;    
@@ -930,7 +933,7 @@ static void action_allgatherv(const char *const *action) {
   int recv_sum=0;  
   MPI_Datatype MPI_CURRENT_TYPE2;
 
-  if(action[3+comm_size]) {
+  if(action[3+comm_size] && action[4+comm_size]) {
     MPI_CURRENT_TYPE = decode_datatype(action[3+comm_size]);
     MPI_CURRENT_TYPE2 = decode_datatype(action[4+comm_size]);
   } else {
@@ -995,13 +998,13 @@ static void action_allToAllv(const char *const *action) {
 
   send_buf_size=parse_double(action[2]);
   recv_buf_size=parse_double(action[3+comm_size]);
-  if(action[4+2*comm_size]) {
+  if(action[4+2*comm_size] && action[5+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;
+  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));