NERSCPowering Scientific Discovery Since 1974

DDT

Distributed Debugging Tool (DDT) from Allinea Software is a parallel debugger installed on Hopper, Carver and Euclid.

The performance of the X Windows-based DDT Graphical User Interface can be greatly improved if used in conjunction with the free NX software.

Introduction

DDT is a parallel debugger which can be run with up to 8192 processors. It can be used to debug serial, OpenMP, MPI, Coarray Fortran (CAF), UPC (Unified Parallel C) codes. It also supports GPU debugging, but NERSC doesn't currently have a license on Dirac.

Totalview users will find DDT has very similar functionality and an intuitive user interface. All of the primary parallel debugging features from Totalview are available with DDT.

The Allinea DDT web page and 'DDT User Guide' (available as $DDT_DOCDIR/userguide.pdf after loading a ddt module) is a good resource for learning more about some of the advanced DDT features.

Loading the DDT Module

To use DDT at NERSC, first load the DDT module to set the correct environment settings with the following command:

% module load ddt

 

Compiling Code to Run with DDT

In order to use DDT, code must be compiled with the -g option. We also recommend that you do not run with optimization turned on, flags such as -fast.

A Fortran example:

% ftn -g -o testDDT_ex testDDT.f        # on Hopper
% mpif90 -g -o testDDT_ex testDDT.f # on Carver or Euclid

A C example:

% cc -g -o testDDT_ex testDDT.c         # on Hopper
% mpicc -g -o testDDT_ex testDDT.c      # on Carver or Euclid

Starting a Job with DDT

Be sure to log in with an X window forwarding enabled. This could mean using the -X or -Y option to ssh. The -Y option often works better for Mac OSX.

% ssh -X username@hopper.nersc.gov

After loading the DDT module and compiling with the -g option, request and interactive session on Hopper and Carver. On Euclid, you run DDT interactively, without going through a batch session.

% qsub -I -V -q debug -lmppwidth=numCores                      # Hopper
% qsub -I -V -q debug -lnodes=numNodes:ppn=numTasksPerNode     # on Carver

Then launch the debugger with the ddt command followed by the name of the executable to debug:

% ddt testDDT_ex

The DDT GUI will pop up and ask What would like to do? For basic debugging choose the option Run and Debug a Program . A user can also choose to Open a Core File . Attach to a Running Program is not yet available.

DDT Submit Window

Then a submission window will appear with a path to the executable to debug. Select the number of processors on which to run and press run. To pass command line arguments to a program enter them in the aprun arguments box.

DDT Submit window

Trouble Shooting

If you are having trouble launching DDT try these steps.

Make sure you have the most recent version of the config.ddt configuration file. The first time you run DDT, you pick up a master template which then gets stored locally in your home directory in ~/.ddt/config_${NERSC_HOST}.ddt where ${NERSC_HOST} is the machine name: hopper, carver or euclid. If you are having problems launching DDT you could be using an older verion of the config.ddt file.

% rm -rf ~/.ddt  

Remove any stale processes that may have been left by DDT.

% rm -rf $TMPDIR/.ddt-$USER 

In case of a font problem where every character is displayed as a square, please delete the .fontconfig directory in your home directory and restart ddt.

% rm -rf ~/.fontconfig

Make sure you are requesting an interactive batch session on Hopper and Carver. NERSC has configured DDT to run from the interactive batch jobs.

% qsub -I -V -q debug -lmppwidth=numCores                      # Hopper
% qsub -I -V -q debug -lnodes=numNodes:ppn=numTasksPerNode     # on Carver

Finally make sure you have compiled your code with -g. A large number of users who are having trouble running with parallel debuggers forget to compile their codes with debugging flags turned on. If none of these tips help, please contact the consultants at consult@nersc.gov

 

Basic Debugging Functionality

The DDT GUI interface should be intuitive to anyone who has used a parallel debugger like Totalview before. Users can set breakpoints, step through code, set watches, examine and change variables, dive into arrays, dereference pointers, view variables across processors, step through processors etc. Please see the DDT Users Guide if you have trouble with any of these basic features.                                                                                                                                                                                            

