30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Visualizing Array Data<br />

Visualizing Data Programmatically<br />

The $visualize function lets you visualize data from within eval points and<br />

the Tools > Evaluate Window. Because you can enter more than one<br />

$visualize function within an eval point or Evaluate Window, you can simultaneous<br />

visualize multiple variables.<br />

If you enter the $visualize function in an eval point, <strong>TotalView</strong> interprets<br />

rather than compiles the expression, which can greatly decrease performance.<br />

See “Defining Eval Points and Conditional Breakpoints” on page 366 for<br />

information about compiled and interpreted expressions.<br />

Using the $visualize function in an eval point lets you animate the changes<br />

that occur in your data, because the Visualizer updates the array’s display<br />

every time <strong>TotalView</strong> reaches the eval point. Here is this function’s syntax:<br />

$visualize ( array [, slice_string ])<br />

The array argument names the dataset being visualized. The optional<br />

slice_string argument is a quoted string that defines a constant slice expression<br />

that modifies the array parameter’s dataset. In Fortran, you can use<br />

either a single (’) or double-quotation mark ("). You must use a double-quotation<br />

mark if your language is C or C++.<br />

The following examples show how you can use this function. Notice that<br />

the array’s dimension ordering differs between C/C++ and Fortran.<br />

C and C++ $visualize(my_array);<br />

$visualize (my_array,"[::2][10:15]");<br />

$visualize (my_array,"[12][:]");<br />

Fortran $visualize (my_array)<br />

$visualize (my_array,’(11:16,::2)’)<br />

$visualize (my_array,’(:,13)’)<br />

The first example in each programming language group visualizes the entire<br />

array. The second example selects every second element in the array’s<br />

major dimension; it also clips the minor dimension to all elements in the<br />

range. The third example reduces the dataset to a single dimension by<br />

selecting one subarray.<br />

You may need to cast your data so that <strong>TotalView</strong> knows what the array’s<br />

dimensions are. For example, here is a the C function that passes a twodimensional<br />

array parameter that does not specify the major dimension’s<br />

extent.<br />

void my_procedure (double my_array[][32])<br />

{ /* procedure body */ }<br />

You would need to cast this before <strong>TotalView</strong> can visualize it. For example:<br />

$visualize (*(double[32][32]*)my_array);<br />

Sometimes, it’s hard to know what to specify. You can quickly refine array<br />

and slice arguments, for example, by entering the $visualize function into<br />

the Tools > Evaluate Dialog Box. When you select the Evaluate button, you<br />

192 Chapter 9: Visualizing Programs and Data

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!