Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'origin/mc-fastsnapshot' into mc
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 24 Jul 2014 14:11:19 +0000 (16:11 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 24 Jul 2014 14:11:19 +0000 (16:11 +0200)
Conflicts:
buildtools/Cmake/Flags.cmake

1  2 
src/mc/mc_global.c
src/mc/mc_private.h

diff --combined src/mc/mc_global.c
@@@ -30,7 -30,7 +30,7 @@@ e_mc_reduce_t mc_reduce_kind = e_mc_red
  int _sg_do_model_check = 0;
  int _sg_mc_checkpoint = 0;
  int _sg_mc_sparse_checkpoint = 0;
- int _sg_mc_soft_dirty = 1;
+ int _sg_mc_soft_dirty = 0;
  char *_sg_mc_property_file = NULL;
  int _sg_mc_timeout = 0;
  int _sg_mc_hash = 0;
@@@ -145,7 -145,6 +145,7 @@@ void _mc_cfg_cb_comms_determinism(cons
          ("You are specifying a value to enable/disable the detection of determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
    }
    _sg_mc_comms_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
 +  mc_reduce_kind = e_mc_reduce_none;
  }
  
  void _mc_cfg_cb_send_determinism(const char *name, int pos)
          ("You are specifying a value to enable/disable the detection of send-determinism in the communications schemes after the initialization (through MSG_config?), but model-checking was not activated at config time (through --cfg=model-check:1). This won't work, sorry.");
    }
    _sg_mc_send_determinism = xbt_cfg_get_boolean(_sg_cfg_set, name);
 +  mc_reduce_kind = e_mc_reduce_none;
  }
  
  /* MC global data structures */