Useful DDT Features

Process Groups

With DDT, the user can easily change the debugger to focus on a single process or group of processes. If Focus on current Processor is chosen, then stepping through the code, setting a breakpoint etc will occur only for a given processor. If Focus on current Group is chosen then the entire group of processors will advance when stepping forward in a program and a breakpoint will be set for all processors in a group.

Similary, when Focus on current Thread is chosen, then all actions are for an OpenMP thread. DDT doesn't allow to create a thread group. However, one can click the Step Threads Together box to make all threads to move together inside a parallel region. In the image shown above, this box is grayed out simply because the code is not an OpenMP code.

A user can create new sub-groups of processors in several ways. One way is to click on the Create Group button at the bottom of the Process Group Window. Another way is to right-click in the Process Group Window to create a group and then drag the desired processors to the group. Groups can also be created more efficiently using sub-groups from the Parallel Stack View described below. The below image shows 3 different groups of processors, the default All group, a group with only a single master processor Master and a group with the remaining Workers processors.

Parallel Stack View

A feature which should help users debug at high concurrencies is DDT's Parallel Stack View window found in the lower left area, which allows the user to see the position of all processors in a code at the same time from the main window. A program is displayed as a branching tree with the number and location of each processor at each point. Instead of clicking through windows to determine where each processor has stopped, the Parallel Stack View presents a quick overview which easily allows users to identify stray processes. Users can also create sub-groups of processors from a branch of the tree by right clicking on the branch. A new group will appear in the Process Group Window at the top of the GUI.

Parallel Stack View

Mesage Queues

DDT can allows to examine the status of the intermal MPI message buffers. With this feature, you can detect a coding error that generates communication deadlock where all processes are waiting for each other when no message was sent.

Currently message queue debugging is not provided on Hopper.

There are three types of message queues:

  • Send: Calls to MPI send functions that have not yet completed; shown in red arrows
  • Receive: Calls to MPI receive functions that have not yet completed; shown in green arrows
  • Unexpected Message: Represents messages received by the system but the corresponding receive function call has not been made ; shown in blue arrows

To view message queues, you need to select Message Queues from the View pull-down menu. Below are some examples: 

DDT Receive Message Queue

DDT Send and Receive Message Queues

Memory Debugging

DDT has a memory debugging tool that can show heap memory usage across processors.

To access the memory debugging feature, you must first build your code for memory debugging. On Carver, you can build it as usual. However, on Hopper, you have to follow certain steps. Below is a table showing steps for building a static executable using different compilers for memory debugging on Hopper. For the compilers other than PGI, the linking step is made of two parts. The first is to run in verbose mode using the -v flag to show all the linking steps taken. The second step is to rerun the last linker line after inserting some more options.

Compiler For static linking
PGI

% ftn -g -c prog.f
% ftn -Bddt -o prog prog.o

GNU

% ftn -g -c prog.f
% ftn -v -o prog prog.o          # -v to get the last linker line

Rerun the last linker line after inserting '-zmuldefs' right after the command and putting ${DDT_LINK_DMALLOC} just before -lc:
% /opt/gcc/4.7.1/snos/libexec/gcc/x86_64-suse-linux/4.7.1/collect2 -zmuldefs ... ${DDT_LINK_DMALLOC} -lc ...

Cray

% ftn -g -c prog.f
% ftn -v -o prog prog.o

Do similarly as above:
% /opt/cray/cce/8.0.7/cray-binutils/x86_64-unknown-linux-gnu/bin/ld -zmuldefs ... ${DDT_LINK_DMALLOC} -lc ...

Intel

% ftn -g -c prog.f
% ftn -v -o prog prog.o

Do similary as above. There are two locations to put ${DDT_LINK_DMALLOC} as there are two -lc's:
% ld -zmuldefs ... ${DDT_LINK_DMALLOC} -lc ... ${DDT_LINK_DMALLOC} -lc ...

The example commands are shown for a Fortran case. cc and CC should be used similarly for C and C++ codes. In case of a C++ code, ${DDT_LINK_DMALLOCXX} is to be used instead of ${DDT_LINK_DMALLOC}.

