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