25#ifndef __CUDA_TIMER_HPP__
26#define __CUDA_TIMER_HPP__
39 std::map<std::string, std::vector<float> > cuda_timers_;
43 void add_measurment(std::string
const& label,
float value)
45 cuda_timers_[label].push_back(value / 1000);
51 std::printf(
"CUDA timers \n");
52 for (
int i = 0; i < 115; i++) std::printf(
"-");
54 std::printf(
"name count total min max average\n");
55 for (
int i = 0; i < 115; i++) std::printf(
"-");
58 std::map<std::string, std::vector<float> >::iterator it;
59 for (it = cuda_timers_.begin(); it != cuda_timers_.end(); it++) {
60 int count = (int)it->second.size();
64 for (
int i = 0; i < count; i++) {
65 total += it->second[i];
66 minval = std::min(minval, it->second[i]);
67 maxval = std::max(maxval, it->second[i]);
69 double average = (count == 0) ? 0.0 : total / count;
74 std::printf(
"%-60s : %5i %10.4f %10.4f %10.4f %10.4f\n", it->first.c_str(), count, total, minval, maxval, average);
90 cudaEventCreate(&e_start_);
91 cudaEventCreate(&e_stop_);
92 cudaEventRecord(e_start_, 0);
98 cudaEventRecord(e_stop_, 0);
99 cudaEventSynchronize(e_stop_);
100 cudaEventElapsedTime(&time, e_start_, e_stop_);
101 cudaEventDestroy(e_start_);
102 cudaEventDestroy(e_stop_);
103 cuda_timers_wrapper().add_measurment(label_, time);
109 CUDA_timer(std::string
const& label__) : label_(label__), active_(
false)
122 return cuda_timers_wrapper_;
Namespace of the SIRIUS library.