From: Gabriel Corona Date: Tue, 2 Jun 2015 11:13:31 +0000 (+0200) Subject: temp X-Git-Tag: v3_12~693 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8454ea5fa71f9a14328f16aec13537e592912d48 temp --- diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index 7940e39b74..6e4b110b2f 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -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] diff --git a/src/mc/mc_page_snapshot.cpp b/src/mc/mc_page_snapshot.cpp index eeaa925005..7bb42f03d1 100644 --- a/src/mc/mc_page_snapshot.cpp +++ b/src/mc/mc_page_snapshot.cpp @@ -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, diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 21cfc7b3bd..746453687c 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -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