Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move libsosp into its own directory
[simgrid.git] / src / mc / sosp / RegionSnapshot.hpp
similarity index 65%
rename from src/mc/RegionSnapshot.hpp
rename to src/mc/sosp/RegionSnapshot.hpp
index 3ab7361..87b4220 100644 (file)
 #include "xbt/base.h"
 
 #include "src/mc/AddressSpace.hpp"
 #include "xbt/base.h"
 
 #include "src/mc/AddressSpace.hpp"
-#include "src/mc/ChunkedData.hpp"
-#include "src/mc/PageStore.hpp"
 #include "src/mc/remote/RemotePtr.hpp"
 #include "src/mc/remote/RemotePtr.hpp"
+#include "src/mc/sosp/ChunkedData.hpp"
+#include "src/mc/sosp/PageStore.hpp"
 
 namespace simgrid {
 namespace mc {
 
 
 namespace simgrid {
 namespace mc {
 
-enum class RegionType {
-  Unknown = 0,
-  Heap = 1,
-  Data = 2
-};
+enum class RegionType { Unknown = 0, Heap = 1, Data = 2 };
 
 
-enum class StorageType {
-  NoData = 0,
-  Flat = 1,
-  Chunked = 2,
-  Privatized = 3
-};
+enum class StorageType { NoData = 0, Flat = 1, Chunked = 2, Privatized = 3 };
 
 class Buffer {
 private:
 
 class Buffer {
 private:
-  enum class Type {
-    Malloc,
-    Mmap
-  };
+  enum class Type { Malloc, Mmap };
   void* data_ = nullptr;
   std::size_t size_;
   Type type_ = Type::Malloc;
 
   Buffer(std::size_t size, Type type = Type::Malloc);
   void* data_ = nullptr;
   std::size_t size_;
   Type type_ = Type::Malloc;
 
   Buffer(std::size_t size, Type type = Type::Malloc);
-  Buffer(void* data, std::size_t size, Type type = Type::Malloc) :
-    data_(data), size_(size), type_(type) {}
+  Buffer(void* data, std::size_t size, Type type = Type::Malloc) : data_(data), size_(size), type_(type) {}
+
 public:
   Buffer() = default;
   void clear() noexcept;
   ~Buffer() noexcept { clear(); }
 
 public:
   Buffer() = default;
   void clear() noexcept;
   ~Buffer() noexcept { clear(); }
 
-  static Buffer malloc(std::size_t size)
-  {
-    return Buffer(size, Type::Malloc);
-  }
-  static Buffer mmap(std::size_t size)
-  {
-    return Buffer(size, Type::Mmap);
-  }
+  static Buffer malloc(std::size_t size) { return Buffer(size, Type::Malloc); }
+  static Buffer mmap(std::size_t size) { return Buffer(size, Type::Mmap); }
 
   // No copy
   Buffer(Buffer const& buffer) = delete;
   Buffer& operator=(Buffer const& buffer) = delete;
 
   // Move
 
   // No copy
   Buffer(Buffer const& buffer) = delete;
   Buffer& operator=(Buffer const& buffer) = delete;
 
   // Move
-  Buffer(Buffer&& that) noexcept
-    : data_(that.data_), size_(that.size_), type_(that.type_)
+  Buffer(Buffer&& that) noexcept : data_(that.data_), size_(that.size_), type_(that.type_)
   {
     that.data_ = nullptr;
     that.size_ = 0;
   {
     that.data_ = nullptr;
     that.size_ = 0;
@@ -77,17 +58,17 @@ public:
   Buffer& operator=(Buffer&& that) noexcept
   {
     clear();
   Buffer& operator=(Buffer&& that) noexcept
   {
     clear();
-    data_ = that.data_;
-    size_ = that.size_;
-    type_ = that.type_;
+    data_      = that.data_;
+    size_      = that.size_;
+    type_      = that.type_;
     that.data_ = nullptr;
     that.size_ = 0;
     that.type_ = Type::Malloc;
     return *this;
   }
 
     that.data_ = nullptr;
     that.size_ = 0;
     that.type_ = Type::Malloc;
     return *this;
   }
 
-  void* get()              { return data_; }
-  const void* get()  const { return data_; }
+  void* get() { return data_; }
+  const void* get() const { return data_; }
   std::size_t size() const { return size_; }
 };
 
   std::size_t size() const { return size_; }
 };
 
@@ -112,15 +93,16 @@ public:
 class RegionSnapshot {
 public:
   static const RegionType UnknownRegion = RegionType::Unknown;
 class RegionSnapshot {
 public:
   static const RegionType UnknownRegion = RegionType::Unknown;
-  static const RegionType HeapRegion = RegionType::Heap;
-  static const RegionType DataRegion = RegionType::Data;
+  static const RegionType HeapRegion    = RegionType::Heap;
+  static const RegionType DataRegion    = RegionType::Data;
+
 private:
   RegionType region_type_;
   StorageType storage_type_;
   simgrid::mc::ObjectInformation* object_info_;
 
   /** @brief  Virtual address of the region in the simulated process */
 private:
   RegionType region_type_;
   StorageType storage_type_;
   simgrid::mc::ObjectInformation* object_info_;
 
   /** @brief  Virtual address of the region in the simulated process */
-  void *start_addr_;
+  voidstart_addr_;
 
   /** @brief Size of the data region in bytes */
   std::size_t size_;
 
   /** @brief Size of the data region in bytes */
   std::size_t size_;
@@ -134,28 +116,31 @@ private:
    * on the region of the global variables.
    *
    * */
    * on the region of the global variables.
    *
    * */
-  void *permanent_addr_;
+  voidpermanent_addr_;
 
   Buffer flat_data_;
   ChunkedData page_numbers_;
   std::vector<RegionSnapshot> privatized_regions_;
 
   Buffer flat_data_;
   ChunkedData page_numbers_;
   std::vector<RegionSnapshot> privatized_regions_;
+
 public:
 public:
-  RegionSnapshot() :
-    region_type_(UnknownRegion),
-    storage_type_(StorageType::NoData),
-    object_info_(nullptr),
-    start_addr_(nullptr),
-    size_(0),
-    permanent_addr_(nullptr)
-  {}
-  RegionSnapshot(RegionType type, void *start_addr, void* permanent_addr, size_t size) :
-    region_type_(type),
-    storage_type_(StorageType::NoData),
-    object_info_(nullptr),
-    start_addr_(start_addr),
-    size_(size),
-    permanent_addr_(permanent_addr)
-  {}
+  RegionSnapshot()
+      : region_type_(UnknownRegion)
+      , storage_type_(StorageType::NoData)
+      , object_info_(nullptr)
+      , start_addr_(nullptr)
+      , size_(0)
+      , permanent_addr_(nullptr)
+  {
+  }
+  RegionSnapshot(RegionType type, void* start_addr, void* permanent_addr, size_t size)
+      : region_type_(type)
+      , storage_type_(StorageType::NoData)
+      , object_info_(nullptr)
+      , start_addr_(start_addr)
+      , size_(size)
+      , permanent_addr_(permanent_addr)
+  {
+  }
   ~RegionSnapshot()                     = default;
   RegionSnapshot(RegionSnapshot const&) = default;
   RegionSnapshot& operator=(RegionSnapshot const&) = default;
   ~RegionSnapshot()                     = default;
   RegionSnapshot(RegionSnapshot const&) = default;
   RegionSnapshot& operator=(RegionSnapshot const&) = default;
@@ -174,14 +159,14 @@ public:
   }
   RegionSnapshot& operator=(RegionSnapshot&& that)
   {
   }
   RegionSnapshot& operator=(RegionSnapshot&& that)
   {
-    region_type_ = that.region_type_;
-    storage_type_ = that.storage_type_;
-    object_info_ = that.object_info_;
-    start_addr_ = that.start_addr_;
-    size_ = that.size_;
-    permanent_addr_ = that.permanent_addr_;
-    flat_data_ = std::move(that.flat_data_);
-    page_numbers_ = std::move(that.page_numbers_);
+    region_type_        = that.region_type_;
+    storage_type_       = that.storage_type_;
+    object_info_        = that.object_info_;
+    start_addr_         = that.start_addr_;
+    size_               = that.size_;
+    permanent_addr_     = that.permanent_addr_;
+    flat_data_          = std::move(that.flat_data_);
+    page_numbers_       = std::move(that.page_numbers_);
     privatized_regions_ = std::move(that.privatized_regions_);
     that.clear();
     return *this;
     privatized_regions_ = std::move(that.privatized_regions_);
     that.clear();
     return *this;
@@ -191,14 +176,14 @@ public:
 
   void clear()
   {
 
   void clear()
   {
-    region_type_ = UnknownRegion;
+    region_type_  = UnknownRegion;
     storage_type_ = StorageType::NoData;
     privatized_regions_.clear();
     page_numbers_.clear();
     flat_data_.clear();
     storage_type_ = StorageType::NoData;
     privatized_regions_.clear();
     page_numbers_.clear();
     flat_data_.clear();
-    object_info_ = nullptr;
-    start_addr_ = nullptr;
-    size_ = 0;
+    object_info_    = nullptr;
+    start_addr_     = nullptr;
+    size_           = 0;
     permanent_addr_ = nullptr;
   }
 
     permanent_addr_ = nullptr;
   }
 
@@ -213,12 +198,12 @@ public:
   void flat_data(Buffer data)
   {
     storage_type_ = StorageType::Flat;
   void flat_data(Buffer data)
   {
     storage_type_ = StorageType::Flat;
-    flat_data_ = std::move(data);
+    flat_data_    = std::move(data);
     page_numbers_.clear();
     privatized_regions_.clear();
   }
   const Buffer& flat_data() const { return flat_data_; }
     page_numbers_.clear();
     privatized_regions_.clear();
   }
   const Buffer& flat_data() const { return flat_data_; }
-  Buffer& flat_data()             { return flat_data_; }
+  Buffer& flat_data() { return flat_data_; }
 
   void page_data(ChunkedData page_data)
   {
 
   void page_data(ChunkedData page_data)
   {
@@ -236,14 +221,8 @@ public:
     page_numbers_.clear();
     privatized_regions_ = std::move(data);
   }
     page_numbers_.clear();
     privatized_regions_ = std::move(data);
   }
-  std::vector<RegionSnapshot> const& privatized_data() const
-  {
-    return privatized_regions_;
-  }
-  std::vector<RegionSnapshot>& privatized_data()
-  {
-    return privatized_regions_;
-  }
+  std::vector<RegionSnapshot> const& privatized_data() const { return privatized_regions_; }
+  std::vector<RegionSnapshot>& privatized_data() { return privatized_regions_; }
 
   simgrid::mc::ObjectInformation* object_info() const { return object_info_; }
   void object_info(simgrid::mc::ObjectInformation* info) { object_info_ = info; }
 
   simgrid::mc::ObjectInformation* object_info() const { return object_info_; }
   void object_info(simgrid::mc::ObjectInformation* info) { object_info_ = info; }
@@ -257,24 +236,16 @@ public:
   StorageType storage_type() const { return storage_type_; }
   RegionType region_type() const { return region_type_; }
 
   StorageType storage_type() const { return storage_type_; }
   RegionType region_type() const { return region_type_; }
 
-  bool contain(RemotePtr<void> p) const
-  {
-    return p >= start() && p < end();
-  }
+  bool contain(RemotePtr<void> p) const { return p >= start() && p < end(); }
 };
 
 };
 
-RegionSnapshot privatized_region(
-    RegionType region_type, void *start_addr, void* permanent_addr,
-    std::size_t size);
-RegionSnapshot dense_region(
-  RegionType type, void *start_addr, void* data_addr, std::size_t size);
-simgrid::mc::RegionSnapshot sparse_region(
-  RegionType type, void *start_addr, void* data_addr, std::size_t size);
-simgrid::mc::RegionSnapshot region(
-  RegionType type, void *start_addr, void* data_addr, std::size_t size);
-
-}
-}
+RegionSnapshot privatized_region(RegionType region_type, void* start_addr, void* permanent_addr, std::size_t size);
+RegionSnapshot dense_region(RegionType type, void* start_addr, void* data_addr, std::size_t size);
+simgrid::mc::RegionSnapshot sparse_region(RegionType type, void* start_addr, void* data_addr, std::size_t size);
+simgrid::mc::RegionSnapshot region(RegionType type, void* start_addr, void* data_addr, std::size_t size);
+
+} // namespace mc
+} // namespace simgrid
 
 typedef simgrid::mc::RegionSnapshot s_mc_mem_region_t;
 typedef s_mc_mem_region_t* mc_mem_region_t;
 
 typedef simgrid::mc::RegionSnapshot s_mc_mem_region_t;
 typedef s_mc_mem_region_t* mc_mem_region_t;