[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
User Manual


Previous Contents Index

Optimization and Debugging

You should disable optimization when you compile a program for debugging. Optimizations can cause unexpected and confusing behavior in a debugging session by changing the order of machine code. When you turn optimization off, a debugging session is expedited and simplified because the machine code is put in the same order as the lines in your source program.

On the Tru64 UNIX operating system, full optimization, corresponding to the -O4 or -O flag, is the default unless you specify the -g flag on the command line for debugging. The -g flag disables optimization entirely, and displays this message:


cobol: Warning:...File not optimized; use -g3 if both
optimization and debugging wanted     <>

On OpenVMS Alpha systems, in general, specify /NOOPTIMIZE if you specify /DEBUG when you compile a program. If you specify /DEBUG but omit any form of the /OPTIMIZE qualifier on the command line, the compiler issues the following informational message:


%COBOL-I-DEBUGOPT, /NOOPTIMIZE is recommended with /DEBUG

Unlike other informational messages, which are turned off by default, this message is issued even if /WARNINGS=NOINFORMATION is in effect. You can turn it off by specifying any form of the /OPTIMIZE qualifier.

If you need to debug optimized code, refer to the OpenVMS Debugger Manual. <>

Other Effects of Optimization

An effect of optimization is larger object modules and longer compile times. These potential disadvantages are typically outweighed by faster run times.

To speed compilations during program development, you may want to compile with the noobject option when you want to check syntax.

When checking for correct execution, you may want to compile initially with no optimization, and later with optimization when the program is executing correctly.

If your program is not executing correctly and you suspect an optimization-related problem, try compiling it with no optimization or with level 2 optimization. The latter is a compromise that can often help, because it turns off some of the more aggressive optimizations, such as decimal shadowing.

15.2 Specifying Alignment of Data for Optimum Performance (Alpha, I64)

Proper alignment of numeric data items within record structures can make run-time performance significantly faster. See Chapter 16 for information on data alignment specified on the compiler command line, and information on compiler directives that specify alignment. Refer to the HP COBOL Reference Manual for information on the SYNCHRONIZED clause, which is also used to specify alignment. <>

15.3 Using COMP Data Items for Speed

Large, compute-intensive applications can often run faster if arithmetic data items are USAGE COMP.3 As you write COBOL code, maximize your use of COMP for arithmetic operands. COMP data items typically run faster for arithmetic operations than PACKED-DECIMAL (COMP-3) or DISPLAY data items. In general, the following guidelines hold true:

  • When the data item is part of an arithmetic operation, specify USAGE IS COMP.
  • When the data item is used as a subscript, specify USAGE IS INDEX.

For existing COBOL programs, you should consider converting numeric data items to COMP if an application is compute-bound and time-critical and you would like to improve execution speed. Some factors in the decision whether to convert are discussed in this section.

Precision Not Reduced by Conversion to COMP

The data types usually employed for COBOL data items are summarized below:

Usage Data Type
COMP, BINARY,
COMP-5, COMP-X
Binary
COMP-1 F-Float (compiled with /FLOAT=D_FLOAT
or /FLOAT=G_FLOAT)
  S-Float (compiled with /FLOAT=IEEE_FLOAT)
COMP-2 D-Float (compiled with /FLOAT=D_FLOAT)
  G-Float (compiled with /FLOAT=G_FLOAT)
  T-Float (compiled with /FLOAT=IEEE_FLOAT)
COMP-3,
PACKED-DECIMAL
Packed-decimal
DISPLAY Text or decimal

On Tru64 UNIX systems, the F_FLOAT, D_FLOAT and G_FLOAT data types are not supported. <>

Operations on COMP-1 and COMP-2 data items are fast. However, it is not recommended that you convert data items to COMP-1 or COMP-2, because you could lose precision. Floating-point numbers are approximations using a scientific notation relative to powers of two. A COMP-1 operand gives approximately 7 decimal digits of precision, a COMP-2 approximately 15; either often represents a value less precisely than the other data types, which are fixed point.

The semantics of COMP (BINARY, COMP-5, COMP-X), COMP-3 (PACKED-DECIMAL), and DISPLAY operands are the same: each can be scaled (except for COMP-5 and COMP-X) and signed, and can hold up to 18 decimal digits. Therefore, converting existing programs from COMP-3 or DISPLAY to COMP will yield results that are no less accurate or precise. The only effect on operands is the method of storage; and the primary effect on operations is improved performance.

Because changing the data type changes the way data is stored, you may not be able to change the data type of items that participate in a REDEFINES or that are elements of file record structures.

Tools That Can Help You Decide Whether to Convert a Program

Hewlett-Packard does not recommend a massive conversion of all source programs to use COMP operands. Most existing COBOL programs perform very well, and conversions of old programs can be expensive. The following tools can help you decide which programs would run significantly faster if converted, and to discover program interdependencies:

PCA

On OpenVMS, the Performance and Coverage Analyzer (PCA) can target specific areas of programs that require large amounts of CPU time. If 80 percent of the processing time is used by 20 percent of the COBOL routines, you may benefit from converting only these routines to use COMP.

SCA and LSE

The Source Code Analyzer (SCA) can help discover program interdependencies as you contemplate changes. For example, if it is proposed that an item declared COMP-3 be changed, SCA can quickly and easily find all the references to that item.

If SCA is used in conjunction with the Language-Sensitive Editor (LSE), LSE can bring up buffers in your editing session with each of the references.

Oracle CDD/Repository

The Common Data Dictionary can store data definitions and dependency information, which can then be maintained from one centralized location. <>

prof, pixie

On Tru64 UNIX, these performance analysis tools can be used to identify programs ( prof ) or sections of programs ( pixie ) that require large amounts of CPU time. If 80 percent of the processing time is used by 20 percent of the COBOL routines, you may benefit from converting only these routines to use COMP. <>

Note

3 Following are some reasons: COMP data items can be manipulated by direct and natural use of the Alpha instruction set. Manipulation of decimal types requires longer sequences of instructions, most of which are implemented as HP COBOL Run-Time Library routines. While floating point is also a natural Alpha data type, it does not support the full 18-digit precision allowed in COBOL. For more information, refer to the HP COBOL Reference Manual.


Previous Next Contents Index