Line data Source code
1 : //
2 : // Class Timer
3 : // This class is used in IpplTimings.
4 : //
5 : //
6 : //
7 : #include "Kokkos_Core.hpp"
8 :
9 : #include "Timer.h"
10 :
11 : bool Timer::enableFences = IPPL_ENABLE_TIMER_FENCES;
12 :
13 134 : Timer::Timer() {
14 134 : this->clear();
15 134 : }
16 :
17 7532 : void Timer::clear() {
18 7532 : elapsed_m = 0.0;
19 7532 : }
20 :
21 7264 : void Timer::start() {
22 7264 : start_m = std::chrono::high_resolution_clock::now();
23 7264 : }
24 :
25 14662 : void Timer::stop() {
26 14662 : if (enableFences) {
27 29324 : Kokkos::fence();
28 : }
29 14662 : stop_m = std::chrono::high_resolution_clock::now();
30 :
31 14662 : duration_type elapsed = stop_m - start_m;
32 :
33 14662 : elapsed_m += elapsed.count();
34 14662 : }
35 :
36 7264 : double Timer::elapsed() {
37 7264 : return elapsed_m;
38 : }
|