@@@ -304,9 -302,6 +304,9 @@@ void MC_init(
      MC_ignore_global_variable("maestro_stack_start");
      MC_ignore_global_variable("maestro_stack_end");
      MC_ignore_global_variable("smx_total_comms");
 +    MC_ignore_global_variable("communications_pattern");
 +    MC_ignore_global_variable("initial_communications_pattern");
 +    MC_ignore_global_variable("incomplete_communications_pattern");
  
      if (MC_is_active()) {
        MC_ignore_global_variable("mc_diff_info");
@@@ -513,12 -508,13 +513,12 @@@ void MC_replay(xbt_fifo_t stack, int st
  {
    int raw_mem = (mmalloc_get_current_heap() == mc_heap);
  
 -  int value, i = 1, count = 1;
 +  int value, i = 1, count = 1, call = 0, j;
    char *req_str;
    smx_simcall_t req = NULL, saved_req = NULL;
    xbt_fifo_item_t item, start_item;
    mc_state_t state;
    smx_process_t process = NULL;
 -  int comm_pattern = 0;
    smx_action_t current_comm;
  
    XBT_DEBUG("**** Begin Replay ****");
  
    MC_SET_MC_HEAP;
  
 -  if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
 +  if (mc_reduce_kind == e_mc_reduce_dpor) {
      xbt_dict_reset(first_enabled_state);
      xbt_swag_foreach(process, simix_global->process_list) {
        if (MC_process_is_enabled(process)) {
    }
  
    if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
 -    xbt_dynar_reset(communications_pattern);
 -    xbt_dynar_reset(incomplete_communications_pattern);
 +    for (j=0; j<simix_process_maxpid; j++) {
 +      xbt_dynar_reset((xbt_dynar_t)xbt_dynar_get_as(communications_pattern, j, xbt_dynar_t));
 +    }
 +    for (j=0; j<simix_process_maxpid; j++) {
 +      xbt_dynar_reset((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, j, xbt_dynar_t));
 +    }
    }
  
    MC_SET_STD_HEAP;
      state = (mc_state_t) xbt_fifo_get_item_content(item);
      saved_req = MC_state_get_executed_request(state, &value);
  
 -    if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
 +    if (mc_reduce_kind == e_mc_reduce_dpor) {
        MC_SET_MC_HEAP;
        char *key = bprintf("%lu", saved_req->issuer->pid);
        xbt_dict_remove(first_enabled_state, key);
        /* TODO : handle test and testany simcalls */
        if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
          if (req->call == SIMCALL_COMM_ISEND)
 -          comm_pattern = 1;
 +          call = 1;
          else if (req->call == SIMCALL_COMM_IRECV)
 -          comm_pattern = 2;
 +          call = 2;
          else if (req->call == SIMCALL_COMM_WAIT)
 -          comm_pattern = 3;
 +          call = 3;
          else if (req->call == SIMCALL_COMM_WAITANY)
 -          comm_pattern = 4;
 +          call = 4;
        }
  
        SIMIX_simcall_pre(req, value);
  
        if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
          MC_SET_MC_HEAP;
 -        if (comm_pattern == 1 || comm_pattern == 2) {
 -          get_comm_pattern(communications_pattern, req, comm_pattern);
 -        } else if (comm_pattern == 3 /* || comm_pattern == 4 */ ) {
 +        if (call == 1) { /* Send */
 +          get_comm_pattern(communications_pattern, req, call);
 +        } else if (call == 2) { /* Recv */
 +          get_comm_pattern(communications_pattern, req, call);
 +        } else if (call == 3) { /* Wait */
            current_comm = simcall_comm_wait__get__comm(req);
 -          if (current_comm->comm.refcount == 1) {       /* First wait only must be considered */
 +          if (current_comm->comm.refcount == 1)  /* First wait only must be considered */
              complete_comm_pattern(communications_pattern, current_comm);
 -          }
 -        } else if (comm_pattern == 4 /* || comm_pattern == 4 */ ) {
 -          current_comm =
 -              xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value,
 -                               smx_action_t);
 -          if (current_comm->comm.refcount == 1) {       /* First wait only must be considered */
 +        } else if (call == 4) { /* WaitAny */
 +          current_comm = xbt_dynar_get_as(simcall_comm_waitany__get__comms(req), value, smx_action_t);
 +          if (current_comm->comm.refcount == 1) /* First wait only must be considered */
              complete_comm_pattern(communications_pattern, current_comm);
 -          }
          }
          MC_SET_STD_HEAP;
 -        comm_pattern = 0;
 +        call = 0;
        }
  
  
  
        count++;
  
 -      if ((mc_reduce_kind == e_mc_reduce_dpor) && !_sg_mc_comms_determinism && !_sg_mc_send_determinism) {
 +      if (mc_reduce_kind == e_mc_reduce_dpor) {
          MC_SET_MC_HEAP;
          /* Insert in dict all enabled processes */
          xbt_swag_foreach(process, simix_global->process_list) {
diff --combined src/mc/mc_private.h
@@@ -142,6 -142,7 +142,7 @@@ void mc_free_page_snapshot_region(size_
  void mc_restore_page_snapshot_region(mc_mem_region_t region, size_t page_count, uint64_t* pagemap, mc_mem_region_t reference_region);
  
  mc_mem_region_t mc_region_new_sparse(int type, void *start_addr, size_t size, mc_mem_region_t ref_reg);
+ void MC_region_destroy(mc_mem_region_t reg);
  void mc_region_restore_sparse(mc_mem_region_t reg, mc_mem_region_t ref_reg);
  void mc_softdirty_reset();
  
@@@ -153,10 -154,10 +154,10 @@@ bool mc_snapshot_region_linear(mc_mem_r
  void* mc_snapshot_read_fragmented(void* addr, mc_mem_region_t region, void* target, size_t size);
  
  void* mc_snapshot_read(void* addr, mc_snapshot_t snapshot, void* target, size_t size);
- int mc_snapshot_region_memcp(
+ int mc_snapshot_region_memcmp(
    void* addr1, mc_mem_region_t region1,
    void* addr2, mc_mem_region_t region2, size_t size);
- int mc_snapshot_memcp(
+ int mc_snapshot_memcmp(
    void* addr1, mc_snapshot_t snapshot1,
    void* addr2, mc_snapshot_t snapshot2, size_t size);
  
@@@ -379,7 -380,7 +380,7 @@@ typedef struct s_mc_visited_state
  }s_mc_visited_state_t, *mc_visited_state_t;
  
  extern xbt_dynar_t visited_states;
 -int is_visited_state(void);
 +mc_visited_state_t is_visited_state(void);
  void visited_state_free(mc_visited_state_t state);
  void visited_state_free_voidp(void *s);
  
@@@ -628,7 -629,6 +629,7 @@@ typedef struct s_mc_comm_pattern
    void *data;
  }s_mc_comm_pattern_t, *mc_comm_pattern_t;
  
 +extern xbt_dynar_t initial_communications_pattern;
  extern xbt_dynar_t communications_pattern;
  extern xbt_dynar_t incomplete_communications_pattern;
  
@@@ -738,18 -738,22 +739,22 @@@ void* mc_snapshot_read_pointer(void* ad
  static inline __attribute__((always_inline))
  void* mc_snapshot_read_region(void* addr, mc_mem_region_t region, void* target, size_t size)
  {
-   uintptr_t offset = (uintptr_t) addr - (uintptr_t) region->start_addr;
+   if (region==NULL)
+     return addr;
  
-   xbt_assert(addr >= region->start_addr && (char*) addr+size < (char*)region->start_addr+region->size,
+   uintptr_t offset = (char*) addr - (char*) region->start_addr;
+   xbt_assert(mc_region_contain(region, addr),
      "Trying to read out of the region boundary.");
  
    // Linear memory region:
    if (region->data) {
-     return (void*) ((uintptr_t) region->data + offset);
+     return (char*) region->data + offset;
    }
  
    // Fragmented memory region:
    else if (region->page_numbers) {
+     // Last byte of the region:
      void* end = (char*) addr + size - 1;
      if( mc_same_page(addr, end) ) {
        // The memory is contained in a single page:
    }
  }
  
+ static inline __attribute__ ((always_inline))
+ void* mc_snapshot_read_pointer_region(void* addr, mc_mem_region_t region)
+ {
+   void* res;
+   return *(void**) mc_snapshot_read_region(addr, region, &res, sizeof(void*));
+ }
  
  SG_END_DECL()