1 #ifndef PROFILER_SRC_MOLPRO_PROFILER_TREE_REPORT_H
2 #define PROFILER_SRC_MOLPRO_PROFILER_TREE_REPORT_H
3 #ifdef MOLPRO_PROFILER_MPI
7 #include <molpro/profiler/Counter.h>
8 #include <molpro/profiler/Node.h>
9 #include <molpro/profiler/Profiler.h>
10 #include <molpro/profiler/SortBy.h>
11 #include <molpro/profiler/dotgraph.h>
43 void report(
const std::shared_ptr<Node<Counter>>& root,
const std::string& description, std::ostream& out,
55 #ifdef MOLPRO_PROFILER_MPI
56 void report(
const Profiler& prof, std::ostream& out, MPI_Comm communicator,
bool cumulative =
true,
59 void report_root_process(
const Profiler& prof, std::ostream& out, MPI_Comm communicator,
int root_process,
61 std::string
get_dotgraph(
const Profiler& prof, MPI_Comm communicator,
int root_process,
int* hot,
int* cool,
62 double threshold,
bool get_percentage_time);
64 std::string
get_dotgraph(
const Profiler& prof,
int hot[3],
int cool[3],
double threshold,
bool get_percentage_time);
88 template <
class CompareTreePaths>
94 std::list<std::string>
path;
106 template <
class AccessParameter>
110 bool parameter_check = AccessParameter{}(l) > AccessParameter{}(r);
111 bool result = depth_check ? depth_check : parameter_check;
113 if (l.
depth == r.
depth && AccessParameter{}(l) == AccessParameter{}(r)) {
145 std::string format_path_cumulative(
const std::list<std::string>& path);
155 std::string format_path_not_cumulative(
const std::list<std::string>& path);
170 template <
class CompareTreePaths>
171 std::map<TreePath, std::shared_ptr<Node<Counter>>, CompareTreePaths> sort_children(
172 const std::shared_ptr<
Node<Counter>>& root,
bool cumulative);
183 void format_paths(std::list<std::string>& path_names,
bool append);
191 std::string frequency(
size_t n_op,
double time);
193 std::string seconds(
double time);
195 void write_timing(std::ostream& out,
double time,
size_t n_op);
198 void write_report(
const Node<Counter>& root,
const std::string& description,
const std::list<TreePath>& paths,
199 std::ostream& out,
bool cumulative);
201 #ifdef MOLPRO_PROFILER_MPI
219 std::shared_ptr<Node<Counter>> synchronised_tree(
const std::shared_ptr<
Node<Counter>>& node,
223 void reduce_all(
long long int& operation_count,
double& wall_time,
double& cpu_time, MPI_Comm comm);
224 void reduce_root_only(
long long int& operation_count,
double& wall_time,
double& cpu_time, MPI_Comm comm,
Resource counter used for storing operation count, call count, timing information.
Definition: Counter.h:15
size_t get_operation_count() const
Definition: Counter.h:40
const Timer & get_cpu() const
Definition: Counter.h:41
size_t get_call_count() const
Definition: Counter.h:39
const Timer & get_wall() const
Definition: Counter.h:42
A node in a parameter tree storing a Counter object aliased by a name.
Definition: Node.h:20
double cumulative_time() const
Cumulative time over all start/stop periods. If active than it includes the time from start to curren...
Definition: Timer.cpp:42
std::string format_path_cumulative(const std::list< std::string > &path)
convert path to a formatted string
Definition: report.cpp:53
std::string format_single_path(const std::list< std::string > &path, bool cumulative)
Definition: report.h:157
std::string format_path_not_cumulative(const std::list< std::string > &path)
convert path to a formatted string
Definition: report.cpp:62
size_t total_operation_count(const std::shared_ptr< Node< Counter >> &node)
Performs depth first search through the tree and accumulates operation counter value.
Definition: report.cpp:43
std::list< std::string > path_to_node(std::shared_ptr< Node< Counter >> node)
Returns path of node names from root to node.
Definition: report.cpp:34
void report(const std::shared_ptr< Node< Counter >> &root, const std::string &description, std::ostream &out, bool cumulative=true, SortBy sort_by=SortBy::wall)
Reports the content of a Profiler call subtree.
Definition: report.cpp:209
std::string get_dotgraph(const Profiler &prof, int hot[3], int cool[3], double threshold, bool get_percentage_time)
Definition: report.cpp:313
SortBy
Definition: SortBy.h:7
profiler::Profiler Profiler
Definition: Profiler.h:6
double operator()(const TreePath &t)
Definition: report.h:124
double operator()(const TreePath &t)
Definition: report.h:127
double operator()(const TreePath &t)
Definition: report.h:130
double operator()(const TreePath &t)
Definition: report.h:121
bool operator()(const TreePath &l, const TreePath &r) const
Definition: report.h:108
double operator()()
Definition: report.h:134
double operator()(const TreePath &t)
Definition: report.h:133
Utility for storing a node as a path from root to that node and corresponding Counter.
Definition: report.h:68
size_t depth
depth of the node (root is 0)
Definition: report.h:95
static std::list< TreePath > convert_tree_to_paths(const std::shared_ptr< Node< Counter >> &root, bool cumulative, SortBy sort_by)
Performs Depth-First-Search and converts the whole tree to a list of TreePath objects.
Definition: report.cpp:94
Counter counter
copy of the counter object with cumulative effects or lack of them already accounted
Definition: report.h:93
TreePath(std::shared_ptr< Node< Counter >> node, bool cumulative)
Processes path from root nodes into list of strings and copies Counter accounting for cumulative effe...
Definition: report.cpp:14
std::list< std::string > path
concatenation of names from root to the node
Definition: report.h:94