Natural Optimizer Compiler Version 8.3/8.4 - Documentation Updates

Note:
The documentation updates provided here only cover the changes introduced in Natural Optimizer Compiler Version 8.3 and Version 8.4.

For the changes in installation, see Installing the Natural Optimizer Compiler on z/OS, z/VSE and BS2000 in the Natural Installation documentation.


Optimizer Options under Natural Optimizer Compiler Version 8.3/8.4

Note:
This is an extract of the chapter Optimizer Options and only describes the changes specific to the Natural Optimizer Compiler Version 8.3 and Version 8.4.

ARCH Option

The ARCH option specifies the hardware architecture level to be used for generating code for executable Natural objects.

When you specify an ARCH value, the Natural Optimizer Compiler generates newer and faster machine instructions that can improve the performance of the generated code. You cannot specify a value that is higher than the architecture level of your current machine. An executable Natural object cataloged with an ARCH level can only run on a machine with the same or a higher architecture level. Therefore, we recommend not to use the ARCH option if the cataloged objects are intended to execute on any machine, especially on a machine with a lower architecture level (for example, BS2000).

For detailed information on architecture levels, see the related literature from IBM (z/Architecture, Principles of Operation).

The following architecture levels are supported by the ARCH option of the Natural Optimizer Compiler:

Architecture Level IBM Hardware Facility Required
0 Specifies that no architecture level is used. This is the default setting for compatibility with all mainframe platforms supported by Natural.
1 to 4 These values are not evaluated and treated as ARCH=0.
5 to 6
  • z800 or z900
    Extended-Translation Facility 2

  • z890 or z990
    HFP Multiply-and-Add/Subtract Facility

7
  • z9 to z109
    Extended-Immediate Facility

8
  • z10
    General-Instructions-Extension Facility
    Execute-Extensions Facility

9
  • zEnterprise 196
    Load/Store-on Condition Facility
    Floating-Point-Extension-Facility
    Distinct-Operands Facility
    High-Word-Facility

10
  • zEnterprise EC12 (zEC12)
    Decimal Floating-Point Facility
    Decimal Floating-Point Zoned-Conversion Facility

11
  • zEnterprise z13
    Decimal Floating-Point Packed-Conversion Facility

12 (Applies to Natural Optimizer Compiler Version 8.4 and above only.)
  • zEnterprise z14
    Vector Packed-Decimal Facility

Note:
With an ARCH value greater zero, the Natural Optimizer Compiler generates instructions up to the facility level described in the table above. An ARCH value higher than the architecture level of the underlying machine is rejected at compile time. The attempt to start a program compiled with an ARCH level on a machine with a lower architecture level, causes a NAT1394 runtime error. You can display information on the current machine by using the TECH system command.

This section covers the following topics:

Support for Architecture Level 10

When ARCH=10 is set, the Natural Optimizer Compiler generates instructions provided by the Decimal-Floating-Point (DFP) Zoned-Conversion Facility for the numeric operations described in the following section. This can significantly improve the execution speed for statements that use these operations.

Operations Optimized by ARCH=10

The following arithmetic operations on variables of the Natural data formats I (integer), N (numeric unpacked) and P (packed numeric) benefit from ARCH=10:

  • Value assignments:

    P:=I

    P:=N

    N:=I

    N:=N

    N:=P only if the number of packed digits is less than or equal to 15.

    I:=N

  • Arithmetic operations, such as ADD, SUBTRACT, DIVIDE and MULTIPLY statements, but only if both of the following conditions apply:

    At least one of the operands used is in the format N or I.
    The operation result does not exceed 34 (integer + precision) digits.

  • Comparisons, such as IF and DECIDE statements, but only if both of the following conditions apply:

    At least one of the operands used is in the format N.
    Both operands are in different formats.

Support for Architecture Level 11

When ARCH=11 is set, the Natural Optimizer Compiler uses machine instructions introduced with the DFP Packed-Conversion Facility. In addition to the numeric operations optimized with ARCH=10, ARCH=11 also optimizes operations that use packed variables only.

Support for Architecture Level 12

Applies to Natural Optimizer Compiler Version 8.4 and above only.

When ARCH=12 is set, the Natural Optimizer Compiler generates machine instructions introduced with the Vector Packed-Decimal Facility (VPD) in the z14 hardware class. This can improve the execution speed for assignments, comparisons, and calculations if at least one packed operand is used.

VPD machine instructions are generated for the same Natural operations described for Architecture Level 11, except they are applied only to arithmetic operations whose results do not exceed 31 (integer + precision) digits.

Compatibility for Architecture Level 10 and 11

When ARCH=10 is used, the Natural Optimizer Compiler generates machine instructions introduced with the Decimal-Floating-Point (DFP) Zoned-Conversion Facility or the DFP Packed-Conversion Facility. These instructions execute faster than the standard machine code instructions for arithmetic operations, but they do not accept data which is improper in terms of the zoned numeric data type (N).

This may cause runtime errors, when an N-field is defined within a REDEFINE section of an alpha or binary variable and the N-field is not properly initialized before used in an arithmetic operation.

