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