Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : Add statistics about comparison times for each pair reached:
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Mon, 12 Nov 2012 16:20:41 +0000 (17:20 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Mon, 12 Nov 2012 16:35:23 +0000 (17:35 +0100)
- if debug log enabled for mc_compare:
  - number of comparisons done with this pair
  - for each comparison step : number of different states, comparison times (average, max, min)
- otherwise
  - number of comparisons done with this pair
  - snapshot comparison times (stopped when the first difference is detected)

src/mc/mc_compare.c
src/mc/mc_global.c
src/mc/mc_liveness.c
src/mc/mc_private.h
src/simix/smx_smurf.c

index aec9b8c..ebc91f9 100644 (file)
@@ -163,7 +163,7 @@ void heap_equality_free_voidp(void *e){
   heap_equality_free((heap_equality_t) * (void **) e);
 }
 
-int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
+int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, mc_comparison_times_t ct1, mc_comparison_times_t ct2){
 
   raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
   
@@ -202,6 +202,9 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
     }
   }
 
+  ct1->nb_comparisons++;
+  ct2->nb_comparisons++;
+
   xbt_os_timer_t global_timer = xbt_os_timer_new();
   xbt_os_timer_t timer = xbt_os_timer_new();
 
@@ -215,6 +218,9 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   size_t chunks_used2 = mmalloc_get_chunks_used((xbt_mheap_t)s2->regions[heap_index]->data);
   if(chunks_used1 != chunks_used2){
     if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+      xbt_os_timer_stop(timer);
+      xbt_dynar_push_as(ct1->chunks_used_comparison_times, double, xbt_os_timer_elapsed(timer));
+      xbt_dynar_push_as(ct2->chunks_used_comparison_times, double, xbt_os_timer_elapsed(timer));
       XBT_DEBUG("Different number of chunks used in each heap : %zu - %zu", chunks_used1, chunks_used2);
       errors++;
     }else{
@@ -223,7 +229,8 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
      
       xbt_os_timer_free(timer);
       xbt_os_timer_stop(global_timer);
-      xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+      xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
       xbt_os_timer_free(global_timer);
 
       if(!raw_mem_set)
@@ -231,22 +238,20 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
 
       return 1;
     }
+  }else{
+    if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
+      xbt_os_timer_stop(timer);
   }
-
-  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->chunks_used_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Chunks used comparison : %f", xbt_os_timer_elapsed(timer));
-    
+  
+  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
     xbt_os_timer_start(timer);
-  }
 
   /* Compare size of stacks */
   unsigned int cursor = 0;
   void *addr_stack1, *addr_stack2;
   void *sp1, *sp2;
   size_t size_used1, size_used2;
