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