The CUDA Compute Profiler

NVidia provides a simple profiler for CUDA and OpenCL programs in order to allow users to identify performance bottlenecks in multi-kernel applications or to quantify the benefit of optimizing a single kernel.

That profiler can be easily used through some environement variables and the latest version of documentation can be found in the CUDA toolkit.

The profiler suppports lot of options (ie. events) like the number of instructions executed (inst_executed), the number of texture cache hits (tex_cache_hit)…

For example, if you want to trace the number of instructions executed, you have to set the following environement variables :

# Enable the profiler

# Specify a config file for enabling performance counters in the GPU
export COMPUTE_PROFILE_CONFIG=perf_config.txt

# Set to the desired file path for profiling output (cuda_profile_0.log by default) (optionnal)
export COMPUTE_PROFILE_LOG=perf_log.txt

# Set to either 1 (set) or 0 (unset) to enable or disable a comma separated version of the log output. (optionnal)

Then, you have to specify what performance counters you want to trace in the perf_config.txt. in this example, perf_config.txt looks like this :


Now, you can run your CUDA sample and you can see the output report in cuda_profile_0.log (depends of COMPUTE_PROFILE_LOG).

In my example, I ran the vectorAddDrv CUDA sample, and the output looks like this :

# CUDA_DEVICE 0 GeForce GT 430
# TIMESTAMPFACTOR fffff68322358270
method=[ memcpyHtoD ] gputime=[ 115.328 ] cputime=[ 81.000 ]
method=[ memcpyHtoD ] gputime=[ 115.328 ] cputime=[ 65.000 ]
method=[ VecAdd_kernel ] gputime=[ 65.984 ] cputime=[ 90.000 ] occupancy=[ 1.000 ] inst_executed=[ 17848 ]
method=[ memcpyDtoH ] gputime=[ 188.288 ] cputime=[ 397.000 ]

Leave a Reply

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

You are commenting using your 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