UK Logo High Performance Computing November 23, 2009
Home News System Status User Policies Account Info Hardware Software Documentation FAQs Search
UKy HPC: HP Superdome Cluster Profiling


   Profiling Documentation  
HP Superdome Cluster


   CXPerf


Documentation on the following

|
Overview

CXperf is an interactive runtime performance analysis tool for programs compiled with HP ANSI C (c89), ANSI C++ (aCC), and Fortran 90 (f90) compilers.

Most performance analysis tools, including CXperf, require special profiling options when you compile a program. The options instruct the compiler to create a special executable file containing information that the profiler uses to collect performance data.

Performance analysis methods

There are two different methods available for carrying out performance analysis:

Statistical sampling methods

Statistical sampling methods sample a program's performance at measured intervals and average each routine's execution time. The gprof and prof utilities use statistical sampling.

Event-based methods

Event-based methods measure a program's entire execution time and report the total time spent in individual routines and loops. CXperf is an event-based profiler.

Event-based profilers have advantages over statistical sampling profilers because they provide a greater variety of metrics and direct correlation to the source code.

Caution:
Event-based methods of profiling can become intrusive. Keep the level of intrusion to a minimum.

Due to increased profiling time and intrusion, selecting to profile all region types, all loops, and all metrics during a single profiling session is not recommended.

Why Use CXperf ?

CXperf can be used to discover which routines or loops slow down a program's execution. In some cases, simple modification of source code, such as inserting compiler directives, results in significant performance improvements.

Profiling versions of a program that have been compiled at different optimization levels provides insight into the types of optimizations that work best for a given situation.


How CXperf works

CXperf profiles selected parts of a program, controls the program's execution, stores performance data in a performance data file ( PDF), and displays performance information in reports and graphs. CXperf supports
  • Profiling routines, loops, and compiler-generated parallel loops
  • Routine level profiling for object files and archive libraries created with PA_RISC targeting compilers


  • Displaying profiling information for
    • Entire processes
    • Individual execution threads

  • Preinstrumented executable files

    Preinstrumenting allows you to write profile selection settings (instrumentation) to the current executable file or to a copy of the current executable file. You can run the preinstrumented executable file outside the control of CXperf. The profiling data is collected in a performance data file (PDF) for later analysis.

  • Graphical analysis for performance data
  • Profiling MPI and PVM message passing applications
|
Using CXperf

To invoke CXperf, type cxperf at your UNIX prompt with or without specifying a file name. The file name can be an executable file or a Performance Data File (PDF).

Note:
When you profile a program, CXperf generates a performance data file (PDF) to store the profiling data. The PDF is a binary file containing performance data for a single run of your program. Performance analysis reports and graphs are generated from data in PDFs. You can invoke CXperf with the name of a PDF to analyze data collected during a single run of a program or to analyze data collected in multiple PDFs but merged into a single PDF.

The performance analysis process consists of four steps:
  • Compilation - Although it does not aid in compiling a program for profiling, CXperf provides instructions for compiling because correct compilation is the important first step in the profiling process.


  • Instrumentation - Selecting regions to profile and metrics to collect.


  • Execution - Running an instrumented executable file, either within CXperf or outside.

  • Analysis - Extracting and understanding data gathered in a PDF during execution.

Profiling is an iterative process; you profile a program, make changes to the source code based on the results, and profile again.

When you start CXperf with no filename, the Compilation Page appears. The Compilation Page provides compile information for profiling and allows you to browse a file list to choose an executable file.

When you start CXperf with an executable file, the Instrumentation Page appears.

When you start CXperf with a PDF, the Analysis Page appears.

All pages have a file menu and a help menu. Use the file menu to set preferences, open new files, and exit CXperf. Use the help menu to access online help.


CXperf interfaces

You can run CXperf in X/Motif Graphical User Interface (GUI) mode, character oriented tty interface (line) mode, and batch mode. Text reports are available in all modes.

