28
Oct
10

CUDA Event API

Description:

Cuda Event API can be used to accurately time events by starting events at different times, and comparing their start times.

CUDA Event API Management Functions:

  • cudaEventCreate
  • cudaEventCreateWithFlags
  • cudaEventDestroy
  • cudaEventElapsedTime
  • cudaEventQuery
  • cudaEventRecord
  • cudaEventSynchronize

Example:

cudaEvent_t start,stop;
// Generate events
cudaEventCreate(&start);
cudaEventCreate(&stop);

// Trigger event 'start'
cudaEventRecord(start, 0);

/* CUDA Host / Device / Kernel Code ... */

cudaEventRecord(stop, 0); // Trigger Stop event
cudaEventSynchronize(stop); // Sync events (BLOCKS till last (stop in this case) has been recorded!)
float elapsedTime; // Initialize elapsedTime;
cudaEventElapsedTime(&elapsedTime, start, stop); // Calculate runtime, write to elapsedTime -- cudaEventElapsedTime returns value in milliseconds. Resolution ~0.5ms

printf("Execution Time: %f", elapsedTime); // Print Elapsed time

// Destroy CUDA Event API Events
cudaEventDestroy(start);
cudaEventDestroy(stop);

Multiple Timers Using Multiple Events:

Multiple timers can be pushed to time individual Kernels in an application. Initialize timers with different names and use cudaEventElapsedTime to calculate the event recording differences!

Screenshot showing a console application with multiple CUDA event API timers

Screenshot showing a console application with multiple CUDA event API timers

About these ads

0 Responses to “CUDA Event API”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: