Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Integrate the (WIP) hashing logic in the Snapshot object
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 7 Aug 2022 17:30:19 +0000 (19:30 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 7 Aug 2022 17:30:19 +0000 (19:30 +0200)
src/mc/mc_hash.cpp [deleted file]
src/mc/mc_hash.hpp [deleted file]
src/mc/sosp/Snapshot.cpp
src/mc/sosp/Snapshot.hpp
tools/cmake/DefinePackages.cmake

diff --git a/src/mc/mc_hash.cpp b/src/mc/mc_hash.cpp
deleted file mode 100644 (file)
index 8b667d0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (c) 2014-2022. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include <cinttypes>
-#include <cstdint>
-
-#include "xbt/log.h"
-
-#include "mc/datatypes.h"
-#include "src/mc/mc_hash.hpp"
-#include "src/mc/mc_private.hpp"
-#include "src/mc/sosp/Snapshot.hpp"
-#include <mc/mc.h>
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc, "Logging specific to mc_hash");
-
-namespace simgrid::mc {
-
-namespace {
-
-class djb_hash {
-  hash_type state_ = 5381LL;
-
-public:
-  template<class T>
-  void update(T& x)
-  {
-    state_ = (state_ << 5) + state_ + x;
-  }
-  hash_type value() const { return state_; }
-};
-
-}
-
-hash_type hash(Snapshot const& snapshot)
-{
-  XBT_DEBUG("START hash %ld", snapshot.num_state_);
-  djb_hash hash;
-  // TODO:
-  // * nb_processes
-  // * heap_bytes_used
-  // * root variables
-  // * basic stack frame information
-  // * stack frame local variables
-  XBT_DEBUG("END hash %ld", snapshot.num_state_);
-  return hash.value();
-}
-
-} // namespace simgrid::mc
diff --git a/src/mc/mc_hash.hpp b/src/mc/mc_hash.hpp
deleted file mode 100644 (file)
index 03110a7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2007-2022. The SimGrid Team. All rights reserved.          */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef SIMGRID_MC_HASH_HPP
-#define SIMGRID_MC_HASH_HPP
-
-#include "xbt/base.h"
-#include "src/mc/mc_forward.hpp"
-
-namespace simgrid::mc {
-
-using hash_type = std::uint64_t;
-
-XBT_PRIVATE hash_type hash(simgrid::mc::Snapshot const& snapshot);
-
-} // namespace simgrid::mc
-
-#endif
index eb1fca1..b36d8cd 100644 (file)
@@ -5,7 +5,6 @@
 
 #include "src/mc/sosp/Snapshot.hpp"
 #include "src/mc/mc_config.hpp"
-#include "src/mc/mc_hash.hpp"
 
 #include <cstddef> /* std::size_t */
 
@@ -211,7 +210,7 @@ Snapshot::Snapshot(long num_state, RemoteProcess* process) : AddressSpace(proces
 
   if (_sg_mc_max_visited_states > 0 || not _sg_mc_property_file.get().empty()) {
     snapshot_stacks(process);
-    hash_ = simgrid::mc::hash(*this);
+    hash_ = this->do_hash();
   }
 
   ignore_restore();
@@ -284,4 +283,26 @@ void Snapshot::restore(RemoteProcess* process) const
   process->clear_cache();
 }
 
+/* ----------- Hashing logic -------------- */
+class djb_hash {
+  hash_type state_ = 5381LL;
+
+public:
+  template <class T> void update(T& x) { state_ = (state_ << 5) + state_ + x; }
+  hash_type value() const { return state_; }
+};
+hash_type Snapshot::do_hash() const
+{
+  XBT_DEBUG("START hash %ld", num_state_);
+  djb_hash hash;
+  // TODO:
+  // * nb_processes
+  // * heap_bytes_used
+  // * root variables
+  // * basic stack frame information
+  // * stack frame local variables
+  XBT_DEBUG("END hash %ld", num_state_);
+  return hash.value();
+}
+
 } // namespace simgrid::mc
index 008334b..90af292 100644 (file)
@@ -15,9 +15,8 @@
 
 /** Ignored data
  *
- *  Some parts of the snapshot are ignored by zeroing them out: the real
- *  values is stored here.
- * */
+ *  Some parts of the snapshot are ignored by zeroing them out: the real values is stored here.
+ */
 struct s_mc_snapshot_ignored_data_t {
   void* start;
   std::vector<char> data;
@@ -56,6 +55,8 @@ using const_mc_snapshot_stack_t = const s_mc_snapshot_stack_t*;
 
 namespace simgrid::mc {
 
+using hash_type = std::uint64_t;
+
 class XBT_PRIVATE Snapshot final : public AddressSpace {
 public:
   /* Initialization */
@@ -93,6 +94,7 @@ private:
   void snapshot_stacks(RemoteProcess* process);
   void handle_ignore();
   void ignore_restore() const;
+  hash_type do_hash() const;
 };
 } // namespace simgrid::mc
 
index 7f83b4f..cf687db 100644 (file)
@@ -646,8 +646,6 @@ set(MC_SRC
   src/mc/mc_client_api.cpp
   src/mc/mc_exit.hpp
   src/mc/mc_forward.hpp
-  src/mc/mc_hash.cpp
-  src/mc/mc_hash.hpp
   src/mc/mc_private.hpp
   src/mc/mc_record.cpp
   src/mc/mc_safety.hpp