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 102 : Timer::Timer() {
14 102 : this->clear();
15 102 : }
16 :
17 294 : void Timer::clear() {
18 294 : elapsed_m = 0.0;
19 294 : }
20 :
21 90 : void Timer::start() {
22 90 : start_m = std::chrono::high_resolution_clock::now();
23 90 : }
24 :
25 272 : void Timer::stop() {
26 272 : if (enableFences) {
27 544 : Kokkos::fence();
28 : }
29 272 : stop_m = std::chrono::high_resolution_clock::now();
30 :
31 272 : duration_type elapsed = stop_m - start_m;
32 :
33 272 : elapsed_m += elapsed.count();
34 272 : }
35 :
36 80 : double Timer::elapsed() {
37 80 : return elapsed_m;
38 : }
|