1 #ifndef PROFILER_SRC_MOLPRO_PROFILER_TREE_REPORT_H
2 #define PROFILER_SRC_MOLPRO_PROFILER_TREE_REPORT_H
3 #ifdef MOLPRO_PROFILER_MPI
6 #include <molpro/mpi.h>
8 #include <molpro/profiler/Counter.h>
9 #include <molpro/profiler/Node.h>
10 #include <molpro/profiler/Profiler.h>
11 #include <molpro/profiler/SortBy.h>
12 #include <molpro/profiler/dotgraph.h>
44 void report(
const std::shared_ptr<Node<Counter>>& root,
const std::string& description, std::ostream& out,
57 void report(
const Profiler& prof, std::ostream& out, MPI_Comm communicator,
bool cumulative =
true,
62 std::string
get_dotgraph(
const Profiler& prof, MPI_Comm communicator,
int root_process,
int* hot,
int* cool,
63 double threshold,
bool get_percentage_time);
65 std::string
get_dotgraph(
const Profiler& prof,
int hot[3],
int cool[3],
double threshold,
bool get_percentage_time);
89 template <
class CompareTreePaths>
95 std::list<std::string>
path;
107 template <
class AccessParameter>
111 bool parameter_check = AccessParameter{}(l) > AccessParameter{}(r);
112 bool result = depth_check ? depth_check : parameter_check;
114 if (l.
depth == r.
depth && AccessParameter{}(l) == AccessParameter{}(r)) {
146 std::string format_path_cumulative(
const std::list<std::string>& path);
156 std::string format_path_not_cumulative(
const std::list<std::string>& path);
171 template <
class CompareTreePaths>
172 std::map<TreePath, std::shared_ptr<Node<Counter>>, CompareTreePaths> sort_children(
173 const std::shared_ptr<
Node<Counter>>& root,
bool cumulative);
184 void format_paths(std::list<std::string>& path_names,
bool append);
192 std::string frequency(
size_t n_op,
double time);
194 std::string seconds(
double time);
196 void write_timing(std::ostream& out,
double time,
size_t n_op);
199 void write_report(
const Node<Counter>& root,
const std::string& description,
const std::list<TreePath>& paths,
200 std::ostream& out,
bool cumulative);
202 #ifdef MOLPRO_PROFILER_MPI
220 std::shared_ptr<Node<Counter>> synchronised_tree(
const std::shared_ptr<
Node<Counter>>& node,
224 void reduce_all(
long long int& operation_count,
double& wall_time,
double& cpu_time, MPI_Comm comm);
225 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
Instrumental profiler for timing sections of code.
Definition: Profiler.h:42
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:158
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
std::string get_dotgraph(const Profiler &prof, MPI_Comm communicator, int root_process, int *hot, int *cool, double threshold, bool get_percentage_time)
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
void report_root_process(const Profiler &prof, std::ostream &out, MPI_Comm communicator, int root_process, bool cumulative=true, SortBy sort_by=SortBy::wall)
Reports collective content of Profiler but writing on the root process only.
SortBy
Definition: SortBy.h:7
profiler::Profiler Profiler
Definition: Profiler.h:6
double operator()(const TreePath &t)
Definition: report.h:125
double operator()(const TreePath &t)
Definition: report.h:128
double operator()(const TreePath &t)
Definition: report.h:131
double operator()(const TreePath &t)
Definition: report.h:122
bool operator()(const TreePath &l, const TreePath &r) const
Definition: report.h:109
double operator()()
Definition: report.h:135
double operator()(const TreePath &t)
Definition: report.h:134
Utility for storing a node as a path from root to that node and corresponding Counter.
Definition: report.h:69
size_t depth
depth of the node (root is 0)
Definition: report.h:96
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:94
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:95