A numeric zoned field carries one digit in one byte. Usually, each byte contains x’F’ in the left halfbyte (Zone bits) and the digit value (0-9) in the right halfbyte (Numeric bits). This applies for all bytes, except for the last one, which contains (A-F) in the left halfbyte (Sign bits).

A sign halfbyte (C,A,F,E) represents a positive value, whereas (B,D) stands for a negative value. A value other than (0-9) inside the numeric halfbytes (N) and a value other than (A-F) inside the sign halfbyte (S) is considered invalid. The data inside the zone halfbytes (Z) is not regarded by arithmetic conversion instructions and can have any value (0-F).

Example for a variable defined as (N6):

ZN ZN ZN ZN ZN SN Sign is Value is Works with ARCH<=9 Works with ARCH>=10
F1 F2 F3 F4 F5 F6 F=positive 123456, ok yes yes
F3 F2 F6 F3 F3 D2 D=negative 323662, ok yes yes
40 40 40 40 40 40 4=invalid 000000, ok yes NAT7024
00 00 00 00 00 00 0=invalid 000000, ok yes NAT7024
12 13 14 15 16 17 1=invalid 234567, ok yes NAT7024
51 6B 72 7A 12 F1 F=positive 1B2A21, invalid NAT0954 NAT7024

When ARCH=9 (or lower) is used, invalid sign halfbytes (0-9) are automatically corrected by the generated code to a positive sign (F). This turns N-fields with a blank contents into valid data with value zero. The same applies for Hexa zero data.

When ARCH=10 (or 11) is used, invalid sign halfbytes (0-9) remain unchanged and lead to a program check (Data exception) when accessed by a DFP instruction. If such an abend occurs, Natural issues a NAT7024 error instead of a NAT0954 to clearly indicate that the error is caused by an N-variable that does not contain valid numeric data.

If a numeric halfbyte (N) contains a value other than (0-9), a program check (Data exception) happens regardless of the ARCH level used.

Conclusion:

Do not use ARCH=10 (or 11) to catalog a program which operates unclean numeric data, with a sign value other than (A-F).

For example:

OPTIONS MCG=(PGEN,ARCH=9)                                          
DEFINE DATA LOCAL                                                  
1 #A (A6)                                                          
1 REDEFINE #A                                                      
  2 #N (N6)                                                        
END-DEFINE                                     /*  ARCH=9  ARCH=10 
#A := H'F1F2F3F4F5F6'   ADD 1 TO #N  WRITE #N  /*  ok       ok     
#A := H'F3F2F6F3F3D2'   ADD 1 TO #N  WRITE #N  /*  ok       ok     
#A := H'404040404040'   ADD 1 TO #N  WRITE #N  /*  ok       NAT7024
#A := H'000000000000'   ADD 1 TO #N  WRITE #N  /*  ok       NAT7024
#A := H'121314151617'   ADD 1 TO #N  WRITE #N  /*  ok       NAT7024
#A := H'516B727A12F1'   ADD 1 TO #N  WRITE #N  /*  NAT0954  NAT7024
END

Moreover, when ARCH=10 (or 11) is used, Natural can issue a NAT1305 (truncated numeric value) instead of a NAT1301 error (intermediate result too large) for the following reason: The DFP numeric format is used for calculating intermediate results and an overflow is only detected at the end of the arithmetic operation when the DFP is converted into the format of the result.

Compatibility for Architecture Level 12

When ARCH=12 is used, the Natural Optimizer Compiler generates machine instructions introduced with the Vector Packed-Decimal Facility (VPD) which are compatible in terms of data incorrectness with the code generated with ARCH=9 or below.

Numeric data fields (N) with incorrect sign representations (0-9) are converted into the positive sign value (F). This accepts numeric fields with a blank or hex00 content and treats them as value zero. A data exception (abend) does not occur in these cases.

Prerequisites for Code Generation with Unicode Operands

The Natural Optimizer Compiler generates optimized code for Natural statements with Unicode strings if the following requirements are met:

Statement Requirement
All statements All operands used in the statement must be of the type Unicode.
EXAMINE The ARCH option must be set to a value greater than or equal to 6.
IF

DECIDE FOR

DECIDE ON

  • All Unicode character strings must be normalized.

  • The ARCH option must be set to a value greater than or equal to 5.

  • The UNICC option must be set to ON or FORCE.

  • The COLLATE option of the CFICU profile parameter must be set to OFF (see the Parameter Reference documentation).

MOVE

MOVE SUBSTRING

RESET

The ARCH option must be set to a value greater than or equal to 5.

UNICC Option

The UNICC option controls the generation of optimized code for IF, DECIDE FOR and DECIDE ON statements that contain Unicode operands.

Valid values for UNICC are:

Value Explanation
ON Generates optimized code and checks whether COLLATE=OFF is set (see the CFICU profile parameter in the Parameter Reference documentation).

If COLLATE=ON is set, execution of the optimized code will fail with a NAT7023 Natural system error.

FORCE Generates optimized code analogous to ON but without COLLATE=OFF check.

The code optimized with FORCE performs better than the code optimized with ON but can cause wrong results if COLLATE=ON is set.

OFF Optimized code is not generated.

OFF is the default setting.