10 #ifndef NANOVDB_GPU_TIMER_H_HAS_BEEN_INCLUDED
11 #define NANOVDB_GPU_TIMER_H_HAS_BEEN_INCLUDED
15 #include <cuda_runtime_api.h>
22 cudaEvent_t mStart, mStop;
30 cudaEventCreate(&mStart);
31 cudaEventCreate(&mStop);
32 cudaEventRecord(mStart, mStream);
42 os << msg <<
" ... " << std::flush;
43 cudaEventCreate(&mStart);
44 cudaEventCreate(&mStop);
45 cudaEventRecord(mStart, mStream);
51 cudaEventDestroy(mStart);
52 cudaEventDestroy(mStop);
58 void start() {cudaEventRecord(mStart, mStream);}
66 os << msg <<
" ... " << std::flush;
73 void start(
const char* msg, std::ostream& os = std::cerr)
75 os << msg <<
" ... " << std::flush;
83 cudaEventRecord(mStop, mStream);
84 cudaEventSynchronize(mStop);
86 cudaEventElapsedTime(&diff, mStart, mStop);
92 void stop(std::ostream& os = std::cerr)
95 os <<
"completed in " << diff <<
" milliseconds" << std::endl;
104 this->
start(msg, os);
110 #endif // NANOVDB_GPU_TIMER_H_HAS_BEEN_INCLUDED
void start(const char *msg, std::ostream &os=std::cerr)
Start the timer.
GLsizei const GLchar *const * string
GpuTimer(cudaStream_t stream=0)
Default constructor.
void start(const std::string &msg, std::ostream &os=std::cerr)
Start the timer.
struct CUstream_st * cudaStream_t
void stop(std::ostream &os=std::cerr)
stop the timer
void restart(const std::string &msg, std::ostream &os=std::cerr)
stop and start the timer
GpuTimer(const std::string &msg, cudaStream_t stream=0, std::ostream &os=std::cerr)
Construct and start the timer.
float elapsed()
elapsed time (since start) in miliseconds
void start()
Start the timer.