26.11.2012 Views

Compiler Usage Guidelines for 64-Bit Operating Systems on AMD64 ...

Compiler Usage Guidelines for 64-Bit Operating Systems on AMD64 ...

Compiler Usage Guidelines for 64-Bit Operating Systems on AMD64 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

32035 Rev. 3.22 November 2007<br />

<str<strong>on</strong>g>Compiler</str<strong>on</strong>g> <str<strong>on</strong>g>Usage</str<strong>on</strong>g> <str<strong>on</strong>g>Guidelines</str<strong>on</strong>g> <str<strong>on</strong>g>for</str<strong>on</strong>g> AMD<str<strong>on</strong>g>64</str<strong>on</strong>g> Plat<str<strong>on</strong>g>for</str<strong>on</strong>g>ms<br />

Fortran and C/C++ arrays also use different storage methods. Fortran uses column-major order, and<br />

C/C++ uses row-major order. This poses no problems <str<strong>on</strong>g>for</str<strong>on</strong>g> <strong>on</strong>e-dimensi<strong>on</strong>al arrays. For twodimensi<strong>on</strong>al<br />

arrays, where there are an equal number of rows and columns, simply reverse the row<br />

and column indices. For arrays other than single dimensi<strong>on</strong>al arrays, and square two-dimensi<strong>on</strong>al<br />

arrays, inter-language functi<strong>on</strong> mixing is not recommended.<br />

Linking Fortran Modules with C/C++ Main Programs<br />

You must explicitly link in the PGI Fortran runtime support libraries when linking pgf90-compiled<br />

program units into C or C++ main programs (C/C++ calling Fortan) using the switches -lpgf90, -<br />

lpgf90_rpm1, -lpgf902, -lpgf90rtl, and -lpgftnrtl. When linking pgf77-compiled program units into<br />

C or C++ main programs, you need to use <strong>on</strong>ly the -lpgftnrtl switch.<br />

4.1.2 Run-Time Errors<br />

Does your program expect <str<strong>on</strong>g>64</str<strong>on</strong>g>-bit integers?<br />

By default, the Fortran INTEGER data-type is a 32-bit entity in AMD<str<strong>on</strong>g>64</str<strong>on</strong>g>. If a program expects<br />

INTEGER to be a <str<strong>on</strong>g>64</str<strong>on</strong>g>-bit entity (e.g., programs ported from some <str<strong>on</strong>g>64</str<strong>on</strong>g>-bit architecture, such as Alpha),<br />

use the -i8 switch. The -i8 switch makes all integers <str<strong>on</strong>g>64</str<strong>on</strong>g>-bit entities. This switch is <strong>on</strong>ly available <str<strong>on</strong>g>for</str<strong>on</strong>g><br />

the PGI Fortran compiler (pgf90).<br />

Are you receiving a run-time error?<br />

Check <str<strong>on</strong>g>for</str<strong>on</strong>g> array overruns. Run-time errors can be caused by accessing arrays out-of-bounds. Use the<br />

switch -Mbounds to generate code <str<strong>on</strong>g>for</str<strong>on</strong>g> checking array bounds.<br />

4.1.3 Compiled and Linked Code Generates Unexpected Results<br />

Are you generating vectorized code?<br />

For some loops, vectorizati<strong>on</strong> can cause a slight difference in results due to the reordering of floatingpoint<br />

operati<strong>on</strong>s. Using the switch combinati<strong>on</strong> -tp=k8-<str<strong>on</strong>g>64</str<strong>on</strong>g> and -fastsse may cause vectorizati<strong>on</strong>. Try<br />

using the n<strong>on</strong>-vectorizing switch combinati<strong>on</strong> -tp=k8-<str<strong>on</strong>g>64</str<strong>on</strong>g>, -Mscalarsse, and -fast as a diagnostic step<br />

instead. As an alternative to the vectorizing switches, use the n<strong>on</strong>-vectorizing switches if their use<br />

causes your code to give the correct, expected behavior.<br />

Does your program require floating-point divisi<strong>on</strong>s c<strong>on</strong><str<strong>on</strong>g>for</str<strong>on</strong>g>ming to the IEEE 754 standard?<br />

Use the -Kieee=strict switch to generate floating-point divisi<strong>on</strong>s that are strictly compliant with the<br />

IEEE 754 standard.<br />

Does your program rely <strong>on</strong> x87 features?<br />

The -fastsse switch instructs the compiler to use SSE2 registers and instructi<strong>on</strong>s. If the results of a<br />

program do not match your expectati<strong>on</strong>s when using SSE2 registers and instructi<strong>on</strong>s, the program<br />

may rely <strong>on</strong> some x87 features.<br />

Chapter 4 Troubleshooting and Portability Issues 43

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

Saved successfully!

Ooh no, something went wrong!