X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/22fc8328ec91522b667f0aa18b4870ae9460ea5c..453434d0a99cf069777049230d135478dbfe848c:/src/smpi/internals/smpi_replay.cpp diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index de586295a7..7eb9815677 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -21,6 +21,60 @@ using simgrid::s4u::Actor; +#include +// From https://stackoverflow.com/questions/7110301/generic-hash-for-tuples-in-unordered-map-unordered-set +// This is all just to make std::unordered_map work with std::tuple. If we need this in other places, +// this could go into a header file. +namespace hash_tuple{ + template + struct hash + { + size_t + operator()(TT const& tt) const + { + return std::hash()(tt); + } + }; + + template + inline void hash_combine(std::size_t& seed, T const& v) + { + seed ^= hash_tuple::hash()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + // Recursive template code derived from Matthieu M. + template ::value - 1> + struct HashValueImpl + { + static void apply(size_t& seed, Tuple const& tuple) + { + HashValueImpl::apply(seed, tuple); + hash_combine(seed, std::get(tuple)); + } + }; + + template + struct HashValueImpl + { + static void apply(size_t& seed, Tuple const& tuple) + { + hash_combine(seed, std::get<0>(tuple)); + } + }; + + template + struct hash> + { + size_t + operator()(std::tuple const& tt) const + { + size_t seed = 0; + HashValueImpl >::apply(seed, tt); + return seed; + } + }; +} + XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_replay,smpi,"Trace Replay with SMPI"); static std::unordered_map*> reqq;