imate
C++/CUDA Reference
Loading...
Searching...
No Matches
cuda_timer.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3 * SPDX-License-Identifier: BSD-3-Clause
4 * SPDX-FileType: SOURCE
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the license found in the LICENSE.txt file in the root
8 * directory of this source tree.
9 */
10
11
12#ifndef _CUDA_UTILITIES_CUDA_TIMER_H_
13#define _CUDA_UTILITIES_CUDA_TIMER_H_
14
15
16// =======
17// Headers
18// =======
19
20#include <cuda_runtime_api.h> // cudaEvent_t, cudaEventCreate,
21 // cudaEventDestropy, cudaEventRecord,
22 // cudaEventSynchronize, cudaEventElapsedTime
23
24
25// ==========
26// Cuda Timer
27// ==========
28
60
62{
63 public:
64
65 CudaTimer();
66 ~CudaTimer();
67 void start();
68 void stop();
69 float elapsed() const;
70
71 protected:
72 cudaEvent_t start_time;
73 cudaEvent_t stop_time;
74};
75
76#endif // _CUDA_UTILITIES_CUDA_TIMER_H_
Records elasped time between two CUDA events.
Definition cuda_timer.h:62
~CudaTimer()
Destructor for CudaTimer.
Definition cuda_timer.cu:40
void stop()
Stops the timer.
Definition cuda_timer.cu:67
void start()
Starts the timer.
Definition cuda_timer.cu:54
cudaEvent_t stop_time
Definition cuda_timer.h:73
float elapsed() const
Returns the elapsed time in seconds.
Definition cuda_timer.cu:80
CudaTimer()
constructor for CudaTimer
Definition cuda_timer.cu:26
cudaEvent_t start_time
Definition cuda_timer.h:72