38 template <target_system system>
55 fprintf(stderr,
"ERROR: inconsistent timer state\n");
67 fprintf(stderr,
"ERROR: inconsistent timer state\n");
71 struct timeval stop_event, res;
73 gettimeofday(&stop_event, NULL);
117 fprintf(stderr,
"ERROR: inconsistent timer state\n");
123 err = cudaEventCreate(&active_sample.start);
124 if (err != cudaSuccess)
126 fprintf(stderr,
"ERROR: cudaEventCreate failed (%d): %s\n", err, cudaGetErrorName(err));
130 err = cudaEventCreate(&active_sample.end);
131 if (err != cudaSuccess)
133 fprintf(stderr,
"ERROR: cudaEventCreate failed (%d): %s\n", err, cudaGetErrorName(err));
137 err = cudaEventRecord(active_sample.start);
138 if (err != cudaSuccess)
140 fprintf(stderr,
"ERROR: start: cudaEventRecord failed (%d): %s\n", err, cudaGetErrorName(err));
151 fprintf(stderr,
"ERROR: inconsistent timer state\n");
156 err = cudaEventRecord(active_sample.end);
157 if (err != cudaSuccess)
159 fprintf(stderr,
"ERROR: stop: cudaEventRecord failed (%d): %s\n", err, cudaGetErrorName(err));
163 retired_events.push(active_sample);
170 while(!retired_events.empty())
174 sample_type sample = retired_events.top();
175 retired_events.pop();
177 cudaEventSynchronize(sample.end);
178 cudaEventElapsedTime(&ms, sample.start, sample.end);
181 cudaEventDestroy(sample.start);
182 cudaEventDestroy(sample.end);
208 template <
typename Timer>
time_series & operator+=(const time_series &other)
std::stack< sample_type > retired_events
struct timeval start_event
sample_type active_sample