Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: tiny simplifications and cosmetics (even some snake_casing)
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 16 May 2019 00:15:44 +0000 (02:15 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Thu, 16 May 2019 00:44:31 +0000 (02:44 +0200)
src/mc/mc_mmu.hpp
src/mc/mc_smx.cpp
src/mc/sosp/RegionSnapshot.cpp
src/mc/sosp/mc_checkpoint.cpp
src/mc/sosp/mc_snapshot.hpp

index dae7a09..cd920ce 100644 (file)
@@ -13,9 +13,9 @@
 #define XBT_ALWAYS_INLINE inline __attribute__((always_inline))
 #endif
 
 #define XBT_ALWAYS_INLINE inline __attribute__((always_inline))
 #endif
 
-/** Cache the size of a memory page for the current system. */
+/** Size of a memory page for the current system. */
 extern "C" int xbt_pagesize;
 extern "C" int xbt_pagesize;
-/** Cache the number of bits of addresses inside a given page, log2(xbt_pagesize). */
+/** Number of bits of addresses inside a given page, log2(xbt_pagesize). */
 extern "C" int xbt_pagebits;
 
 namespace simgrid {
 extern "C" int xbt_pagebits;
 
 namespace simgrid {
@@ -23,7 +23,7 @@ namespace mc {
 // TODO, do not depend on xbt_pagesize/xbt_pagebits but our own chunk size
 namespace mmu {
 
 // TODO, do not depend on xbt_pagesize/xbt_pagebits but our own chunk size
 namespace mmu {
 
-static int chunkSize()
+static int chunk_size()
 {
   return xbt_pagesize;
 }
 {
   return xbt_pagesize;
 }
@@ -33,7 +33,7 @@ static int chunkSize()
  *  @param size Byte size
  *  @return Number of memory pages
  */
  *  @param size Byte size
  *  @return Number of memory pages
  */
-static XBT_ALWAYS_INLINE std::size_t chunkCount(std::size_t size)
+static XBT_ALWAYS_INLINE std::size_t chunk_count(std::size_t size)
 {
   size_t page_count = size >> xbt_pagebits;
   if (size & (xbt_pagesize - 1))
 {
   size_t page_count = size >> xbt_pagebits;
   if (size & (xbt_pagesize - 1))
@@ -47,7 +47,7 @@ static XBT_ALWAYS_INLINE std::pair<std::size_t, std::uintptr_t> split(std::uintp
   return {offset >> xbt_pagebits, offset & (xbt_pagesize - 1)};
 }
 
   return {offset >> xbt_pagebits, offset & (xbt_pagesize - 1)};
 }
 
-/** Merge chunk number and remaining offset info a global offset */
+/** Merge chunk number and remaining offset into a global offset */
 static XBT_ALWAYS_INLINE std::uintptr_t join(std::size_t page, std::uintptr_t offset)
 {
   return ((std::uintptr_t)page << xbt_pagebits) + offset;
 static XBT_ALWAYS_INLINE std::uintptr_t join(std::size_t page, std::uintptr_t offset)
 {
   return ((std::uintptr_t)page << xbt_pagebits) + offset;
@@ -58,7 +58,7 @@ static XBT_ALWAYS_INLINE std::uintptr_t join(std::pair<std::size_t, std::uintptr
   return join(value.first, value.second);
 }
 
   return join(value.first, value.second);
 }
 
-static XBT_ALWAYS_INLINE bool sameChunk(std::uintptr_t a, std::uintptr_t b)
+static XBT_ALWAYS_INLINE bool same_chunk(std::uintptr_t a, std::uintptr_t b)
 {
   return (a >> xbt_pagebits) == (b >> xbt_pagebits);
 }
 {
   return (a >> xbt_pagebits) == (b >> xbt_pagebits);
 }
index 1f27dc8..c1ea4b3 100644 (file)
@@ -151,8 +151,7 @@ int MC_smpi_process_count()
   if (mc_model_checker == nullptr)
     return smpi_process_count();
   int res;
   if (mc_model_checker == nullptr)
     return smpi_process_count();
   int res;
-  mc_model_checker->process().read_variable("process_count",
-    &res, sizeof(res));
+  mc_model_checker->process().read_variable("process_count", &res, sizeof(res));
   return res;
 }
 #endif
   return res;
 }
 #endif
index 4a506bf..f86a2f3 100644 (file)
@@ -61,7 +61,7 @@ RegionSnapshot sparse_region(RegionType region_type, void* start_addr, void* per
   xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize - 1)) == 0, "Start address not at the beginning of a page");
   xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize - 1)) == 0,
              "Permanent address not at the beginning of a page");
   xbt_assert((((uintptr_t)start_addr) & (xbt_pagesize - 1)) == 0, "Start address not at the beginning of a page");
   xbt_assert((((uintptr_t)permanent_addr) & (xbt_pagesize - 1)) == 0,
              "Permanent address not at the beginning of a page");
-  size_t page_count = simgrid::mc::mmu::chunkCount(size);
+  size_t page_count = simgrid::mc::mmu::chunk_count(size);
 
   simgrid::mc::ChunkedData page_data(mc_model_checker->page_store(), *process, RemotePtr<void>(permanent_addr),
                                      page_count);
 
   simgrid::mc::ChunkedData page_data(mc_model_checker->page_store(), *process, RemotePtr<void>(permanent_addr),
                                      page_count);
index 9951c16..e5bd494 100644 (file)
@@ -66,7 +66,7 @@ static void restore(RegionSnapshot* region)
 
     case simgrid::mc::StorageType::Chunked:
       xbt_assert(((region->permanent_address().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
 
     case simgrid::mc::StorageType::Chunked:
       xbt_assert(((region->permanent_address().address()) & (xbt_pagesize - 1)) == 0, "Not at the beginning of a page");
-      xbt_assert(simgrid::mc::mmu::chunkCount(region->size()) == region->page_data().page_count());
+      xbt_assert(simgrid::mc::mmu::chunk_count(region->size()) == region->page_data().page_count());
 
       for (size_t i = 0; i != region->page_data().page_count(); ++i) {
         void* target_page =
 
       for (size_t i = 0; i != region->page_data().page_count(); ++i) {
         void* target_page =
@@ -112,7 +112,7 @@ RegionSnapshot privatized_region(RegionType region_type, void* start_addr, void*
 }
 #endif
 
 }
 #endif
 
-static void add_region(int index, simgrid::mc::Snapshot* snapshot, simgrid::mc::RegionType type,
+static void add_region(simgrid::mc::Snapshot* snapshot, simgrid::mc::RegionType type,
                        simgrid::mc::ObjectInformation* object_info, void* start_addr, void* permanent_addr,
                        std::size_t size)
 {
                        simgrid::mc::ObjectInformation* object_info, void* start_addr, void* permanent_addr,
                        std::size_t size)
 {
@@ -131,26 +131,23 @@ static void add_region(int index, simgrid::mc::Snapshot* snapshot, simgrid::mc::
     region = simgrid::mc::region(type, start_addr, permanent_addr, size);
 
   region.object_info(object_info);
     region = simgrid::mc::region(type, start_addr, permanent_addr, size);
 
   region.object_info(object_info);
-  snapshot->snapshot_regions[index] =
-      std::unique_ptr<simgrid::mc::RegionSnapshot>(new simgrid::mc::RegionSnapshot(std::move(region)));
+  snapshot->snapshot_regions.push_back(
+      std::unique_ptr<simgrid::mc::RegionSnapshot>(new simgrid::mc::RegionSnapshot(std::move(region))));
 }
 
 static void get_memory_regions(simgrid::mc::RemoteClient* process, simgrid::mc::Snapshot* snapshot)
 {
 }
 
 static void get_memory_regions(simgrid::mc::RemoteClient* process, simgrid::mc::Snapshot* snapshot)
 {
-  const size_t n = process->object_infos.size();
-  snapshot->snapshot_regions.resize(n + 1);
-  int i = 0;
-  for (auto const& object_info : process->object_infos) {
-    add_region(i, snapshot, simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw,
-               object_info->start_rw, object_info->end_rw - object_info->start_rw);
-    ++i;
-  }
+  snapshot->snapshot_regions.clear();
+
+  for (auto const& object_info : process->object_infos)
+    add_region(snapshot, simgrid::mc::RegionType::Data, object_info.get(), object_info->start_rw, object_info->start_rw,
+               object_info->end_rw - object_info->start_rw);
 
   xbt_mheap_t heap = process->get_heap();
   void* start_heap = heap->base;
   void* end_heap   = heap->breakval;
 
 
   xbt_mheap_t heap = process->get_heap();
   void* start_heap = heap->base;
   void* end_heap   = heap->breakval;
 
-  add_region(n, snapshot, simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap,
+  add_region(snapshot, simgrid::mc::RegionType::Heap, nullptr, start_heap, start_heap,
              (char*)end_heap - (char*)start_heap);
   snapshot->heap_bytes_used = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
 
              (char*)end_heap - (char*)start_heap);
   snapshot->heap_bytes_used = mmalloc_get_bytes_used_remote(heap->heaplimit, process->get_malloc_info());
 
@@ -443,10 +440,7 @@ std::shared_ptr<simgrid::mc::Snapshot> take_snapshot(int num_state)
     snapshot->stacks = take_snapshot_stacks(snapshot.get());
     if (_sg_mc_hash)
       snapshot->hash = simgrid::mc::hash(*snapshot);
     snapshot->stacks = take_snapshot_stacks(snapshot.get());
     if (_sg_mc_hash)
       snapshot->hash = simgrid::mc::hash(*snapshot);
-    else
-      snapshot->hash = 0;
-  } else
-    snapshot->hash = 0;
+  }
 
   snapshot_ignore_restore(snapshot.get());
   return snapshot;
 
   snapshot_ignore_restore(snapshot.get());
   return snapshot;
index b02b4d6..1926455 100644 (file)
@@ -108,7 +108,7 @@ public:
   std::vector<std::size_t> stack_sizes;
   std::vector<s_mc_snapshot_stack_t> stacks;
   std::vector<simgrid::mc::IgnoredHeapRegion> to_ignore;
   std::vector<std::size_t> stack_sizes;
   std::vector<s_mc_snapshot_stack_t> stacks;
   std::vector<simgrid::mc::IgnoredHeapRegion> to_ignore;
-  std::uint64_t hash;
+  std::uint64_t hash = 0;
   std::vector<s_mc_snapshot_ignored_data_t> ignored_data;
 };
 } // namespace mc
   std::vector<s_mc_snapshot_ignored_data_t> ignored_data;
 };
 } // namespace mc
@@ -171,7 +171,7 @@ static XBT_ALWAYS_INLINE const void* MC_region_read(simgrid::mc::RegionSnapshot*
     case simgrid::mc::StorageType::Chunked: {
       // Last byte of the region:
       void* end = (char*)addr + size - 1;
     case simgrid::mc::StorageType::Chunked: {
       // Last byte of the region:
       void* end = (char*)addr + size - 1;
-      if (simgrid::mc::mmu::sameChunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
+      if (simgrid::mc::mmu::same_chunk((std::uintptr_t)addr, (std::uintptr_t)end)) {
         // The memory is contained in a single page:
         return mc_translate_address_region_chunked((uintptr_t)addr, region);
       }
         // The memory is contained in a single page:
         return mc_translate_address_region_chunked((uintptr_t)addr, region);
       }