NiHu  2.0
fmm_timer.h
Go to the documentation of this file.
1 
6 #ifndef NIHU_FMM_TIMER_H_INCLUDED
7 #define NIHU_FMM_TIMER_H_INCLUDED
8 
9 #include "fmm_operator.hpp"
10 #include "util/timer.h"
11 
12 #include <array>
13 #include <iostream>
14 #include <vector>
15 
16 namespace NiHu
17 {
18 namespace fmm
19 {
20 
22 class fmm_timer
23 {
24  typedef NiHu::cpu_time timer_t;
25 
26 public:
27  enum {
29  M2M = op_tags::tag2idx(op_tags::m2m()),
31  L2L = op_tags::tag2idx(op_tags::l2l()),
33  M2L = op_tags::tag2idx(op_tags::m2l()),
35  P2M = op_tags::tag2idx(op_tags::p2m()),
37  P2L = op_tags::tag2idx(op_tags::p2l()),
39  L2P = op_tags::tag2idx(op_tags::l2p()),
41  M2P = op_tags::tag2idx(op_tags::m2p()),
43  P2P = op_tags::tag2idx(op_tags::p2p()),
45  NUM_TIME_INDICES = op_tags::num_tags(),
46  } time_index_t;
47 
48 private:
49  std::vector<std::array<long long, NUM_TIME_INDICES> > m_times;
50  timer_t::time_point_t m_t0;
51 
52 public:
56  fmm_timer(size_t nLevel)
57  : m_times(nLevel)
58  {
59  }
60 
62  void reset(void)
63  {
64  for (auto &it : m_times)
65  it[M2M] = it[L2L] = it[M2L] = it[P2M] = it[P2L] = it[L2P] = it[M2P] = it[P2P] = 0;
66  }
67 
69  typename timer_t::time_point_t tic(void)
70  {
71  return m_t0 = timer_t::tic();
72  }
73 
79  void toc(size_t level, int type)
80  {
81  m_times[level][type] += (long long) (timer_t::toc(m_t0) * 1e6);
82  }
83 
88  std::ostream &print(std::ostream &os = std::cout) const;
89 
90  std::vector<std::array<long long, NUM_TIME_INDICES> > const & get_times(void) const
91  {
92  return m_times;
93  }
94 };
95 
96 } // namespace fmm
97 } // namesapce NiHu
98 
99 #endif /* NIHU_FMM_TIMER_H_INCLUDED */
NiHu::fmm::fmm_timer
class to store fmm timing data
Definition: fmm_timer.h:22
NiHu::fmm::op_tags::m2l
Definition: fmm_operator.hpp:22
fmm_operator.hpp
FMM operator types and tags.
NiHu::fmm::fmm_timer::M2L
@ M2L
index of M2L operation
Definition: fmm_timer.h:33
NiHu::fmm::fmm_timer::P2M
@ P2M
index of P2M operation
Definition: fmm_timer.h:35
NiHu::fmm::op_tags::l2p
Definition: fmm_operator.hpp:26
NiHu::fmm::fmm_timer::L2L
@ L2L
index of L2L operation
Definition: fmm_timer.h:31
NiHu::fmm::fmm_timer::fmm_timer
fmm_timer(size_t nLevel)
constructor
Definition: fmm_timer.h:56
NiHu::fmm::fmm_timer::M2M
@ M2M
index of M2M operation
Definition: fmm_timer.h:29
NiHu::cpu_time
CPU time.
Definition: timer.h:51
NiHu::fmm::fmm_timer::P2L
@ P2L
index of P2L operation
Definition: fmm_timer.h:37
NiHu::fmm::fmm_timer::P2P
@ P2P
index of P2P operation
Definition: fmm_timer.h:43
NiHu::fmm::op_tags::p2l
Definition: fmm_operator.hpp:25
NiHu::fmm::op_tags::l2l
Definition: fmm_operator.hpp:21
NiHu::fmm::fmm_timer::toc
void toc(size_t level, int type)
stop timer at a given level and operation type
Definition: fmm_timer.h:79
NiHu::fmm::fmm_timer::M2P
@ M2P
index of M2P operation
Definition: fmm_timer.h:41
timer.h
portable implementation of wall clock and cpu timers
NiHu::fmm::op_tags::p2m
Definition: fmm_operator.hpp:24
NiHu::fmm::op_tags::m2m
Definition: fmm_operator.hpp:20
NiHu::fmm::fmm_timer::print
std::ostream & print(std::ostream &os=std::cout) const
inserter into output stream
Definition: fmm_timer.cpp:17
NiHu::fmm::fmm_timer::L2P
@ L2P
index of L2P operation
Definition: fmm_timer.h:39
NiHu::fmm::fmm_timer::reset
void reset(void)
reset timer
Definition: fmm_timer.h:62
NiHu::fmm::op_tags::p2p
Definition: fmm_operator.hpp:29
NiHu::fmm::fmm_timer::tic
timer_t::time_point_t tic(void)
start timer
Definition: fmm_timer.h:69
NiHu::fmm::fmm_timer::NUM_TIME_INDICES
@ NUM_TIME_INDICES
number of time indices
Definition: fmm_timer.h:45
NiHu::fmm::op_tags::m2p
Definition: fmm_operator.hpp:27