Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Rename PerPageCopy to ChunkedData (and move in its own files)
[simgrid.git] / src / mc / RegionSnapshot.hpp
index 9b74130..11ba6f8 100644 (file)
 
 #include <mc/PageStore.hpp>
 #include <mc/AddressSpace.hpp>
+#include <mc/ChunkedData.hpp>
 
 namespace simgrid {
 namespace mc {
 
-class PerPageCopy {
-  PageStore* store_;
-  std::vector<std::size_t> pagenos_;
-public:
-  PerPageCopy() : store_(nullptr) {}
-  PerPageCopy(PerPageCopy const& that)
-  {
-    store_ = that.store_;
-    pagenos_ = that.pagenos_;
-    for (std::size_t pageno : pagenos_)
-      store_->ref_page(pageno);
-  }
-  void clear()
-  {
-    for (std::size_t pageno : pagenos_)
-      store_->unref_page(pageno);
-    pagenos_.clear();
-  }
-  ~PerPageCopy() {
-    clear();
-  }
-
-  PerPageCopy(PerPageCopy&& that)
-  {
-    store_ = that.store_;
-    that.store_ = nullptr;
-    pagenos_ = std::move(that.pagenos_);
-    that.pagenos_.clear();
-  }
-  PerPageCopy& operator=(PerPageCopy const& that)
-  {
-    this->clear();
-    store_ = that.store_;
-    pagenos_ = that.pagenos_;
-    for (std::size_t pageno : pagenos_)
-      store_->ref_page(pageno);
-    return *this;
-  }
-  PerPageCopy& operator=(PerPageCopy && that)
-  {
-    this->clear();
-    store_ = that.store_;
-    that.store_ = nullptr;
-    pagenos_ = std::move(that.pagenos_);
-    that.pagenos_.clear();
-    return *this;
-  }
-
-  std::size_t page_count() const
-  {
-    return pagenos_.size();
-  }
-
-  std::size_t pageno(std::size_t i) const
-  {
-    return pagenos_[i];
-  }
-
-  const std::size_t* pagenos() const { return pagenos_.data(); }
-  std::size_t*       pagenos()       { return pagenos_.data(); }
-
-  const void* page(std::size_t i) const
-  {
-    return store_->get_page(pagenos_[i]);
-  }
-
-  PerPageCopy(PageStore& store, AddressSpace& as,
-    remote_ptr<void> addr, std::size_t page_count,
-    const size_t* ref_page_numbers, const std::uint64_t* pagemap);
-};
-
 enum class RegionType {
   Unknown = 0,
   Heap = 1,
@@ -143,10 +73,6 @@ public:
   static const RegionType UnknownRegion = RegionType::Unknown;
   static const RegionType HeapRegion = RegionType::Heap;
   static const RegionType DataRegion = RegionType::Data;
-  static const StorageType NoData = StorageType::NoData;
-  static const StorageType FlatData = StorageType::Flat;
-  static const StorageType ChunkedData = StorageType::Chunked;
-  static const StorageType PrivatizedData = StorageType::Privatized;
 public:
   typedef unique_data_ptr flat_data_ptr;
 private:
@@ -172,12 +98,12 @@ private:
   void *permanent_addr_;
 
   flat_data_ptr flat_data_;
-  PerPageCopy page_numbers_;
+  ChunkedData page_numbers_;
   std::vector<RegionSnapshot> privatized_regions_;
 public:
   RegionSnapshot() :
     region_type_(UnknownRegion),
-    storage_type_(NoData),
+    storage_type_(StorageType::NoData),
     object_info_(nullptr),
     start_addr_(nullptr),
     size_(0),
@@ -185,7 +111,7 @@ public:
   {}
   RegionSnapshot(RegionType type, void *start_addr, void* permanent_addr, size_t size) :
     region_type_(type),
-    storage_type_(NoData),
+    storage_type_(StorageType::NoData),
     object_info_(nullptr),
     start_addr_(start_addr),
     size_(size),
@@ -227,7 +153,7 @@ public:
   void clear()
   {
     region_type_ = UnknownRegion;
-    storage_type_ = NoData;
+    storage_type_ = StorageType::NoData;
     privatized_regions_.clear();
     page_numbers_.clear();
     flat_data_.reset();
@@ -239,7 +165,7 @@ public:
 
   void clear_data()
   {
-    storage_type_ = NoData;
+    storage_type_ = StorageType::NoData;
     flat_data_.reset();
     page_numbers_.clear();
     privatized_regions_.clear();
@@ -247,25 +173,25 @@ public:
   
   void flat_data(flat_data_ptr data)
   {
-    storage_type_ = FlatData;
+    storage_type_ = StorageType::Flat;
     flat_data_ = std::move(data);
     page_numbers_.clear();
     privatized_regions_.clear();
   }
   const char* flat_data() const { return flat_data_.get(); }
 
-  void page_data(PerPageCopy page_data)
+  void page_data(ChunkedData page_data)
   {
-    storage_type_ = ChunkedData;
+    storage_type_ = StorageType::Chunked;
     flat_data_.reset();
     page_numbers_ = std::move(page_data);
     privatized_regions_.clear();
   }
-  PerPageCopy const& page_data() const { return page_numbers_; }
+  ChunkedData const& page_data() const { return page_numbers_; }
 
   void privatized_data(std::vector<RegionSnapshot> data)
   {
-    storage_type_ = PrivatizedData;
+    storage_type_ = StorageType::Privatized;
     flat_data_.reset();
     page_numbers_.clear();
     privatized_regions_ = std::move(data);