Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: switch to xxhash as a (fast) hashing function.
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 23 Sep 2019 08:49:42 +0000 (10:49 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Mon, 23 Sep 2019 08:49:47 +0000 (10:49 +0200)
Mandates C++14 but should be faster according to
https://aras-p.info/blog/2016/08/02/Hash-Functions-all-the-way-down/

CMakeLists.txt
ChangeLog
src/mc/sosp/PageStore.cpp
tools/cmake/MakeLib.cmake

index 2ed6e4c..945f9ef 100644 (file)
@@ -411,6 +411,11 @@ if (enable_model-checking AND enable_ns3)
   message(FATAL_ERROR "Cannot activate both model-checking and ns-3 bindings: ns-3 pull too much dependencies for the MC to work")
 endif()
 
+get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+if (enable_model-checking AND (NOT ("cxx_std_14" IN_LIST known_features)))
+  message(FATAL_ERROR "Model-checking requires C++14. Please upgrade your compiler")
+endif()
+
 if(enable_smpi)
   SET(HAVE_SMPI 1)
   if(NOT WIN32)
@@ -777,8 +782,6 @@ endif()
 ################
 # Our usage of pybind11::overload_cast mandates C++14
 if((NOT DEFINED enable_python) OR enable_python)
-  get_property(known_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
-
   if("cxx_std_14" IN_LIST known_features)
 
     if(EXISTS ${CMAKE_HOME_DIRECTORY}/pybind11) # Try to use a local copy of pybind11, if any
index 0dbb14e..ac3848d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -35,6 +35,8 @@ SMPI:
    MPI_ERRORS_ARE_FATAL, so codes which were sending warnings may start failing.
 
 Model-Checker:
+ - Bump our requirements to C++14 for the model-checker. This is
+   because of xxHash that we now use as a hash implementation.
  - Option model-checker/hash was removed. This is always activated now.
  - New option smpi/buffering controls the MPI buffering in MC mode.
  - MPI calls now MC_assert() that no MPI_ERR_* code is returned. 
index 6cb9b5e..21a9ea2 100644 (file)
@@ -12,8 +12,9 @@
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
 
-#include "src/mc/sosp/PageStore.hpp"
+#include "src/include/xxhash.hpp"
 #include "src/mc/mc_mmu.hpp"
+#include "src/mc/sosp/PageStore.hpp"
 
 #include <cstring> // memcpy, memcmp
 #include <unistd.h>
@@ -33,14 +34,7 @@ namespace mc {
  */
 static XBT_ALWAYS_INLINE PageStore::hash_type mc_hash_page(const void* data)
 {
-  const std::uint64_t* values = (const uint64_t*)data;
-  std::size_t n               = xbt_pagesize / sizeof(uint64_t);
-
-  // This djb2:
-  std::uint64_t hash = 5381;
-  for (std::size_t i = 0; i != n; ++i)
-    hash = ((hash << 5) + hash) + values[i];
-  return hash;
+  return xxh::xxhash<64>(data, xbt_pagesize);
 }
 
 // ***** snapshot_page_manager
index 480b934..ba435a6 100644 (file)
@@ -27,6 +27,8 @@ set_property(TARGET simgrid
 add_dependencies(simgrid maintainer_files)
 
 if(enable_model-checking)
+  set_property(TARGET simgrid PROPERTY CXX_STANDARD 14)
+
   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
   target_link_libraries(simgrid-mc simgrid)
   set_target_properties(simgrid-mc