-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathprofiler.hpp
More file actions
67 lines (55 loc) · 1.46 KB
/
profiler.hpp
File metadata and controls
67 lines (55 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// ***********************************************************************************
// Idefix MHD astrophysical code
// Copyright(C) Geoffroy R. J. Lesur <[email protected]>
// and other code contributors
// Licensed under CeCILL 2.1 License, see COPYING for more information
// ***********************************************************************************
#ifndef PROFILER_HPP_
#define PROFILER_HPP_
#include <map>
#include <mutex> // NOLINT [build/c++11]
#include <string>
namespace idfx {
struct SpaceHandle {
char name[64];
};
// Region is a helper class to Profiler
// it used to generate a tree of the regions encountered while running
// and produce a performance report.
class Region {
public:
Region(Region *parent, std::string name, int level);
Region();
~Region();
void Start();
void Stop();
void Show(double );
Region* GetChild(std::string name);
double GetTimer();
static bool Compare(Region *, Region *);
bool isLeaf{true};
std::string name;
std::map<std::string, Region*> children;
Region *parent;
int level;
private:
Kokkos::Timer timer;
double myTime{0};
int64_t nCalls{0};
};
class Profiler {
public:
void Init();
void Show();
void EnablePerformanceProfiling();
int numSpaces;
int64_t spaceSize[16];
int64_t spaceMax[16];
char spaceName[16][64];
std::mutex m;
bool perfEnabled{false};
Region rootRegion;
Region *currentRegion;
};
}// namespace idfx
#endif // PROFILER_HPP_