From: Martin Quinson Date: Thu, 16 May 2019 00:15:44 +0000 (+0200) Subject: mc: tiny simplifications and cosmetics (even some snake_casing) X-Git-Tag: v3.22.4~127^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b923f24fcb86571011626426f577fe6322094bb3 mc: tiny simplifications and cosmetics (even some snake_casing) --- diff --git a/src/mc/mc_mmu.hpp b/src/mc/mc_mmu.hpp index dae7a092b5..cd920ce34b 100644 --- a/src/mc/mc_mmu.hpp +++ b/src/mc/mc_mmu.hpp @@ -13,9 +13,9 @@ #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; -/** 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 { @@ -23,7 +23,7 @@ namespace mc { // 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; } @@ -33,7 +33,7 @@ static int chunkSize() * @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)) @@ -47,7 +47,7 @@ static XBT_ALWAYS_INLINE std::pair split(std::uintp 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; @@ -58,7 +58,7 @@ static XBT_ALWAYS_INLINE std::uintptr_t join(std::pair> xbt_pagebits) == (b >> xbt_pagebits); } diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 1f27dc8580..c1ea4b3f38 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -151,8 +151,7 @@ int MC_smpi_process_count() 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 diff --git a/src/mc/sosp/RegionSnapshot.cpp b/src/mc/sosp/RegionSnapshot.cpp index 4a506bfd2d..f86a2f3c03 100644 --- a/src/mc/sosp/RegionSnapshot.cpp +++ b/src/mc/sosp/RegionSnapshot.cpp @@ -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"); - 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(permanent_addr), page_count); diff --git a/src/mc/sosp/mc_checkpoint.cpp b/src/mc/sosp/mc_checkpoint.cpp index 9951c16294..e5bd494a89 100644 --- a/src/mc/sosp/mc_checkpoint.cpp +++ b/src/mc/sosp/mc_checkpoint.cpp @@ -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"); - 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 = @@ -112,7 +112,7 @@ RegionSnapshot privatized_region(RegionType region_type, void* start_addr, void* } #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) { @@ -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); - snapshot->snapshot_regions[index] = - std::unique_ptr(new simgrid::mc::RegionSnapshot(std::move(region))); + snapshot->snapshot_regions.push_back( + std::unique_ptr(new simgrid::mc::RegionSnapshot(std::move(region)))); } 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; - 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()); @@ -443,10 +440,7 @@ std::shared_ptr take_snapshot(int num_state) 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; diff --git a/src/mc/sosp/mc_snapshot.hpp b/src/mc/sosp/mc_snapshot.hpp index b02b4d6002..19264557d4 100644 --- a/src/mc/sosp/mc_snapshot.hpp +++ b/src/mc/sosp/mc_snapshot.hpp @@ -108,7 +108,7 @@ public: std::vector stack_sizes; std::vector stacks; std::vector to_ignore; - std::uint64_t hash; + std::uint64_t hash = 0; std::vector 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; - 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); }