1 // =============================================================================
2 // === GPUQREngine/Include/GPUQREngine_timing.hpp ==============================
3 // =============================================================================
4 //
5 // Contains timing macros that wrap GPU timing logic, using cudaEvents.
6 //
7 // =============================================================================
8 
9 
10 #ifndef GPUQRENGINE_TIMING_HPP
11 #define GPUQRENGINE_TIMING_HPP
12 
13 #ifdef TIMING
14 
15 // create the timer
16 #define TIMER_INIT()                            \
17 cudaEvent_t start, stop ;                       \
18 cudaEventCreate(&start) ;                       \
19 cudaEventCreate(&stop) ;                        \
20 
21 // start the timer
22 #define TIMER_START()                           \
23 cudaEventRecord(start, 0);                      \
24 
25 // stop the timer and get the time since the last tic
26 // t is the time since the last TIMER_START()
27 #define TIMER_STOP(t)                           \
28 cudaEventRecord(stop, 0);                       \
29 cudaThreadSynchronize();                        \
30 cudaEventElapsedTime(&(t), start, stop);        \
31 
32 // destroy the timer
33 #define TIMER_FINISH()                          \
34 cudaEventDestroy(start);                        \
35 cudaEventDestroy(stop);                         \
36 
37 #else
38 
39 // compile with no timing
40 #define TIMER_INIT() ;
41 #define TIMER_START() ;
42 #define TIMER_STOP(t) ;
43 #define TIMER_FINISH() ;
44 
45 #endif
46 #endif
47