Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
mc: create RegionSparse, RegionDense and RegionPrivatized (WIP)
[simgrid.git] / src / mc / mc_hash.cpp
1 /* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <cinttypes>
7
8 #include <cstdint>
9
10 #include "xbt/log.h"
11
12 #include "mc/datatypes.h"
13 #include "src/mc/mc_hash.hpp"
14 #include "src/mc/mc_private.hpp"
15 #include "src/mc/sosp/mc_snapshot.hpp"
16 #include <mc/mc.h>
17
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_hash, mc, "Logging specific to mc_hash");
19
20 namespace simgrid {
21 namespace mc {
22
23 namespace {
24
25 class djb_hash {
26   hash_type state_ = 5381LL;
27
28 public:
29   template<class T>
30   void update(T& x)
31   {
32     state_ = (state_ << 5) + state_ + x;
33   }
34   hash_type value()
35   {
36     return state_;
37   }
38 };
39
40 }
41
42 hash_type hash(Snapshot const& snapshot)
43 {
44   XBT_DEBUG("START hash %i", snapshot.num_state_);
45   djb_hash hash;
46   // TODO:
47   // * nb_processes
48   // * heap_bytes_used
49   // * root variables
50   // * basic stack frame information
51   // * stack frame local variables
52   XBT_DEBUG("END hash %i", snapshot.num_state_);
53   return hash.value();
54 }
55
56 }
57 }