Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix: every state should also save a copy of the communication action associated...
[simgrid.git] / src / mc / mc_request.c
index 6ee8336..97617a8 100644 (file)
@@ -2,10 +2,7 @@
 
 int MC_request_depend(smx_req_t r1, smx_req_t r2)
 {
-    if (r1->issuer == r2->issuer)
-    return FALSE;
-
-  if (r1->call != r2->call)
+  if (r1->issuer == r2->issuer)
     return FALSE;
 
   if (r1->call == REQ_COMM_ISEND && r2->call == REQ_COMM_ISEND
@@ -30,6 +27,26 @@ int MC_request_depend(smx_req_t r1, smx_req_t r2)
       && r2->comm_wait.comm->comm.dst_buff != r1->comm_wait.comm->comm.src_buff)
     return FALSE;
 
+  if(r1->call == REQ_COMM_TEST &&
+      (r1->comm_test.comm == NULL
+       || r1->comm_test.comm->comm.src_buff == NULL
+       || r1->comm_test.comm->comm.dst_buff == NULL))
+    return FALSE;
+
+  if(r2->call == REQ_COMM_TEST &&
+      (r2->comm_test.comm == NULL
+       || r2->comm_test.comm->comm.src_buff == NULL
+       || r2->comm_test.comm->comm.dst_buff == NULL))
+    return FALSE;
+
+  if (r1->call == REQ_COMM_TEST && r2->call == REQ_COMM_WAIT
+      && r1->comm_test.comm == r2->comm_wait.comm)
+    return FALSE;
+
+  if (r1->call == REQ_COMM_WAIT && r2->call == REQ_COMM_TEST
+      && r1->comm_wait.comm == r2->comm_test.comm)
+    return FALSE;
+
   return TRUE;
 }
 
@@ -67,11 +84,38 @@ char *MC_request_to_string(smx_req_t req)
                       act->comm.src_proc ? act->comm.src_proc->name : "",
                       act->comm.dst_proc ? act->comm.dst_proc->name : "");
       break;
+
+    case REQ_COMM_WAITANY:
+      type = bprintf("WaitAny");
+      args = bprintf("-");
+      /* FIXME: improve output */
+      break;
+
+    case REQ_COMM_TESTANY:
+       type = bprintf("TestAny");
+       args = bprintf("-");
+       /* FIXME: improve output */
+       break;
+
     default:
       THROW_UNIMPLEMENTED;
   }
+
   str = bprintf("[(%lu)%s] %s (%s)", req->issuer->pid ,req->issuer->name, type, args);
   xbt_free(type);
   xbt_free(args);
   return str;
 }
+
+unsigned int MC_request_testany_fail(smx_req_t req)
+{
+  unsigned int cursor;
+  smx_action_t action;
+
+  xbt_dynar_foreach(req->comm_testany.comms, cursor, action){
+    if(action->comm.src_proc && action->comm.dst_proc)
+      return FALSE;
+  }
+
+  return TRUE;
+}