A simple script, static_linking_ddt_md, is provided in your $PATH to help you complete the somewhat complicated steps shown above.

% module load ddt
% ftn -g -c prog.f
% static_linking_ddt_md ftn -o prog prog.o # instead of 'ftn -o prog prog.o'
% ls -l prog
-rwx------ 1 xxxxx xxxxx 6701908 2012-10-15 15:19 prog

For multi-threaded codes, DDT_LINK_DMALLOCTH and DDT_LINK_DMALLOCTHCXX are used in place of DDT_LINK_DMALLOC and DDT_LINK_DMALLOCXX, respectively. Again, a utility script, static_linking_ddt_md_th, is provided to help with linking:

% static_linking_ddt_md_th ftn -mp -o prog prog.o   # instead of 'ftn -mp -o prog prog.o' 

Below is a table showing how to prepare your code using dyanmic linking on Hopper. The example is provided for a Fortran code case. Adjustments should be made for C and C++ codes as above. Again, in case of a C++ code, ${DDT_LINK_DMALLOC} must be repalced with ${DDT_LINK_DMALLOCXX} .

Compiler For dynamic linking
PGI, Cray

% ftn -g -c prog.f
% ftn -dyanmic -o prog prog.o ${DDT_LINK_DMALLOC} --Wl,--allow-multiple-definition

GNU, Intel

% ftn -g -c prog.f
% ftn -dynamic -o prog.o ${DDT_LINK_DMALLOC} -zmuldefs

For multi-threaded codes, ${DDT_LINK_DMALLOCTH} or ${DDT_LINK_DMALLOCTHCXX} should be used instead.

Next, when DDT starts, you must click the "Memory Debugging" checkbox in the DDT run menu that first comes up

DDT Groups

To set detailed memory debugging options, click the 'Details...' button on the far right side, which will open the 'Memory Debugging Options' window. There you can set the heap debugging level, the number of guard pages before or after arrays (but not both) for detection of heap overflow or underflow in the program, etc. The default page size is 4 KB.

DDT - memory debugging option

Several features are enabled with memory debugging. To see them, select Current Memory Usage and Memory Statistics under the View menu.  You might see something that looks like the following:

DDT - Current Memory Usage

It displays current heap memory usage of the program and the routines where it is allocated. By clicking on one of the pointers in the "Allocation Details" list on the left you can get information mapped to source code:

DDT - Pointer Details

 It is known that memory debugging can fail with the error message "A tree node closed prematurely. One or more proceses may be unusable.", especially with MPI_Bcast. A workaround is to disable 'store stack backtraces for memory allocations' option in the 'Enable Memory Debugging' setting. This problem will be fixed in the next release.

Installed Versions

PackagePlatformCategoryVersionModuleInstall DateDate Made Default
DDT carver applications/ debugging 3.1-22847 ddt/3.1-22847 2012-05-11 2012-06-22
DDT carver applications/ debugging 3.2-24924 ddt/3.2-24924 2012-08-30 2012-10-10
DDT carver applications/ debugging 3.2-rc2 ddt/3.2-rc2 2012-06-22 2012-07-17
DDT edison applications/ debugging 3.2.1 ddt/3.2.1 2013-01-16 2013-01-19
DDT hopper applications/ debugging 3.0 ddt_ccm/3.0 2012-04-05
DDT hopper applications/ debugging 3.1-20638 ddt_ccm/3.1-20638 2012-04-05 2012-04-05
DDT hopper applications/ debugging 3.1-22847 ddt/3.1-22847 2012-05-11 2012-06-22
DDT hopper applications/ debugging 3.2-24924 ddt/3.2-24924 2012-08-30 2012-10-10
DDT hopper applications/ debugging 3.2-rc2 ddt/3.2-rc2 2012-06-22 2012-07-18
DDT hopper applications/ debugging 3.2.1-27702 ddt/3.2.1-27702 2013-01-15 2013-02-01

Introductory Video Tutorial

Watch the video.

Downloads