+  int is_diff = 0;
   while(cursor < xbt_dynar_length(stacks_areas)){
     addr_stack1 = (char *)s1->regions[heap_index]->data + ((char *)((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->address - (char *)std_heap);
     addr_stack2 = (char *)s2->regions[heap_index]->data + ((char *)((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->address - (char *)std_heap);
@@ -256,15 +261,22 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
     size_used2 = ((stack_region_t)xbt_dynar_get_as(stacks_areas, cursor, stack_region_t))->size - ((char*)sp2 - (char*)addr_stack2);
     if(size_used1 != size_used2){
       if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+        if(is_diff == 0){
+          xbt_os_timer_stop(timer);
+          xbt_dynar_push_as(ct1->stacks_sizes_comparison_times, double, xbt_os_timer_elapsed(timer));
+          xbt_dynar_push_as(ct2->stacks_sizes_comparison_times, double, xbt_os_timer_elapsed(timer));
+        }
         XBT_DEBUG("Different size used in stacks : %zu - %zu", size_used1, size_used2);
         errors++;
+        is_diff = 1;
       }else{
         if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
           XBT_VERB("Different size used in stacks : %zu - %zu", size_used1, size_used2);
  
         xbt_os_timer_free(timer);
         xbt_os_timer_stop(global_timer);
-        xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+        xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+        xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
         xbt_os_timer_free(global_timer);
 
         if(!raw_mem_set)
@@ -276,28 +288,33 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   }
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->stacks_sizes_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Stacks sizes comparison : %f", xbt_os_timer_elapsed(timer));
-    
+    if(is_diff == 0)
+      xbt_os_timer_stop(timer);
     xbt_os_timer_start(timer);
   }
-
+  
   /* Compare program data segment(s) */
+  is_diff = 0;
   i = data_program_index;
   while(i < s1->num_reg && s1->regions[i]->type == 2){
     if(data_bss_program_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
       if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+        if(is_diff == 0){
+          xbt_os_timer_stop(timer);
+          xbt_dynar_push_as(ct1->program_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
+          xbt_dynar_push_as(ct2->program_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
+        }
         XBT_DEBUG("Different memcmp for data in program");
         errors++;
+        is_diff = 1;
       }else{
         if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
           XBT_VERB("Different memcmp for data in program"); 
 
         xbt_os_timer_free(timer);
         xbt_os_timer_stop(global_timer);
-        xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+        xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+        xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
         xbt_os_timer_free(global_timer);
 
         if(!raw_mem_set)
@@ -309,28 +326,33 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   }
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->program_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Program data segment comparison : %f", xbt_os_timer_elapsed(timer));
-    
+    if(is_diff == 0)
+      xbt_os_timer_stop(timer);
     xbt_os_timer_start(timer);
   }
 
   /* Compare libsimgrid data segment(s) */
+  is_diff = 0;
   i = data_libsimgrid_index;
   while(i < s1->num_reg && s1->regions[i]->type == 1){
     if(data_bss_libsimgrid_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
       if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+        if(is_diff == 0){
+          xbt_os_timer_stop(timer);
+          xbt_dynar_push_as(ct1->libsimgrid_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
+          xbt_dynar_push_as(ct2->libsimgrid_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
+        }
         XBT_DEBUG("Different memcmp for data in libsimgrid");
         errors++;
+        is_diff = 1;
       }else{
         if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
           XBT_VERB("Different memcmp for data in libsimgrid");
          
         xbt_os_timer_free(timer);
         xbt_os_timer_stop(global_timer);
-        xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+        xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+        xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
         xbt_os_timer_free(global_timer);
         
         if(!raw_mem_set)
@@ -342,11 +364,8 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   }
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->libsimgrid_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Libsimgrid data segment comparison : %f", xbt_os_timer_elapsed(timer));
-    
+    if(is_diff == 0)
+      xbt_os_timer_stop(timer);
     xbt_os_timer_start(timer);
   }
 
@@ -360,6 +379,9 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   if(mmalloc_compare_heap((xbt_mheap_t)s1->regions[heap_index]->data, (xbt_mheap_t)s2->regions[heap_index]->data, &stacks1, &stacks2, &equals)){
 
     if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+      xbt_os_timer_stop(timer);
+      xbt_dynar_push_as(ct1->heap_comparison_times, double, xbt_os_timer_elapsed(timer));
+      xbt_dynar_push_as(ct2->heap_comparison_times, double, xbt_os_timer_elapsed(timer));
       XBT_DEBUG("Different heap (mmalloc_compare)");
       errors++;
     }else{
@@ -373,28 +395,27 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
         XBT_VERB("Different heap (mmalloc_compare)");
        
       xbt_os_timer_stop(global_timer);
-      xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+      xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
       xbt_os_timer_free(global_timer);
 
       if(!raw_mem_set)
         MC_UNSET_RAW_MEM;
       return 1;
     } 
+  }else{
+    if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
+      xbt_os_timer_stop(timer);
   }
 
-  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->heap_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Heap comparison : %f", xbt_os_timer_elapsed(timer));
-    
+  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))
     xbt_os_timer_start(timer);
-  }
 
   /* Stacks comparison */
   cursor = 0;
   stack_region_t stack_region1, stack_region2;
   int diff = 0, diff_local = 0;
+  is_diff = 0;
 
   while(cursor < xbt_dynar_length(stacks1)){
     stack_region1 = (stack_region_t)(xbt_dynar_get_as(stacks1, cursor, stack_region_t));
@@ -407,8 +428,14 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
       diff_local = compare_local_variables(((mc_snapshot_stack_t)xbt_dynar_get_as(s1->stacks, cursor, mc_snapshot_stack_t))->local_variables->data, ((mc_snapshot_stack_t)xbt_dynar_get_as(s2->stacks, cursor, mc_snapshot_stack_t))->local_variables->data, equals);
       if(diff_local > 0){
         if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+          if(is_diff == 0){
+            xbt_os_timer_stop(timer);
+            xbt_dynar_push_as(ct1->stacks_comparison_times, double, xbt_os_timer_elapsed(timer));
+            xbt_dynar_push_as(ct2->stacks_comparison_times, double, xbt_os_timer_elapsed(timer));
+          }
           XBT_DEBUG("Different local variables between stacks %d", cursor + 1);
           errors++;
+          is_diff = 1;
         }else{
           xbt_dynar_free(&stacks1);
           xbt_dynar_free(&stacks2);
@@ -419,7 +446,8 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
           
           xbt_os_timer_free(timer);
           xbt_os_timer_stop(global_timer);
-          xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+          xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+          xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
           xbt_os_timer_free(global_timer);
           
           if(!raw_mem_set)
@@ -436,17 +464,14 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2){
   xbt_dynar_free(&stacks2);
   xbt_dynar_free(&equals);
 
-  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-    xbt_os_timer_stop(timer);
-    xbt_dynar_push_as(initial_state_liveness->stacks_comparison_times, double, xbt_os_timer_elapsed(timer));
-
-    XBT_DEBUG("Stacks comparison : %f", xbt_os_timer_elapsed(timer));
-    
+  if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug))    
     xbt_os_timer_free(timer);
-  }
 
-  xbt_os_timer_stop(global_timer);
-  xbt_dynar_push_as(initial_state_liveness->snapshot_comparison_times, double, xbt_os_timer_elapsed(timer));
+  if(!XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+    xbt_os_timer_stop(global_timer);
+    xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+    xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+  }
   xbt_os_timer_free(global_timer);
 
   if(!raw_mem_set)
index 02600ef..8b8306f 100644 (file)
@@ -204,13 +204,6 @@ void MC_init_liveness(){
   MC_get_local_variables(ls_path, libsimgrid_location_list, &mc_local_variables);
 
   initial_state_liveness = xbt_new0(s_mc_global_t, 1);
-  initial_state_liveness->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->program_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->libsimgrid_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  initial_state_liveness->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
 
   MC_UNSET_RAW_MEM;
 
index cb1b91b..381e3c9 100644 (file)
@@ -50,6 +50,141 @@ int create_dump(int pair)
   return 0;
 }
 
+void MC_print_comparison_times_statistics(mc_comparison_times_t ct){
+
+  XBT_DEBUG("Comparisons done : %d", ct->nb_comparisons);
+  
+  double total, min, max;
+  unsigned int cursor;
+  
+  if(xbt_dynar_length(ct->chunks_used_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->chunks_used_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->chunks_used_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Chunks used comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->chunks_used_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->chunks_used_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->stacks_sizes_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->stacks_sizes_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->stacks_sizes_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Stacks sizes comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_sizes_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_sizes_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->program_data_segment_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->program_data_segment_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Program data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->program_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->program_data_segment_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Libsimgrid data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->heap_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->heap_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->heap_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->heap_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Heap comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->heap_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->heap_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->stacks_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->stacks_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->stacks_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Stacks comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_comparison_times), max, min);
+  }
+
+  if(xbt_dynar_length(ct->snapshot_comparison_times) > 0){
+    cursor = 0;
+    total = 0.0;
+    max = 0.0;
+    min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->snapshot_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->snapshot_comparison_times, cursor, double);
+      cursor++;
+    }
+    XBT_DEBUG("Snapshot comparison (Whole funnel) -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->snapshot_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->snapshot_comparison_times), max, min);
+  }
+
+}
+
+mc_comparison_times_t new_comparison_times(){
+  mc_comparison_times_t ct = NULL;
+  ct = xbt_new0(s_mc_comparison_times_t, 1);
+  ct->nb_comparisons = 0;
+  ct->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->program_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->libsimgrid_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  return ct;
+}
+
 int reached(xbt_state_t st){
 
   raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
@@ -61,6 +196,7 @@ int reached(xbt_state_t st){
   new_pair->nb = xbt_dynar_length(reached_pairs) + 1;
   new_pair->automaton_state = st;
   new_pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
+  new_pair->comparison_times = new_comparison_times();
   new_pair->system_state = MC_take_snapshot_liveness();  
   
   /* Get values of propositional symbols */
@@ -96,10 +232,11 @@ int reached(xbt_state_t st){
     mc_pair_reached_t pair_test = NULL;
      
     xbt_dynar_foreach(reached_pairs, cursor, pair_test){
-      XBT_INFO("Pair reached #%d", pair_test->nb);
+      if(XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug))
+        XBT_DEBUG("****** Pair reached #%d ******", pair_test->nb);
       if(automaton_state_compare(pair_test->automaton_state, st) == 0){
         if(propositional_symbols_compare_value(pair_test->prop_ato, new_pair->prop_ato) == 0){
-          if(snapshot_compare(new_pair->system_state, pair_test->system_state) == 0){
+          if(snapshot_compare(new_pair->system_state, pair_test->system_state, new_pair->comparison_times, pair_test->comparison_times) == 0){
             
             if(raw_mem_set)
               MC_SET_RAW_MEM;
@@ -114,6 +251,10 @@ int reached(xbt_state_t st){
       }else{
         XBT_INFO("Different automaton state");
       }
+      if(pair_test->comparison_times != NULL && XBT_LOG_ISENABLED(mc_liveness, xbt_log_priority_debug)){
+        XBT_DEBUG("*** Comparison times statistics ***");
+        MC_print_comparison_times_statistics(pair_test->comparison_times);
+      }
     }
 
     /* New pair reached */
@@ -143,6 +284,7 @@ void set_pair_reached(xbt_state_t st){
   pair->nb = xbt_dynar_length(reached_pairs) + 1;
   pair->automaton_state = st;
   pair->prop_ato = xbt_dynar_new(sizeof(int), NULL);
+  pair->comparison_times = new_comparison_times();
   pair->system_state = MC_take_snapshot_liveness();
 
   /* Get values of propositional symbols */
index f07cd97..f93f35f 100644 (file)
@@ -44,13 +44,6 @@ typedef struct s_mc_snapshot_stack{
 
 typedef struct s_mc_global_t{
   mc_snapshot_t initial_snapshot;
-  xbt_dynar_t snapshot_comparison_times;
-  xbt_dynar_t chunks_used_comparison_times;
-  xbt_dynar_t stacks_sizes_comparison_times;
-  xbt_dynar_t program_data_segment_comparison_times;
-  xbt_dynar_t libsimgrid_data_segment_comparison_times;
-  xbt_dynar_t heap_comparison_times;
-  xbt_dynar_t stacks_comparison_times;
 }s_mc_global_t, *mc_global_t;
 
 void MC_take_snapshot(mc_snapshot_t);
@@ -241,19 +234,32 @@ typedef struct s_mc_pair{
   xbt_state_t automaton_state;
 }s_mc_pair_t, *mc_pair_t;
 
+typedef struct s_mc_comparison_times{
+  int nb_comparisons;
+  xbt_dynar_t snapshot_comparison_times;
+  xbt_dynar_t chunks_used_comparison_times;
+  xbt_dynar_t stacks_sizes_comparison_times;
+  xbt_dynar_t program_data_segment_comparison_times;
+  xbt_dynar_t libsimgrid_data_segment_comparison_times;
+  xbt_dynar_t heap_comparison_times;
+  xbt_dynar_t stacks_comparison_times;
+}s_mc_comparison_times_t, *mc_comparison_times_t;
+
 typedef struct s_mc_pair_reached{
   int nb;
   xbt_state_t automaton_state;
   xbt_dynar_t prop_ato;
   mc_snapshot_t system_state;
+  mc_comparison_times_t comparison_times;
 }s_mc_pair_reached_t, *mc_pair_reached_t;
 
 int MC_automaton_evaluate_label(xbt_exp_label_t l);
 mc_pair_t new_pair(mc_snapshot_t sn, mc_state_t sg, xbt_state_t st);
+mc_comparison_times_t new_comparison_times(void);
 
 int reached(xbt_state_t st);
 void set_pair_reached(xbt_state_t st);
-int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2);
+int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, mc_comparison_times_t ct1, mc_comparison_times_t ct2);
 void MC_pair_delete(mc_pair_t pair);
 void MC_exit_liveness(void);
 mc_state_t MC_state_pair_new(void);
@@ -261,6 +267,7 @@ void pair_reached_free(mc_pair_reached_t pair);
 void pair_reached_free_voidp(void *p);
 void MC_init_liveness(void);
 void MC_init_memory_map_info(void);
+void MC_print_comparison_times_statistics(mc_comparison_times_t ct);
 
 /* **** Double-DFS stateless **** */
 
index d5a93fc..70c1393 100644 (file)
@@ -566,7 +566,7 @@ void SIMIX_simcall_pre(smx_simcall_t simcall, int value)
 
     case SIMCALL_MC_COMPARE_SNAPSHOTS:
       simcall->mc_compare_snapshots.result =
-        snapshot_compare(simcall->mc_compare_snapshots.snapshot1, simcall->mc_compare_snapshots.snapshot2);
+        snapshot_compare(simcall->mc_compare_snapshots.snapshot1, simcall->mc_compare_snapshots.snapshot2, NULL, NULL);
       SIMIX_simcall_answer(simcall);
       break;
 #endif /* HAVE_MC */