From 721f772404050467d44326bf520ff0a315bd079e Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 23 Sep 2019 10:49:42 +0200 Subject: [PATCH] MC: switch to xxhash as a (fast) hashing function. 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 | 7 +++++-- ChangeLog | 2 ++ src/mc/sosp/PageStore.cpp | 12 +++--------- tools/cmake/MakeLib.cmake | 2 ++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ed6e4c933..945f9ef3f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/ChangeLog b/ChangeLog index 0dbb14ed94..ac3848df43 100644 --- 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. diff --git a/src/mc/sosp/PageStore.cpp b/src/mc/sosp/PageStore.cpp index 6cb9b5e5d9..21a9ea21f3 100644 --- a/src/mc/sosp/PageStore.cpp +++ b/src/mc/sosp/PageStore.cpp @@ -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 // memcpy, memcmp #include @@ -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 diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index 480b93436c..ba435a6ce7 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -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 -- 2.20.1