Loading...
Searching...
No Matches
Statistics.h
Go to the documentation of this file.
#ifndef STATISTICS_H
#define STATISTICS_H
#include <chrono>
#include <set>
#include <string>
#include <vector>
#include "ASLog.h"
namespace Halide {
namespace Internal {
namespace Autoscheduler {
using Clock = std::chrono::high_resolution_clock;
template<typename T>
struct ScopedStatistic {
const T &value;
std::string msg;
ScopedStatistic(const T &value, const std::string &msg)
: value{value},
msg{msg} {
}
~ScopedStatistic() {
aslog(1) << msg << " = " << value << "\n";
}
};
struct ScopedTimer {
std::chrono::time_point<Clock> start;
std::string msg;
explicit ScopedTimer(const std::string &msg)
: start{Clock::now()},
msg{msg} {
aslog(1) << "Start: " << msg << "\n";
}
~ScopedTimer() {
auto duration = Clock::now() - start;
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
aslog(1) << "Duration (ms): " << msg << " = " << ms << "\n";
}
};
struct Timer {
std::chrono::time_point<Clock> start;
Timer()
: start{Clock::now()} {
}
void restart() {
start = Clock::now();
}
std::chrono::duration<double> elapsed() const {
return Clock::now() - start;
}
};
struct Statistics {
int num_featurizations{0};
int num_states_added{0};
int num_block_memoization_hits{0};
int num_block_memoization_misses{0};
int num_memoized_featurizations{0};
int num_memoization_hits{0};
int num_memoization_misses{0};
int num_tilings_accepted{0};
int num_tilings_generated{0};
std::chrono::duration<double> generate_children_time{0};
std::chrono::duration<double> calculate_cost_time{0};
std::chrono::duration<double> enqueue_time{0};
std::chrono::duration<double> compute_in_tiles_time{0};
std::chrono::duration<double> filter_thread_tiles_time{0};
std::chrono::duration<double> filter_parallel_tiles_time{0};
std::chrono::duration<double> feature_write_time{0};
std::chrono::duration<double> featurization_time{0};
int num_schedules_enqueued{0};
std::chrono::duration<double> cost_model_evaluation_time{0};
double total_generate_children_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(generate_children_time).count();
}
double total_compute_in_tiles_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(compute_in_tiles_time).count();
}
double total_filter_thread_tiles_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(filter_thread_tiles_time).count();
}
double total_filter_parallel_tiles_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(filter_parallel_tiles_time).count();
}
double total_feature_write_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(feature_write_time).count();
}
double total_calculate_cost_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(calculate_cost_time).count();
}
double total_featurization_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(featurization_time).count();
}
double average_featurization_time() const {
return total_featurization_time() / (double)num_featurizations;
}
double total_enqueue_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(enqueue_time).count();
}
double total_cost_model_evaluation_time() const {
return std::chrono::duration_cast<std::chrono::milliseconds>(enqueue_time + cost_model_evaluation_time).count();
}
double average_cost_model_evaluation_time() const {
return total_cost_model_evaluation_time() / (double)num_schedules_enqueued;
}
};
} // namespace Autoscheduler
} // namespace Internal
} // namespace Halide
#endif // STATISTICS_H
ASLog.h
Halide::Internal::aslog
Definition ASLog.h:16
Halide::Internal::Autoscheduler
Definition AutoSchedule.h:10
Halide::Internal::Autoscheduler::Clock
std::chrono::high_resolution_clock Clock
Definition Timer.h:15
Halide::Internal
Definition AbstractGenerator.h:24
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition AbstractGenerator.h:19
Halide::Internal::Autoscheduler::ScopedStatistic::~ScopedStatistic
~ScopedStatistic()
Definition Statistics.h:27
Halide::Internal::Autoscheduler::ScopedStatistic::msg
std::string msg
Definition Statistics.h:20
Halide::Internal::Autoscheduler::ScopedStatistic::ScopedStatistic
ScopedStatistic(const T &value, const std::string &msg)
Definition Statistics.h:22
Halide::Internal::Autoscheduler::ScopedStatistic::value
const T & value
Definition Statistics.h:19
Halide::Internal::Autoscheduler::ScopedTimer::ScopedTimer
ScopedTimer(const std::string &msg)
Definition Statistics.h:36
Halide::Internal::Autoscheduler::ScopedTimer::msg
std::string msg
Definition Timer.h:19
Halide::Internal::Autoscheduler::ScopedTimer::start
std::chrono::time_point< Clock > start
Definition Timer.h:18
Halide::Internal::Autoscheduler::ScopedTimer::~ScopedTimer
~ScopedTimer()
Definition Statistics.h:42
Halide::Internal::Autoscheduler::Statistics
Definition Statistics.h:65
Halide::Internal::Autoscheduler::Statistics::average_cost_model_evaluation_time
double average_cost_model_evaluation_time() const
Definition Statistics.h:126
Halide::Internal::Autoscheduler::Statistics::cost_model_evaluation_time
std::chrono::duration< double > cost_model_evaluation_time
Definition Statistics.h:84
Halide::Internal::Autoscheduler::Statistics::num_block_memoization_hits
int num_block_memoization_hits
Definition Statistics.h:68
Halide::Internal::Autoscheduler::Statistics::num_states_added
int num_states_added
Definition Statistics.h:67
Halide::Internal::Autoscheduler::Statistics::enqueue_time
std::chrono::duration< double > enqueue_time
Definition Statistics.h:77
Halide::Internal::Autoscheduler::Statistics::num_tilings_generated
int num_tilings_generated
Definition Statistics.h:74
Halide::Internal::Autoscheduler::Statistics::compute_in_tiles_time
std::chrono::duration< double > compute_in_tiles_time
Definition Statistics.h:78
Halide::Internal::Autoscheduler::Statistics::total_filter_thread_tiles_time
double total_filter_thread_tiles_time() const
Definition Statistics.h:94
Halide::Internal::Autoscheduler::Statistics::num_memoized_featurizations
int num_memoized_featurizations
Definition Statistics.h:70
Halide::Internal::Autoscheduler::Statistics::filter_parallel_tiles_time
std::chrono::duration< double > filter_parallel_tiles_time
Definition Statistics.h:80
Halide::Internal::Autoscheduler::Statistics::total_calculate_cost_time
double total_calculate_cost_time() const
Definition Statistics.h:106
Halide::Internal::Autoscheduler::Statistics::total_generate_children_time
double total_generate_children_time() const
Definition Statistics.h:86
Halide::Internal::Autoscheduler::Statistics::average_featurization_time
double average_featurization_time() const
Definition Statistics.h:114
Halide::Internal::Autoscheduler::Statistics::total_enqueue_time
double total_enqueue_time() const
Definition Statistics.h:118
Halide::Internal::Autoscheduler::Statistics::generate_children_time
std::chrono::duration< double > generate_children_time
Definition Statistics.h:75
Halide::Internal::Autoscheduler::Statistics::num_block_memoization_misses
int num_block_memoization_misses
Definition Statistics.h:69
Halide::Internal::Autoscheduler::Statistics::calculate_cost_time
std::chrono::duration< double > calculate_cost_time
Definition Statistics.h:76
Halide::Internal::Autoscheduler::Statistics::num_memoization_misses
int num_memoization_misses
Definition Statistics.h:72
Halide::Internal::Autoscheduler::Statistics::num_memoization_hits
int num_memoization_hits
Definition Statistics.h:71
Halide::Internal::Autoscheduler::Statistics::total_compute_in_tiles_time
double total_compute_in_tiles_time() const
Definition Statistics.h:90
Halide::Internal::Autoscheduler::Statistics::filter_thread_tiles_time
std::chrono::duration< double > filter_thread_tiles_time
Definition Statistics.h:79
Halide::Internal::Autoscheduler::Statistics::num_tilings_accepted
int num_tilings_accepted
Definition Statistics.h:73
Halide::Internal::Autoscheduler::Statistics::total_cost_model_evaluation_time
double total_cost_model_evaluation_time() const
Definition Statistics.h:122
Halide::Internal::Autoscheduler::Statistics::num_featurizations
int num_featurizations
Definition Statistics.h:66
Halide::Internal::Autoscheduler::Statistics::featurization_time
std::chrono::duration< double > featurization_time
Definition Statistics.h:82
Halide::Internal::Autoscheduler::Statistics::total_featurization_time
double total_featurization_time() const
Definition Statistics.h:110
Halide::Internal::Autoscheduler::Statistics::total_filter_parallel_tiles_time
double total_filter_parallel_tiles_time() const
Definition Statistics.h:98
Halide::Internal::Autoscheduler::Statistics::num_schedules_enqueued
int num_schedules_enqueued
Definition Statistics.h:83
Halide::Internal::Autoscheduler::Statistics::feature_write_time
std::chrono::duration< double > feature_write_time
Definition Statistics.h:81
Halide::Internal::Autoscheduler::Statistics::total_feature_write_time
double total_feature_write_time() const
Definition Statistics.h:102
Halide::Internal::Autoscheduler::Timer::Timer
Timer()
Definition Statistics.h:52
Halide::Internal::Autoscheduler::Timer::restart
void restart()
Definition Statistics.h:56
Halide::Internal::Autoscheduler::Timer::start
std::chrono::time_point< Clock > start
Definition Timer.h:34
Halide::Internal::Autoscheduler::Timer::elapsed
std::chrono::duration< double > elapsed() const
Definition Statistics.h:60