Itoyori  v0.0.1
home_profiler.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ityr/common/util.hpp"
6 #include "ityr/ori/util.hpp"
7 #include "ityr/ori/options.hpp"
8 
9 namespace ityr::ori {
10 
12 public:
14  void record(std::size_t, bool) {}
15  void record(std::byte*, std::size_t, std::byte*, std::size_t, bool) {}
16  void start() {}
17  void stop() {}
18  void print() const {}
19 };
20 
22 public:
24 
25  void record(std::size_t bytes, bool hit) {
26  if (enabled_) {
27  requested_bytes_ += bytes;
28  if (hit) {
29  seg_hit_count_++;
30  } else {
31  seg_miss_count_++;
32  }
33  }
34  }
35 
36  void record(std::byte* seg_addr, std::size_t seg_size,
37  std::byte* req_addr, std::size_t req_size, bool hit) {
38  std::byte* addr_b = std::max(seg_addr, reinterpret_cast<std::byte*>(req_addr));
39  std::byte* addr_e = std::min(seg_addr + seg_size, reinterpret_cast<std::byte*>(req_addr) + req_size);
40  record(addr_e - addr_b, hit);
41  }
42 
43  void start() {
44  requested_bytes_ = 0;
45  seg_hit_count_ = 0;
46  seg_miss_count_ = 0;
47 
48  enabled_ = true;
49  }
50 
51  void stop() {
52  enabled_ = false;
53  }
54 
55  void print() const {
56  auto requested_bytes_all = common::mpi_reduce_value(requested_bytes_, 0, common::topology::mpicomm());
57  auto seg_hit_count_all = common::mpi_reduce_value(seg_hit_count_ , 0, common::topology::mpicomm());
58  auto seg_miss_count_all = common::mpi_reduce_value(seg_miss_count_ , 0, common::topology::mpicomm());
59 
60  if (common::topology::my_rank() == 0) {
61  printf("[Home segments]\n");
62  printf(" User requested: %18ld bytes\n" , requested_bytes_all);
63  printf(" mmap hit count: %18ld segments\n", seg_hit_count_all);
64  printf(" mmap miss count: %18ld segments\n", seg_miss_count_all);
65  printf("\n");
66  fflush(stdout);
67  }
68  }
69 
70 private:
71  std::size_t requested_bytes_ = 0;
72  std::size_t seg_hit_count_ = 0;
73  std::size_t seg_miss_count_ = 0;
74  bool enabled_ = false;
75 };
76 
78 
79 }
Definition: home_profiler.hpp:11
void record(std::size_t, bool)
Definition: home_profiler.hpp:14
void print() const
Definition: home_profiler.hpp:18
void record(std::byte *, std::size_t, std::byte *, std::size_t, bool)
Definition: home_profiler.hpp:15
void start()
Definition: home_profiler.hpp:16
void stop()
Definition: home_profiler.hpp:17
home_profiler_disabled()
Definition: home_profiler.hpp:13
Definition: home_profiler.hpp:21
void record(std::byte *seg_addr, std::size_t seg_size, std::byte *req_addr, std::size_t req_size, bool hit)
Definition: home_profiler.hpp:36
void start()
Definition: home_profiler.hpp:43
void print() const
Definition: home_profiler.hpp:55
home_profiler_stats()
Definition: home_profiler.hpp:23
void stop()
Definition: home_profiler.hpp:51
void record(std::size_t bytes, bool hit)
Definition: home_profiler.hpp:25
#define ITYR_CONCAT(x, y)
Definition: util.hpp:20
MPI_Comm mpicomm()
Definition: topology.hpp:206
rank_t my_rank()
Definition: topology.hpp:207
fflush(stderr)
T mpi_reduce_value(const T &value, int root_rank, MPI_Comm comm, MPI_Op op=MPI_SUM)
Definition: mpi_util.hpp:170
Definition: block_region_set.hpp:9
ITYR_CONCAT(home_profiler_, ITYR_ORI_CACHE_PROF) home_profiler
Definition: home_profiler.hpp:77
monoid< T, min_functor<>, highest< T > > min
Definition: reducer.hpp:101
monoid< T, max_functor<>, lowest< T > > max
Definition: reducer.hpp:104
#define ITYR_ORI_CACHE_PROF