X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7f4f03348bd07609e258eb3b545bdafc2c881847..bff0c1c16b4447b3503aa48d11b15243154ed51a:/src/mc/ChunkedData.hpp diff --git a/src/mc/ChunkedData.hpp b/src/mc/ChunkedData.hpp index 05ef275b5b..076e607560 100644 --- a/src/mc/ChunkedData.hpp +++ b/src/mc/ChunkedData.hpp @@ -10,27 +10,32 @@ #include #include +#include #include #include "src/mc/mc_forward.hpp" -#include "src/mc/AddressSpace.hpp" #include "src/mc/PageStore.hpp" namespace simgrid { namespace mc { +/** A byte-string represented as a sequence of chunks from a PageStore + * + * In order to save memory when taking memory snapshots, a given byte-string + * is split in fixed-size chunks. Identical chunks (either from the same + * snapshot or more probably from different snpashots) share the same memory + * storage. + * + * Thus a chunked is represented as a sequence of indices of each chunk. + */ class ChunkedData { - PageStore* store_; + /** This is where we store the chunks */ + PageStore* store_ = nullptr; + /** Indices of the chunks in the `PageStore` */ std::vector pagenos_; public: - ChunkedData() : store_(nullptr) {} - ChunkedData(ChunkedData const& that) - { - store_ = that.store_; - pagenos_ = that.pagenos_; - for (std::size_t pageno : pagenos_) - store_->ref_page(pageno); - } + + ChunkedData() {} void clear() { for (std::size_t pageno : pagenos_) @@ -42,6 +47,14 @@ public: clear(); } + // Copy and move + ChunkedData(ChunkedData const& that) + { + store_ = that.store_; + pagenos_ = that.pagenos_; + for (std::size_t pageno : pagenos_) + store_->ref_page(pageno); + } ChunkedData(ChunkedData&& that) { store_ = that.store_; @@ -68,19 +81,23 @@ public: return *this; } + /** How many pages are used */ std::size_t page_count() const { return pagenos_.size(); } + + /** Get a chunk index */ std::size_t pageno(std::size_t i) const { return pagenos_[i]; } + + /** Get a view of the chunk indices */ const std::size_t* pagenos() const { return pagenos_.data(); } - std::size_t* pagenos() { return pagenos_.data(); } + /** Get a a pointer to a chunk */ const void* page(std::size_t i) const { return store_->get_page(pagenos_[i]); } ChunkedData(PageStore& store, AddressSpace& as, - remote_ptr addr, std::size_t page_count, - const std::size_t* ref_page_numbers, const std::uint64_t* pagemap); + RemotePtr addr, std::size_t page_count); }; }