You can use more than one mode for a single profiling task. For example, you can run an application in line mode or batch mode to collect profiling data, then use the GUI mode to view graphical analysis of the data.


GUI mode

To invoke CXperf in GUI mode, type cxperf at your UNIX prompt. Navigate through the profiling process using the Previous and Next buttons at the bottom of each page. You may be automatically moved between pages as the profiling process progresses; you may be prevented from moving to a page under certain conditions. By guiding you through the process in this way, profiling with CXperf becomes a straightforward and intuitive process.

CXperf provides graphical analysis of performance data through the GUI. The GUI provides:
  • Mouse-driven selection of region types to profile and metrics to collect
  • Intuitive, step-by-step guidance through the compile, instrument, execute, and analyze steps
  • Summary Profile (2D) and Parallel Profile (3D) graphs to analyze performance data
  • Call Graphs with point-and-click navigation
  • Source code correlation when you click on a bar of the Summary or Parallel Profile graph or on a node in the Call Graph
  • Source code display facility with source code annotations indicating regions profiled.
  • Text performance report functionality on the Analysis Page
  • PDF analysis for files created on a different architecture
  • Multiple Analysis Page comparisons which allow you to:
    • Compare and contrast profiling data for different metrics
    • View data from multiple PDFs simultaneously.

For detailed information on profiling a program in GUI mode, see the HP CXperf's User's Guide.


Line mode

Line mode is a character based, command line interface for CXperf. To use line mode, specify the -nw option when you invoke CXperf from the UNIX prompt. When you start CXperf in line mode with the name of a PDF, use the set pdf and analyze commands to access performance data for multiple PDFs, including PDFs created on different architectures.

Line mode presents performance data in Text reports only. However, after you collect profiling data in line mode, the resulting PDF can be analyzed in GUI mode.

Detailed information on profiling a program in line mode is presented below.

Batch mode

Batch mode allows you to run CXperf by incorporating it in a script or text file. You make use of CXperf's tty commands to profile applications in batch mode.

To use batch mode, provide a command file using the -x option on the command line, or invoke CXperf from a shell script, or both - provide the command file within a shell script. You can redirect input, output, and standard error to and from files.

For detailed information on profiling a program in batch mode, see the HP CXperf's User's Guide.
|

Profiling a program in line mode

Compiling

The first step in the performance analysis process is compilation. CXperf does not actually aid you in compiling, but provides instructions - in GUI mode - for compiling programs using HP Fortran 90, ANSI C++, ANSI C, and HP Parallel 32-bit Fortran 77 compilers. To see the Compilation Page with the instructions you must start CXperf in GUI mode. Enter cxperf at your UNIX prompt:

% cxperf

The Compilation Page appears, displaying instructions for compilation.

Table 1 lists instructions for compiling your program.

Step 1. Read the compile instructions in Table 1.
Step 2. Decide which compile preference you need. For this example, compile and link in a single step.
Step 3. Compile and link in a single step to analyze routines and loops.

For example, using the ANSI C compiler enter:

% /opt/ansi/bin/c89 +pal +O3 myprogram

When compilation completes, you have an executable file, a.out, ready for profiling with CXperf. Your profiling options are determined by the compilation you just performed:

  • +pal compiles the program for routine and loop level profiling.
  • +O3 specifies a compiler optimization level that supports profiling routines and loops.

Table 1 describes compiling command syntax to use for programs compiled with HP ANSI C (c89), ANSI C++ (aCC), Fortran 90 (f90), and Fortran 77 (f77) compilers.

Table 1.  Compile instructions
Function Command syntax
Compiling in a single step to analyze routines
compiler +pa -o executable source_files
Compiling in a single step to analyze routines and loops
compiler +pal {+O2|+O3}-o executable source_files
Compiling and linking to analyze routines
compiler -c +pa source_file -o object_file
compiler +pa -o executable object_files
Compiling and linking to analyze routines and loops
compiler -c +pal {+O2|+O3} source_file -o object_file
compiler +pal -o executable object_files
Linking to analyze routines
cxoi object_files libraries -o executable
compiler +pa -o executable object_files libraries


