Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
Statistics.h
Go to the documentation of this file.
1#ifndef STATISTICS_H
2#define STATISTICS_H
3
4#include <chrono>
5#include <set>
6#include <string>
7#include <vector>
8
9#include "ASLog.h"
10
11namespace Halide {
12namespace Internal {
13namespace Autoscheduler {
14
15using Clock = std::chrono::high_resolution_clock;
16
17template<typename T>
19 const T &value;
20 std::string msg;
21
22 ScopedStatistic(const T &value, const std::string &msg)
23 : value{value},
24 msg{msg} {
25 }
26
28 aslog(1) << msg << " = " << value << "\n";
29 }
30};
31
33 std::chrono::time_point<Clock> start;
34 std::string msg;
35
36 explicit ScopedTimer(const std::string &msg)
37 : start{Clock::now()},
38 msg{msg} {
39 aslog(1) << "Start: " << msg << "\n";
40 }
41
43 auto duration = Clock::now() - start;
44 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
45 aslog(1) << "Duration (ms): " << msg << " = " << ms << "\n";
46 }
47};
48
49struct Timer {
50 std::chrono::time_point<Clock> start;
51
53 : start{Clock::now()} {
54 }
55
56 void restart() {
57 start = Clock::now();
58 }
59
60 std::chrono::duration<double> elapsed() const {
61 return Clock::now() - start;
62 }
63};
64
65struct Statistics {
75 std::chrono::duration<double> generate_children_time{0};
76 std::chrono::duration<double> calculate_cost_time{0};
77 std::chrono::duration<double> enqueue_time{0};
78 std::chrono::duration<double> compute_in_tiles_time{0};
79 std::chrono::duration<double> filter_thread_tiles_time{0};
80 std::chrono::duration<double> filter_parallel_tiles_time{0};
81 std::chrono::duration<double> feature_write_time{0};
82 std::chrono::duration<double> featurization_time{0};
84 std::chrono::duration<double> cost_model_evaluation_time{0};
85
87 return std::chrono::duration_cast<std::chrono::milliseconds>(generate_children_time).count();
88 }
89
91 return std::chrono::duration_cast<std::chrono::milliseconds>(compute_in_tiles_time).count();
92 }
93
95 return std::chrono::duration_cast<std::chrono::milliseconds>(filter_thread_tiles_time).count();
96 }
97
99 return std::chrono::duration_cast<std::chrono::milliseconds>(filter_parallel_tiles_time).count();
100 }
101
103 return std::chrono::duration_cast<std::chrono::milliseconds>(feature_write_time).count();
104 }
105
107 return std::chrono::duration_cast<std::chrono::milliseconds>(calculate_cost_time).count();
108 }
109
111 return std::chrono::duration_cast<std::chrono::milliseconds>(featurization_time).count();
112 }
113
116 }
117
118 double total_enqueue_time() const {
119 return std::chrono::duration_cast<std::chrono::milliseconds>(enqueue_time).count();
120 }
121
123 return std::chrono::duration_cast<std::chrono::milliseconds>(enqueue_time + cost_model_evaluation_time).count();
124 }
125
129};
130
131} // namespace Autoscheduler
132} // namespace Internal
133} // namespace Halide
134
135#endif // STATISTICS_H
std::chrono::high_resolution_clock Clock
Definition Timer.h:15
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.
ScopedStatistic(const T &value, const std::string &msg)
Definition Statistics.h:22
std::chrono::time_point< Clock > start
Definition Timer.h:18
std::chrono::duration< double > cost_model_evaluation_time
Definition Statistics.h:84
std::chrono::duration< double > enqueue_time
Definition Statistics.h:77
std::chrono::duration< double > compute_in_tiles_time
Definition Statistics.h:78
std::chrono::duration< double > filter_parallel_tiles_time
Definition Statistics.h:80
std::chrono::duration< double > generate_children_time
Definition Statistics.h:75
std::chrono::duration< double > calculate_cost_time
Definition Statistics.h:76
std::chrono::duration< double > filter_thread_tiles_time
Definition Statistics.h:79
std::chrono::duration< double > featurization_time
Definition Statistics.h:82
std::chrono::duration< double > feature_write_time
Definition Statistics.h:81
std::chrono::time_point< Clock > start
Definition Timer.h:34
std::chrono::duration< double > elapsed() const
Definition Statistics.h:60