Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


CUDA, Supercomputing for the Masses: Part 16

CUDA 3.0 Enhancements Affecting CUDA-GDB

CUDA 3.0 delivers a big performance improvement for programs compiled with debugging enabled (using nvcc -g -G) because register variables are no longer forced to be spilled to local memory. This alone can help speed the debugging workflow and make it easier to find bugs faster.

Another important enhancement is that CUDA 3.0 executables now use the standard ELF executable format. While opaque, this is actually a change that can affect many developers. For example, those who like to streamline their workflow by keeping CUDA-GDB running while changing and recompiling source will be happy to know that this now works in CUDA 3.0. Just as with GDB, CUDA-GDB does not need to be stopped and restarted every time the executable changes. If you don't use this feature then try it because it preserves breakpoints, debugging history and other information that can maintain the state of a debugging session and really cut down on retyping

In addition, developers can now look at register variables and examine the GPU memory space by casting pointers with CUDA-GDB. The values of "shadow" variables (variables with the same name inside an inner scope as shown for variable, as in the code snippet below) are also reported correctly.

    register int a=2;
   // do something with a
       register int a=10;
       // do something with the value of a that is local to this scope

In total, this latest version of CUDA-GDB provided in the CUDA 3.0 release delivers a significantly more consistent and seamless experience that exhibits fewer and fewer departures from standard or "expected" GDB behavior. Unquestionably, this uniformity will increase developer productivity, reduce frustration, and speed debugging efforts.

Be aware that some of the CUDA-GDB commands have changed since my Part 14 tutorial on CUDA-GDB. Specifically the commands info cuda state, and info cuda threads all have been removed. The new info commands are:

  • info cuda system
  • info cuda device
  • info cuda sm
  • info cuda warp
  • info cuda lane

Also, there is the wonderful new command set cuda memcheck on to check for out-of-bounds and misaligned address errors! Later in this article, I explore the capabilities of the memory checker in CUDA-GDB. The memory checker can also be called separately with the standalone tool cuda-memcheck, which can help automate testing and support field debugging.

For additional information, the latest documentation on CUDA-GDB can be found in version 3.0 of the NVIDIA CUDA Debugger CUDA-GDB. The "What's New" section provides an overview of changes and the "Known Issues" section discusses important limitations. Here are three important ones that still exist:

  • X11 cannot be running on the GPU that is used for debugging. Suggested workarounds include:

    • Remote access to a single GPU (VNC, ssh, etcetera).
    • Use two GPUs, where X11 is running on only one of the graphics processors.

  • Multi-GPU applications are not supported.
  • Kernel launches are not asynchronous as the driver enforces blocking kernel launches when debugging is enabled. This can slow application performance and affect asynchronous behavior.

The following simple example code, version.cu, demonstrates how to read the current driver and runtime version. Please note that the reported version numbers returned differ from what you might expect as discussed in the forums.

#include <stdio.h>
#include <stdlib.h>

int main(void)
  int driverVersion, runtimeVersion;
  printf("driver version %d runtime version %d\n",
	 driverVersion, runtimeVersion);
  return 0;

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.