Refer to Preparing programs to profile for more details about compiling source, object, and library files for CXperf.


Instrumenting

To instrument your executable file, first invoke CXperf.

To start CXperf and instrument a.out in line mode, follow this procedure:

Step 1. Invoke CXperf with the name of your executable file and the -nw (no windows) option.

% /opt/cxperf/bin/cxperf -nw a.out

Convex Performance Analyzer

Type 'help' for help.

Reading executable a.out...

Selecting profile a.out.pdf...

(CXperf)


As shown in the output for the command above, CXperf displays the name of the executable file to be profiled and the name of the PDF that the performance data is written to. By default, the PDF is named executable.pdf.


Note:
Use the CXPERF environment variable to specify command line options for starting CXperf. For example,

% setenv CXPERF `-nw -pid -w'

forces CXperf to start in line mode (-nw). The -pid option specifies that CXperf add the process ID number of the process you are profiling to the name of the PDF it creates. The -w option suppresses warning messages issued by CXperf.


Step 2. Select regions to profile with a form of the select command.

The select command syntax is as follows:

select [ routine | loop ] all

where

routine   Selects routines to profile.
loop   Selects loops to profile.
all   Instructs CXperf to select all routines in your program for profiling.


In this example enter:

(CXperf)   select all

Because a.out is compiled with the +pal option, for this example, routines and loops are available for instrumentation.

The all parameter instructs CXperf to select all routines in your program for profiling.

Both routines and loops are selected for profiling because you did not use the [ routine | loop ] parameter to specify only one region type.

In line mode, if you do not use select to select one or more source code regions for profiling, CXperf does not collect any metrics. For detailed information on using the select command, see Selecting routines and loops in the HP CXperf's User's Guide.

If you have a large program, do not select all routines and all loops to profile in a single session, because the more region types and metrics you select, the slower your code executes. This time delay is referred to as profiling intrusion. For a detailed discussion of profiling intrusion, see Profiling strategy in the HP CXperf's User's Guide.


Step 3. Select metrics to collect with the collect and set events commands.

(CXperf)   collect cpu wall_clock call_graph events

(CXperf)   set events process

collect instructs CXperf to collect
  • CPU time
  • Wall Clock time
  • Call Graph
  • events (Specifies collecting one metric set available on the current architecture. Memory, Process, Data Cache Utilization, and Data and Instruction TLB events are possibilities.)

Use set events immediately after collect events to specify which events to collect. For this example, set events process instructs CXperf to collect Process events.

The type and number of metrics available differ according to machine architecture. For details, refer to Introducing metrics in the HP CXperf's User's Guide.


Executing

This section describes how to execute your program under CXperf control in line mode.

Note:
As an alternative to executing your program, you can write the instrumentation selections you just made to the executable file, using the save executable command. You can then exit CXperf and run the executable file to generate a Performance Data File (PDF). For further details, refer to Preinstrumenting in line mode in the HP CXperf's User's Guide.


Step 1. Run your program using the run command.

(CXperf) run

The run command syntax is:

run [ argument ... ] [ i/o_redirection ]

where

argument   Specifies any number of command line arguments to the program you are profiling. Separate multiple arguments with spaces.

io_redirection   Redirects the standard input, output, or error from or to the specified file when you use one of the redirection operators (<, >, >>, >&, >>&).


Step 2. Wait for the program to complete running.

Your program runs to completion unless you press CTRL-C to pause it. For the most accurate results, do not pause your program during profiling.

When you pause a program, use continue to resume execution, or stop to terminate the program.


Analyzing





Send comments/questions to: help-hpc@uky.edu
Last modified:
August 02 2002 09:57:54.