12.07.2015 Views

PGI User's Guide

PGI User's Guide

PGI User's Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

Interprocedural Analysis and Optimization using –Mipa42% as -o file2.o file2.s% pgcc -Mipa=fast -S -o file3.s file3.c% as -o file3.o file3.s% pgcc -Mipa=fast -o a.out file1.o file2.o file3.oIn the last step, an IPA linker is invoked to read all the IPA summary information and perform theinterprocedural propagation. The IPA linker reinvokes the compiler on each of the object files to recompilethem with interprocedural information. This creates three new objects with mangled names:file1_ipa5_a.out.oo.o, file2_ipa5_a.out.oo.o, file2_ipa5_a.out.oo.oThe system linker is then invoked to link these IPA-optimized objects into the final executable. Later, if one ofthe three source files is edited, the executable can be rebuilt with the same command line:% pgcc -Mipa=fast -o a.out file1.c file2.c file3.cThis will work, but again has the side-effect of compiling each source file, and recompiling each object file atlink time.Building a Program with IPA - Several StepsJust by adding the –Mipa command-line switch, it is possible to use individual pgcc commands to compileeach source file, followed by a command to link the resulting object files into an executable:% pgcc -Mipa=fast -c file1.c% pgcc -Mipa=fast -c file2.c% pgcc -Mipa=fast -c file3.c% pgcc -Mipa=fast -o a.out file1.o file2.o file3.oThe pgcc driver invokes the compiler and assembler as required to process each source file, and invokes theIPA linker for the final link command. If you modify one of the source files, the executable can be rebuilt bycompiling just that file and then relinking:% pgcc -Mipa=fast -c file1.c% pgcc -Mipa=fast -o a.out file1.o file2.o file3.oWhen the IPA linker is invoked, it will determine that the IPA-optimized object for file1.o(file1_ipa5_a.out.oo.o) is stale, since it is older than the object file1.o, and hence will need to berebuilt, and will reinvoke the compiler to generate it. In addition, depending on the nature of the changesto the source file file1.c, the interprocedural optimizations previously performed for file2 and file3 may nowbe inaccurate. For instance, IPA may have propagated a constant argument value in a call from a functionin file1.c to a function in file2.c; if the value of the argument has changed, any optimizations basedon that constant value are invalid. The IPA linker will determine which, if any, of any previously created IPAoptimizedobjects need to be regenerated, and will reinvoke the compiler as appropriate to regenerate them.Only those objects that are stale or which have new or different IPA information will be regenerated, whichsaves on compile time.Building a Program with IPA Using MakeAs in the previous two sections, programs can be built with IPA using the make utility. Just add the commandlineswitch –Mipa, as shown here:OPT=-Mipa=fast a.out: file1.o file2.o file3.opgcc $(OPT) -o a.out file1.o file2.o file3.ofile1.o: file1.cpgcc $(OPT) -c file1.cfile2.o: file2.c

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

Saved successfully!

Ooh no, something went wrong!