Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
temp
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 2 Jun 2015 11:13:31 +0000 (13:13 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 2 Jun 2015 11:13:31 +0000 (13:13 +0200)
src/mc/mc_checkpoint.cpp
src/mc/mc_page_snapshot.cpp
src/mc/mc_snapshot.cpp
src/mc/mc_snapshot.h

index 7940e39..6e4b110 100644 (file)
@@ -80,15 +80,7 @@ namespace mc {
 
 RegionSnapshot::~RegionSnapshot() {}
 
-}
-}
-
-/*******************************  Snapshot regions ********************************/
-/*********************************************************************************/
-
-extern "C" {
-
-static simgrid::mc::RegionSnapshot MC_region_dense(
+simgrid::mc::RegionSnapshot dense_region(
   mc_region_type_t region_type,
   void *start_addr, void* permanent_addr, size_t size)
 {
@@ -113,16 +105,41 @@ static simgrid::mc::RegionSnapshot MC_region_dense(
  * @param permanent_addr Permanent address of this data (for privatized variables, this is the virtual address of the privatized mapping)
  * @param size         Size of the data*
  */
-static simgrid::mc::RegionSnapshot MC_region(
+static simgrid::mc::RegionSnapshot region(
   mc_region_type_t type, void *start_addr, void* permanent_addr, size_t size)
 {
   if (_sg_mc_sparse_checkpoint) {
-    return MC_region_sparse(type, start_addr, permanent_addr, size);
+    return sparse_region(type, start_addr, permanent_addr, size);
   } else  {
-    return MC_region_dense(type, start_addr, permanent_addr, size);
+    return dense_region(type, start_addr, permanent_addr, size);
   }
 }
 
+simgrid::mc::RegionSnapshot sparse_region(mc_region_type_t region_type,
+  void *start_addr, void* permanent_addr, size_t size)
+{
+  mc_process_t process = &mc_model_checker->process();
+
+  xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
+    "Not at the beginning of a page");
+  xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize-1)) == 0,
+    "Not at the beginning of a page");
+  size_t page_count = mc_page_count(size);
+
+  simgrid::mc::PerPageCopy page_data(mc_model_checker->page_store(), *process,
+      permanent_addr, page_count);
+
+  simgrid::mc::RegionSnapshot region(
+    region_type, start_addr, permanent_addr, size);
+  region.page_data(std::move(page_data));
+  return std::move(region);
+}
+
+}
+}
+
+extern "C" {
+
 /** @brief Restore a region from a snapshot
  *
  *  @param reg     Target region
@@ -151,7 +168,12 @@ static void MC_region_restore(mc_mem_region_t region)
   }
 }
 
-static simgrid::mc::RegionSnapshot MC_region_privatized(
+}
+
+namespace simgrid {
+namespace mc {
+
+simgrid::mc::RegionSnapshot privatized_region(
     mc_region_type_t region_type, void *start_addr, void* permanent_addr, size_t size
     )
 {
@@ -171,7 +193,7 @@ static simgrid::mc::RegionSnapshot MC_region_privatized(
   data.reserve(process_count);
   for (size_t i = 0; i < process_count; i++)
     data.push_back(
-      MC_region(region_type, start_addr,
+      simgrid::mc::region(region_type, start_addr,
         privatisation_regions[i].address, size)
       );
 
@@ -181,6 +203,11 @@ static simgrid::mc::RegionSnapshot MC_region_privatized(
   return std::move(region);
 }
 
+}
+}
+
+extern "C" {
+
 static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, mc_region_type_t type,
                                   mc_object_info_t object_info,
                                   void *start_addr, void* permanent_addr, size_t size)
@@ -196,7 +223,7 @@ static void MC_snapshot_add_region(int index, mc_snapshot_t snapshot, mc_region_
   if (privatization_aware && MC_smpi_process_count())
     region = MC_region_privatized(type, start_addr, permanent_addr, size);
   else
-    region = MC_region(type, start_addr, permanent_addr, size);
+    region = simgrid::mc::region(type, start_addr, permanent_addr, size);
 
   region.object_info(object_info);
   snapshot->snapshot_regions[index]
index eeaa925..7bb42f0 100644 (file)
@@ -82,26 +82,6 @@ void mc_restore_page_snapshot_region(mc_process_t process,
 
 // ***** High level API
 
-simgrid::mc::RegionSnapshot MC_region_sparse(mc_region_type_t region_type,
-  void *start_addr, void* permanent_addr, size_t size)
-{
-  mc_process_t process = &mc_model_checker->process();
-
-  xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize-1)) == 0,
-    "Not at the beginning of a page");
-  xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize-1)) == 0,
-    "Not at the beginning of a page");
-  size_t page_count = mc_page_count(size);
-
-  simgrid::mc::PerPageCopy page_data(mc_model_checker->page_store(), *process,
-      permanent_addr, page_count);
-
-  simgrid::mc::RegionSnapshot region(
-    region_type, start_addr, permanent_addr, size);
-  region.page_data(std::move(page_data));
-  return std::move(region);
-}
-
 void mc_region_restore_sparse(mc_process_t process, mc_mem_region_t reg)
 {
   xbt_assert(((reg->permanent_address().address()) & (xbt_pagesize-1)) == 0,
index 21cfc7b..7464536 100644 (file)
@@ -256,12 +256,12 @@ static void test_snapshot(bool sparse_checkpoint) {
 
     // Init memory and take snapshots:
     init_memory(source, byte_size);
-    simgrid::mc::RegionSnapshot region0 = MC_region_sparse(
+    simgrid::mc::RegionSnapshot region0 = simgrid::mc::sparse_region(
       MC_REGION_TYPE_UNKNOWN, source, source, byte_size);
     for(int i=0; i<n; i+=2) {
       init_memory((char*) source + i*xbt_pagesize, xbt_pagesize);
     }
-    simgrid::mc::RegionSnapshot region = MC_region_sparse(
+    simgrid::mc::RegionSnapshot region = simgrid::mc::sparse_region(
       MC_REGION_TYPE_UNKNOWN, source, source, byte_size);
 
     void* destination = mmap(NULL, byte_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
@@ -296,7 +296,7 @@ static void test_snapshot(bool sparse_checkpoint) {
     if (n==1) {
       xbt_test_add("Read pointer for %i page(s)", n);
       memcpy(source, &mc_model_checker, sizeof(void*));
-      simgrid::mc::RegionSnapshot region2 = MC_region_sparse(
+      simgrid::mc::RegionSnapshot region2 = simgrid::mc::sparse_region(
         MC_REGION_TYPE_UNKNOWN, source, source, byte_size);
       xbt_test_assert(MC_region_read_pointer(&region2, source) == mc_model_checker,
         "Mismtach in MC_region_read_pointer()");
index 4ce34ed..a6a4cde 100644 (file)
@@ -275,13 +275,26 @@ public:
   }
 };
 
+simgrid::mc::RegionSnapshot privatized_region(
+  mc_region_type_t type, void *start_addr, void* data_addr, size_t size);
+simgrid::mc::RegionSnapshot dense_region(
+  mc_region_type_t type, void *start_addr, void* data_addr, size_t size);
+simgrid::mc::RegionSnapshot sparse_region(
+  mc_region_type_t type, void *start_addr, void* data_addr, size_t size);
+simgrid::mc::RegionSnapshot region(
+  mc_region_type_t type, void *start_addr, void* data_addr, size_t size);
+
 }
 }
 
 typedef class simgrid::mc::RegionSnapshot s_mc_mem_region_t, *mc_mem_region_t;
 
-MC_SHOULD_BE_INTERNAL simgrid::mc::RegionSnapshot MC_region_sparse(
-  mc_region_type_t type, void *start_addr, void* data_addr, size_t size);
+namespace simgrid {
+namespace mc {
+
+}
+}
+
 XBT_INTERNAL void mc_region_restore_sparse(mc_process_t process, mc_mem_region_t reg);
 
 static inline  __attribute__ ((always_inline))