Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
printer.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <atomic>
19 #include <iostream>
20 #include <mutex>
21 #include <thread>
22 
23 #include <glog/logging.h>
24 
25 #include "tc/core/rtc.h" // for Duration
26 
27 namespace tc {
28 namespace autotune {
29 
33 class Printer {
34  public:
35  Printer(
36  size_t generation,
37  size_t total,
38  const std::atomic_size_t& currentCompilationJob,
39  const std::atomic_size_t& numEvaluations);
40  ~Printer();
41 
42  void record(Duration runtime);
43  void stop();
44 
45  void printAll();
46 
47  private:
48  void printLoop();
49 
50  size_t generation_;
51  std::vector<Duration> runtimes_;
52  mutable std::mutex runtimesMtx_;
53 
54  std::atomic_bool stopPrinting_{false};
55  std::thread printerThread_;
56 
57  const size_t total_;
58  const std::atomic_size_t& currentCompilationJob_;
59  const std::atomic_size_t& numEvaluations_;
60 };
61 
62 } // namespace autotune
63 } // namespace tc
Definition: printer.h:33
std::vector< Duration > runtimes_
Definition: printer.h:51
size_t generation_
Definition: printer.h:50
std::thread printerThread_
Definition: printer.h:55
void record(Duration runtime)
Printer(size_t generation, size_t total, const std::atomic_size_t &currentCompilationJob, const std::atomic_size_t &numEvaluations)
const std::atomic_size_t & currentCompilationJob_
Definition: printer.h:58
std::mutex runtimesMtx_
Definition: printer.h:52
const std::atomic_size_t & numEvaluations_
Definition: printer.h:59
std::atomic_bool stopPrinting_
Definition: printer.h:54
const size_t total_
Definition: printer.h:57
std::chrono::high_resolution_clock::duration Duration
Definition: parameters.h:223