24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

For example, you might compile a program like the one in “Selecting the<br />

Rounding Mode” on page 292 with this command if the program consistently uses<br />

round-to-plus-infinity mode:<br />

xlf95 -qieee=plus -qfloat=rrm changes_rounding_mode.f<br />

Duplicating the Floating-Point Results of Other Systems<br />

To duplicate the double-precision results of programs on systems with different<br />

floating-point architectures (without multiply-add instructions), specify the nomaf<br />

suboption of the -qfloat option. This suboption prevents the compiler from<br />

generating any multiply-add operations. This results in decreased accuracy and<br />

per<strong>for</strong>mance but provides strict con<strong>for</strong>mance to the IEEE standard <strong>for</strong><br />

double-precision arithmetic.<br />

To duplicate the results of programs where the default size of REAL items is<br />

different from that on systems running <strong>XL</strong> <strong>Fortran</strong>, use the -qrealsize option (page<br />

222) to change the default REAL size when compiling with <strong>XL</strong> <strong>Fortran</strong>.<br />

If the system whose results you want to duplicate preserves full double precision<br />

<strong>for</strong> default real constants that are assigned to DOUBLE PRECISION variables, use<br />

the -qdpc or -qrealsize option.<br />

If results consistent with other systems are important to you, include norsqrt and<br />

nofold in the settings <strong>for</strong> the -qfloat option. If you specify the option -O3, include<br />

-qstrict too.<br />

Maximizing Floating-Point Per<strong>for</strong>mance<br />

If per<strong>for</strong>mance is your primary concern and you want your program to be<br />

relatively safe but do not mind if results are slightly different (generally more<br />

precise) from what they would be otherwise, optimize the program with the -O<br />

option, and specify -qfloat=rsqrt:hssngl:fltint. The following section describes the<br />

functions of these suboptions:<br />

v<br />

v<br />

The rsqrt suboption replaces division by a square root with multiplication by the<br />

reciprocal of the root, a faster operation that may not produce precisely the same<br />

result.<br />

The hssngl suboption is the opposite of rndsngl; it improves the per<strong>for</strong>mance of<br />

single-precision (REAL(4)) floating-point calculations by suppressing rounding<br />

operations that are required by the <strong>Fortran</strong> language but are not necessary <strong>for</strong><br />

correct program execution. The results of floating-point expressions are kept in<br />

double precision where the original program would round them to<br />

single-precision. These results are then used in later expressions instead of the<br />

rounded results.<br />

To detect single-precision floating-point overflows and underflows, rounding<br />

operations are still inserted when double-precision results are stored into<br />

single-precision memory locations. However, if optimization removes such a<br />

store operation, hssngl also removes the corresponding rounding operation,<br />

possibly preventing the exception. (Depending on the characteristics of your<br />

program, you may or may not care whether the exception happens.)<br />

The hssngl suboption is safe <strong>for</strong> all types of programs because it always only<br />

increases the precision of floating-point calculations. Program results may differ<br />

because of the increased precision and because of avoidance of some exceptions.<br />

<strong>XL</strong> <strong>Fortran</strong> Floating-Point Processing 295

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

Saved successfully!

Ooh no, something went wrong!