Zip and Skip Tries
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CudaTimer Class Reference

A simple CUDA timer class using CUDA events. More...

Public Member Functions

 CudaTimer ()
 Constructs the CudaTimer and creates CUDA events.
 
 ~CudaTimer ()
 Destroys the CUDA events.
 
void start_timer ()
 Records the start event in the default CUDA stream.
 
float stop_timer ()
 Records the stop event, synchronizes, and calculates elapsed time.
 

Private Attributes

cudaEvent_t start
 
cudaEvent_t stop
 CUDA events to mark start and stop points.
 
float time
 Stores the calculated elapsed time in milliseconds.
 

Detailed Description

A simple CUDA timer class using CUDA events.

Measures the execution time of CUDA operations between calls to start_timer() and stop_timer().

Definition at line 132 of file cuda_utils.cuh.

Constructor & Destructor Documentation

◆ CudaTimer()

CudaTimer::CudaTimer ( )
inline

Constructs the CudaTimer and creates CUDA events.

Definition at line 138 of file cuda_utils.cuh.

139 {
142 }
cudaEvent_t start
cudaEvent_t stop
CUDA events to mark start and stop points.
T * alloc_to_device(size_t size)
Allocates memory on the CUDA device.

◆ ~CudaTimer()

CudaTimer::~CudaTimer ( )
inline

Destroys the CUDA events.

Definition at line 147 of file cuda_utils.cuh.

148 {
151 }

Member Function Documentation

◆ start_timer()

void CudaTimer::start_timer ( )
inline

Records the start event in the default CUDA stream.

Definition at line 156 of file cuda_utils.cuh.

157 {
159 }

◆ stop_timer()

float CudaTimer::stop_timer ( )
inline

Records the stop event, synchronizes, and calculates elapsed time.

Returns
float The elapsed time in milliseconds between the last calls to start_timer() and stop_timer().

Definition at line 166 of file cuda_utils.cuh.

167 {
169 cudaEventSynchronize(stop); // Wait for the stop event to complete
170 cudaEventElapsedTime(&time, start, stop); // Calculate time difference
171 return time;
172 }
float time
Stores the calculated elapsed time in milliseconds.

Member Data Documentation

◆ start

cudaEvent_t CudaTimer::start
private

Definition at line 175 of file cuda_utils.cuh.

◆ stop

cudaEvent_t CudaTimer::stop
private

CUDA events to mark start and stop points.

Definition at line 175 of file cuda_utils.cuh.

◆ time

float CudaTimer::time
private

Stores the calculated elapsed time in milliseconds.

Definition at line 176 of file cuda_utils.cuh.


The documentation for this class was generated from the following file: