MAINPM User's Guide, Chapter 3

previous   next   top   contents   index   framed top   this page unframed


3. Running MAINPM

This chapter describes how to run MAINPM in more detail than the summary of the previous chapter.

3.1. Invoking the MODULE MAINPM

After you have compiled all the MODULEs you wish to monitor, execute the MODULE MAINPM to direct the gathering and reporting of statistics.

When you execute your program while running MAINPM, MAINSAIL gathers statistics and writes them to a data file created by MAINPM. The logical name of the statistics file is (pm statistics file). This logical name is ordinarily entered by means of a subcommand to the MAINSAIL executive in the configuration file (see Section 21.2.19 of the MAINSAIL Utilities User's Guide). If you wish to use a different file name from the usual one for the statistics file, specify it by means of the ENTER subcommand when you invoke MAINPM, as follows:

*mainpm,<eol>
>
enter (pm statistics file) foo.stat<eol>
>
<eol>
MAINPM (type ? for help)

MAINPM:

3.2. MAINPM Commands

After you invoke MAINPM, it prompts you for commands. Commands to MAINPM control:

Enter commands one per line, each followed by <eol>. Upper and lower case are not distinguished in commands. You need type only as many characters of a command as are needed to distinguish it from other commands.

Table 3–1 contains a quick summary of MAINPM commands.

Table 3–1. Summary of MAINPM Commands
Command Meaning
? Display MAINPM commands
ADD f Add statistics from file f to current statistics
CALLS Report number of times each PROCEDURE is called
COUNTS Report statement counts
EXECUTE m Invoke MODULE m (m may be a file name)
INCLUDE f Read commands from file f
INFO Display current MAINPM status
LIST f Write statistics to report file f
LIST Write statistics to current report file
LOAD f Restore current statistics from file f
MODULE Break statistics down to MODULE level
MONITORAREA Undo previous {NO}MONITORAREA commands
MONITORAREA t Monitor areas with title = t
MONITORAREA ? Show non-null titles of current areas
MONITORLIB Undo previous {NO}MONITORLIB commands
MONITORLIB f Monitor MODULEs from library files f = f1 f2 ...
MONITORLIB ? Show file names of currently open libraries
MONITORMODULE Undo previous {NO}MONITORMODULES commands
MONITORMODULE m Monitor MODULEs m = m1 m2 ...
NOCALLS Do not report PROCEDURE call counts
NOCOUNTS Do not report statement counts
NOMONITORAREA t Do not monitor areas with title = t
NOMONITORLIB f Do not monitor MODULEs from library files f = f1 f2 ...
NOMONITORMODULE m Do not monitor MODULEs m = m1 m2 ...
NOPC Do not PC monitor
NOSPACE Do not report chunk/STRING/static space
NOTIMING Do not report timing information
NOTRACEREPORT Do not report trace information
NOTRACESRC Do not report trace source text
NOUNEXECUTED Do not report unexecuted entities
PC {t} PC monitor {with virtual/real time interval t}
PC VIRTUAL {t} PC monitor {with virtual time interval t}
PC REAL {t} PC monitor {with real time interval t}
PC {VIRTUAL|REAL} {t} WHEN callPattern... PC monitor, counting only calls when callPattern is active
PROCEDURE Break statistics down to PROCEDURE level
QUIT Exit MAINPM
SPACE {DEEP} Monitor shallow {and deep} chunk, STRING, and static space
STATEMENT Break statistics down to statement level
STORE f Save current statistics in file f
TARGET s Set target system to s (e.g., for analyzing TRACECHUNKS output)
TIMING x Report timing information, kind of time = x
TRACECHUNKS {f} Trace allocation history of dynamic objects {using trace data file f}
TRACEREPORT Undo NOTRACEREPORT
TRACESRC Undo NOTRACESRC
UNEXECUTED Report unexecuted entities
VERSION m.n Set version number to m.n (e.g., for analyzing TRACECHUNKS output)

3.2.1. Specifying What to Monitor

The basic types of monitoring available are:

The types of monitoring are summarized in Table 3–2.

Table 3–2. Types of MAINPM Monitoring
Type of Monitoring Compiler Subcommands Pre-Execution MAINPM Commands Other Requirements
statement counts PERMOD PERPROC PERSTMT (MONITOR) none none
number of times each PROCEDURE is called PERSTMT (MONITOR) none MAINPM must be breaking statistics down to PROCEDURE or statement level
MODULE CPU time MODTIME (MONITOR) none can't monitor user-defined time simultaneously
PROCEDURE CPU time PROCTIME (MONITOR) none can't monitor user-defined time simultaneously
MODULE user-defined time MODTIME (MONITOR) TIMING USER special code in program
PROCEDURE user-defined time PROCTIME (MONITOR) TIMING USER special code in program
chunk, STRING, and static space none SPACE {DEEP}; (MONITORxxx) (NOMONITORxxx) {NO}MONITOR only for extra control
PC-sampled time none PC {xxx} none
chunk tracing DEBUG, ALIST, or PERSTMT (MONITOR) TRACECHUNKS none

More than one kind of monitoring can take place on the same program execution. In the above list, only MODULE and PROCEDURE CPU timing and MODULE and PROCEDURE user-defined timing are mutually exclusive; either one can be performed simultaneously with any combination of the other three kinds of monitoring, depending on the compiler subcommands and MAINPM commands given.

For chunk, STRING, and static space monitoring, the MONITOR and NOMONITOR commands provide additional control of what is to be monitored by allowing monitoring only of specified areas, MODULEs, or objmod libraries. The MONITOR and NOMONITOR commands must be given before the monitored program is executed; see Chapter 4 for details.

The per-MODULE, per-PROCEDURE, and per-statement statement counts are often measured in conjunction with the per-MODULE and per-PROCEDURE timings. For this reason, the compiler subcommand MONITOR turns on all five compiler subcommands relevant to these kinds of monitoring.

PC-sampled time provides a method of measuring CPU time usage that is an alternative to per-MODULE and per-PROCEDURE timings. The chief differences between the two are:

3.2.2. Invoking MODULEs from MAINPM

Use the EXECUTE command to invoke a MODULE. MAINPM uses the first word following the word EXECUTE as either the name of the MODULE to be invoked or the name of the file containing the MODULE; subsequent words are treated as arguments to the executed MODULE. While that MODULE is running, MAINSAIL gathers statistics about the execution of all MODULEs that were compiled to be monitored. MAINPM also obtains the invoked MODULE's total execution time, regardless of whether or not it was compiled to be monitored. The total execution time includes the time spent in other MODULEs.

3.2.3. Specifying Kinds of Statistics

The commands in Table 3–3 control the kinds of statistics reported for statement count and MODULE and PROCEDURE CPU and user-defined time monitoring. These commands can be given either before or after the monitored program's execution; they do not affect the gathering of the statistics, just the way they are presented in the report.

Table 3–3. Commands Controlling Kinds of Statistics
Command Meaning
COUNTS Report statement counts.
NOCOUNTS Do not report statement counts.
CALLS Report PROCEDURE call counts.
NOCALLS Do not report PROCEDURE call counts.
NOTIMING Do not report timing information.
NOUNEXECUTED Do not report unexecuted entities.
TIMING Report timing information.
UNEXECUTED Report unexecuted entities.

MAINPM reports timing information unless you specify the NOTIMING command. It reports statement counts unless you specify the NOCOUNTS command. It reports how many times each PROCEDURE is called unless you specify the NOCALLS command. It reports unexecuted PROCEDUREs or statements only if you specify the UNEXECUTED command.

MAINPM reports PROCEDURE call counts, unexecuted PROCEDUREs, or statements only for MODULEs in which statement counts at the PROCEDURE or statement level were gathered, so if you want this information reported, be sure to specify the appropriate subcommand when you compile your MODULEs (see Section 2.1).

3.2.4. Specifying Level of Detail

The commands in Table 3–4 control the level of detail to which the statistics are broken down. These commands can be given either before or after the monitored program's execution; they do not affect the gathering of the statistics, just the way they are presented in the report.

Table 3–4. Commands Controlling Level of Detail
Command Meaning
MODULE Break statistics down to the MODULE level.
PROCEDURE Break statistics down to the PROCEDURE level.
STATEMENT Break statistics down to the statement level.

If none of these commands is specified, MAINPM breaks the statistics down to the lowest level for which statistics are available, based on the compiler subcommands with which the MODULEs of the monitored program were compiled. Otherwise it breaks them down to the level corresponding to the last command specified. If no statistics of a given kind are available at that level for a given MODULE, MAINPM uses the statistics at the lowest level available. In particular, since timing information is not available at the statement level, the lowest level to which timing information is ever broken down is the PROCEDURE level.

3.2.5. Including Commands Read from a File

You may run MAINPM several times to gather similar statistics. In this case, there may be an identical set of commands you want to issue at the start of each MAINPM execution. Instead of typing the commands in each time, you can record the commands in a file, and read the commands from the file using the INCLUDE command. The file should contain MAINPM commands, one command per line. INCLUDE commands may be nested; that is, the INCLUDE file may contain INCLUDE commands.

For example, the command:

MAINPMinclude mycmds.txt<eol>

executes the MAINPM commands in mycmds.txt.

3.2.6. Writing to the Report File

Once the kinds of statistics and level of detail are specified to your liking, use the LIST command to generate the report.

If a parameter follows the word LIST, MAINPM uses it as the name of the report file to which it writes the report. Otherwise, it uses the name in the most recently specified LIST command. If no LIST command has been specified, MAINPM prompts you for the name of a file that it creates and subsequently uses as the current report file.

MAINPM closes its report file after each LIST command. If a subsequent LIST command directs more output to the same file, MAINPM reopens the file and positions to its end of file before writing more statistics.

If you want to separate the report into two (or more) parts, then for each part:

MAINPM remembers the kinds of statistics and level of detail to report from one part of a report to the next.

Below is a dialogue between a user and MAINPM that results in a report consisting of two parts. The first part shows each PROCEDURE's shallow and deep time, and the second part shows the number of statements executed in each PROCEDURE:

MAINPMprocedure<eol>
MAINPMnocounts<eol>
MAINPMlist report<eol>
MAINPMcounts<eol>
MAINPMnotiming<eol>
MAINPMlist<eol>

3.2.7. Combining Statistics from Several Executions into One Report

As an alternative to generating a report immediately, you can save the current statistics in a file. That file can be combined with the statistics files from other executions of MAINPM to produce a combined listing.

In order to combine statistics from different runs, the run your program (or programs) repeatedly under MAINPM. After each execution of the monitored program, the save that run's statistics in a different file with the STORE command. After gathering and saving the statistics for each run, combine them by means of the LOAD and ADD commands; use the LOAD command to restore the statistics for the first run, and a sequence of ADD commands to combine the statistics for subsequent runs.

Once the statistics are combined, they can be reported with the LIST command as if they were gathered during a single execution, or they can be saved in a file by means of the STORE command.

3.2.7.1. Portability of Statistics Files
MAINPM's statistics file is a PDF (portable data format) file. Its first record contains the target system number of the operating system on which it was originally created. This number is preserved through all subsequent STORE, LOAD, and ADD operations, regardless of the host system on which these operations occur.

The target system number is used when the contents of two statistics files are merged by means of MAINPM's ADD command. If the two files have different target system number fields, MAINPM issues an error message.

Statistics can be gathered for a program on one system and the program's statistics can be reported on a different system, as long as the necessary intmods from the first system are available on the second system.

3.2.8. Displaying Current MAINPM Status

Use the INFO command to find out what would be reported if a report were generated right now. MAINPM displays the kinds of statistics that would be reported, the level of detail to which they would be reported, and the name of the report file.

3.2.9. Exit from MAINPM

Use the QUIT command to exit MAINPM when you are finished. If your previous command was not a LIST command, MAINPM asks you if you are sure that you want to quit. If your response is not Y (or y), it ignores the QUIT command.

3.3. Details on the Statistics File

This section describes exactly what data are written to the statistics file and when. Data for a monitored MODULE m are written to the file:

Once a MODULE's statistics are written to the statistics file, the state of its statistics is reset to what it was when the MODULE was first allocated. This means that if several MODULEs are run in turn during a single MAINPM session, and a report is generated after each run, the statistics for any MODULEs that were present for more than one run will reflect only their activities during the run associated with each report file.

A MODULE's statistics reflect all instances of the MODULE that may have been active. The statistics are not broken down across different data sections of the same MODULE.


previous   next   top   contents   index   framed top   this page unframed

MAINPM User's Guide, Chapter 3