Displaying a Variable in All Processes or Threads
When you are debugging a parallel program that is running many instances of the same executable, you usually need to view or update the value of a variable in all of the processes or threads at once.
To display the value of a variable in all of the processes in a parallel program, first bring up a Variable Window displaying the value of a variable in one of the processes. You can now use these commands:
- View > Laminate > Process displays the value of the variable in all of the processes.
- View > Laminate > Thread displays the value of a variable in all threads within a single process.
Note: You cannot simultaneously laminate across processes and threads in the same Variable Window.
The Variable Window switches to "laminated" mode, and displays the value of the variable in each process or thread. The following figure shows a simple, scalar variable in each of the processes in some OpenMP programs. Notice that the first six have a variable in a matching stack frame. The corresponding variable cannot be found for the seventh thread.
Laminated Scalar Variable 
|
If you decide that you no longer want the pane to be laminated, use the View > Laminate > None command to delaminate it.
When looking for a matching stack frame, TotalView matches frames starting from the top frame, and considers calls from different memory or stack locations to be different calls. For example, the following definition of recurse contains two additional calls to recurse. Each of these generate nonmatching stack frames.
int recurse (int i, int depth)
{
if (i == 0)
return depth;
if (i&1)
recurse (i-1, depth+1);
else
recurse (i-3, depth+1);
}
If the variables are at different addresses in the different processes or threads, the address field at the top of the pane displays (Multiple) and the unique addresses are displayed with each data item, as was shown in the following figure.
TotalView also allows you to laminate arrays and structures. When you laminate an array, each element in the array is displayed across all processors. As with a normal Variable Window, you can use a slice to select elements to be displayed. The next figure shows an example of a laminated array and a laminated structure. You can also laminate an array of structures.
Laminated Array and Structure
|
Diving in a Laminated Pane
You can dive through pointers in a laminated Variable Window, and the dive will apply to the associated pointer in each process or thread.
Editing a Laminated Variable
If you edit a value in a laminated Variable Window, TotalView asks if it should apply this change to all of the processes or threads or only the one in which you made a change. This is also an easy way to update a variable in all of processes