Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Try to DRY in MC main loops
[simgrid.git] / src / mc / mc_comm_determinism.c
index ff04989..5deb972 100644 (file)
@@ -84,28 +84,28 @@ static void deterministic_pattern(xbt_dynar_t pattern, int partial)
     nb_comms2 = xbt_dynar_length(process_comms_pattern2);
     if(!xbt_dynar_is_empty((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, current_process, xbt_dynar_t)))
       xbt_die("Damn ! Some communications from the process %u are incomplete (%lu)! That means one or several simcalls are not handle.", current_process, xbt_dynar_length((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, current_process, xbt_dynar_t)));
-    if (partial && (nb_comms1 != nb_comms2)) {
+    if (!partial && (nb_comms1 != nb_comms2)) {
       XBT_INFO("The total number of communications is different between the compared patterns for the process %u.\n Communication determinism verification for this process cannot be performed.", current_process);
       initial_global_state->send_deterministic = -1;
       initial_global_state->comm_deterministic = -1;
     } else {
       while (cursor < nb_comms2) {
         comm1 = (mc_comm_pattern_t)xbt_dynar_get_as(process_comms_pattern1, cursor, mc_comm_pattern_t);
-        if (comm1->type == SIMIX_COMM_SEND && comm1->src_proc == current_process) {
+        if (comm1->type == SIMIX_COMM_SEND) {
           comm2 = get_comm_pattern_from_idx(process_comms_pattern2, &send_index, comm1->type, current_process);
           if (compare_comm_pattern(comm1, comm2)) {
-            XBT_INFO("The communications pattern of the process %u is different!", current_process);
+            XBT_INFO("The communications pattern of the process %u is different! (Different communication : %u)", current_process, cursor+1);
             initial_global_state->send_deterministic = 0;
             initial_global_state->comm_deterministic = 0;
             return;
           }
           send_index++;
-        } else if (comm1->type == SIMIX_COMM_RECEIVE && comm1->dst_proc == current_process) {
+        } else if (comm1->type == SIMIX_COMM_RECEIVE) {
           comm2 = get_comm_pattern_from_idx(process_comms_pattern2, &recv_index, comm1->type, current_process);
           if (compare_comm_pattern(comm1, comm2)) {
             initial_global_state->comm_deterministic = 0;
             if (!_sg_mc_send_determinism){
-              XBT_INFO("The communications pattern of the process %u is different!", current_process);
+              XBT_INFO("The communications pattern of the process %u is different! (Different communication : %u)", current_process, cursor+1);
               return;
             }
           }
@@ -159,7 +159,7 @@ static void update_comm_pattern(mc_comm_pattern_t comm_pattern, smx_action_t com
     comm_pattern->data_size = *(comm->comm.dst_buff_size);
     comm_pattern->data = xbt_malloc0(comm_pattern->data_size);
     addr_pointed = *(void **) comm->comm.src_buff;
-    if (addr_pointed > std_heap && addr_pointed < ((xbt_mheap_t) std_heap)->breakval)
+    if (addr_pointed > (void*) std_heap && addr_pointed < std_heap->breakval)
       memcpy(comm_pattern->data, addr_pointed, comm_pattern->data_size);
     else
       memcpy(comm_pattern->data, comm->comm.src_buff, comm_pattern->data_size);
@@ -183,8 +183,7 @@ void get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, int call)
     pattern->data_size = pattern->comm->comm.src_buff_size;
     pattern->data = xbt_malloc0(pattern->data_size);
     addr_pointed = *(void **) pattern->comm->comm.src_buff;
-    if (addr_pointed > std_heap
-        && addr_pointed < ((xbt_mheap_t) std_heap)->breakval)
+    if (addr_pointed > (void*) std_heap && addr_pointed < std_heap->breakval)
       memcpy(pattern->data, addr_pointed, pattern->data_size);
     else
       memcpy(pattern->data, pattern->comm->comm.src_buff, pattern->data_size);
@@ -338,17 +337,13 @@ void MC_modelcheck_comm_determinism(void)
         && (req = MC_state_get_request(state, &value))
         && (visited_state == NULL)) {
 
-      /* Debug information */
-      if (XBT_LOG_ISENABLED(mc_comm_determinism, xbt_log_priority_debug)) {
-        req_str = MC_request_to_string(req, value);
-        XBT_DEBUG("Execute: %s", req_str);
-        xbt_free(req_str);
-      }
+      MC_LOG_REQUEST(mc_comm_determinism, req, value);
 
-      MC_SET_MC_HEAP;
-      if (dot_output != NULL)
+      if (dot_output != NULL) {
+        MC_SET_MC_HEAP;
         req_str = MC_request_get_dot_output(req, value);
-      MC_SET_STD_HEAP;
+        MC_SET_STD_HEAP;
+      }
 
       MC_state_set_executed_request(state, req, value);
       mc_stats->executed_transitions++;
@@ -366,7 +361,7 @@ void MC_modelcheck_comm_determinism(void)
       }
 
       /* Answer the request */
-      SIMIX_simcall_pre(req, value);    /* After this call req is no longer usefull */
+      SIMIX_simcall_enter(req, value);    /* After this call req is no longer usefull */
 
       MC_SET_MC_HEAP;
       current_pattern = !initial_global_state->initial_communications_pattern_done ? initial_communications_pattern : communications_pattern;