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

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

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

v<br />

– If any automatic variables in the called procedures are involved in an<br />

EQUIVALENCE statement<br />

– If the same variable argument is passed more than once in the same call: <strong>for</strong><br />

example, CALL SUB(X,Y,X)<br />

Some procedures that use computed GO TO statements, where any of the<br />

corresponding statement labels are also used in an ASSIGN statement, might<br />

not be inlined.<br />

To change the size limits that control inlining, you can specify -qipa=limit=n,<br />

where n is 0 through 9. Larger values allow more inlining.<br />

It is possible that C/C++ functions can be inlined into <strong>Fortran</strong> programs and<br />

visa-versa during link-time optimizations. The C/C++ code would have to be<br />

compiled using the <strong>IBM</strong> <strong>XL</strong> C/C++ compilers with -qipa and a compatible option<br />

set to that used in the <strong>XL</strong>F compilation.<br />

Shared-memory Parallelism (-qsmp)<br />

Some <strong>IBM</strong> processors are capable of shared-memory parallel processing. Compile<br />

with -qsmp to generate the threaded code needed to exploit this capability. The<br />

option implies a -O2 optimization level. The default behavior <strong>for</strong> the option<br />

without suboptions is to do automatic parallelization with optimization.<br />

The most commonly used -qsmp suboptions are summarized in the following<br />

table.<br />

Commonly used -qsmp suboptions<br />

Suboption<br />

Behavior<br />

auto<br />

Instructs the compiler to automatically generate parallel code where possible<br />

without user assistance. This option also recognizes all the SMP directives.<br />

omp<br />

En<strong>for</strong>ces compliance with the OpenMP <strong>Fortran</strong> API <strong>for</strong> specifying explicit<br />

parallelism. Note that -qsmp=omp is currently incompatible with -qsmp=auto.<br />

opt<br />

Instructs the compiler to optimize as well as parallelize. The optimization is<br />

equivalent to -O2 –qhot in the absence of other optimization options. The default<br />

setting of -qsmp is -qsmp=auto:noomp:opt.<br />

suboptions<br />

Other values <strong>for</strong> the suboption provide control over thread scheduling, nested<br />

parallelism, locking, and so on.<br />

Getting the Most out of -qsmp<br />

v<br />

v<br />

v<br />

v<br />

v<br />

v<br />

Use -qsmp=omp:noauto if you are compiling an OpenMP program and do not<br />

want automatic parallelization. By default, the parallelization per<strong>for</strong>med is both<br />

explicit and automatic.<br />

Be<strong>for</strong>e using -qsmp with automatic parallelization, test your programs using<br />

optimization and -qhot in a single-threaded manner.<br />

Always use the reentrant compiler invocations (the _r command invocations, like<br />

xlf_r) when using -qsmp.<br />

By default, the runtime uses all available processors. Do not set the<br />

<strong>XL</strong>SMPOPTS=PARTHDS or OMP_NUM_THREADS variables unless you want<br />

to use fewer than the number of available processors. You might want to set the<br />

number of executing threads to a small number or to 1 to ease debugging.<br />

If you are using a dedicated machine or node, consider setting the SPINS and<br />

YIELDS variables (suboptions of <strong>XL</strong>SMPOPTS) to 0. Doing so prevents the<br />

operating system from intervening in the scheduling of threads across<br />

synchronization boundaries such as barriers.<br />

When debugging an OpenMP program, try using -qsmp=noopt (without -O) to<br />

make the debugging in<strong>for</strong>mation produced by the compiler more precise. You<br />

Optimizing <strong>XL</strong> <strong>Fortran</strong> Programs 319

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

Saved successfully!

Ooh no, something went wrong!