Code Generation and Processor Architecture. The Portland Group PGI Compiler
ಜಾಹಿರಾತು
ಜಾಹಿರಾತು
Code Generation and Processor Architecture
Microsoft supplies installation packages, vcredist_x86.exe
and vcredist_x64.exe
, containing these runtime files. You can download these packages from www.microsoft.com.
Code Generation and Processor Architecture
The PGI compilers can generate much more efficient code if they know the specific x86 processor architecture on which the program will run. When preparing to deploy your application, you should determine whether you want the application to run on the widest possible set of x86 processors, or if you want to restrict the application to run on a specific processor or set of processors. The restricted approach allows you to optimize performance for that set of processors.
Different processors have differences, some subtle, in hardware features, such as instruction sets and cache size. The compilers make architecture-specific decisions about such things as instruction selection, instruction scheduling, and vectorization, all of which can have a profound effect on the performance of your application.
Processor-specific code generation is controlled by the
-tp
option, described in
“–tp <target> [,target...],” on page 199
. When an application is compiled without any
-tp
options, the compiler generates code for the type of processor on which the compiler is run.
Generating Generic x86 Code
To generate generic x86 code, use one of the following forms of the
-tp
option on your command line:
-tp px ! generate code for any x86 cpu type
-tp p6 ! generate code for Pentium 2 or greater
While both of these examples are good choices for portable execution, most users have Pentium 2 or greater
CPUs.
Generating Code for a Specific Processor
You can use the
-tp
option to request that the compiler generate code optimized for a specific processor. The
PGI Release Notes contains a list of supported processors or you can look at the
-tp
entry in the compiler output generated by using the
-help
option, described in “–help ,” on page 176
.
Generating Code for Multiple Types of Processors in One Executable
PGI unified binaries provide a low-overhead method for a single program to run well on a number of hardware platforms.
All 64-bit PGI compilers can produce PGI Unified Binary programs that contain code streams fully optimized and supported for both AMD64 and Intel EM64T processors using the
-tp
target option.
The compilers generate and combine multiple binary code streams into one executable, where each stream is optimized for a specific platform. At runtime, this one executable senses the environment and dynamically selects the appropriate code stream.
Executable size is automatically controlled via unified binary culling. Only those functions and subroutines where the target affects the generated code will have unique binary images, resulting in a code-size savings of
10-90% compared to generating full copies of code for each target.
108
Chapter 9. Distributing Files - Deployment
Programs can use PGI Unified Binary technology even if all of the object files and libraries are not compiled as unified binaries. Like any other object file, you can use PGI Unified Binary object files to create programs or libraries. No special start up code is needed; support is linked in from the PGI libraries.
The
-Mpfi
option disables generation of PGI Unified Binary. Instead, the default target auto-detect rules for the host are used to select the target processor.
PGI Unified Binary Command-line Switches
The PGI Unified Binary command-line switch is an extension of the target processor switch,
-tp
, which may be applied to individual files during compilation .
The target processor switch,
-tp
, accepts a comma-separated list of 64-bit targets and generates code optimized for each listed target.
The following example generates optimized code for three targets:
-tp k8-64,p7-64,core2-64
A special target switch,
-tp x64
, is the same as
-tp k8-64, p7-64s
.
PGI Unified Binary Directives and Pragmas
PGI Unified binary directives and pragmas may be applied to functions, subroutines, or whole files. The directives and pragmas cause the compiler to generate PGI Unified Binary code optimized for one or more targets. No special command line options are needed for these pragmas and directives to take effect.
The syntax of the Fortran directive is this: pgi$[g|r| ] pgi tp [target]...
where the scope is g (global), r (routine) or blank. The default is r, routine.
For example, the following syntax indicates that the whole file, represented by g, should be optimized for both k8_64 and p7_64.
pgi$g pgi tp k8_64 p7_64
The syntax of the C/C++ pragma is this:
#pragma [global|routine|] tp [target]...
where the scope is global, routine, or blank. The default is routine.
For example, the following syntax indicates that the next function should be optimized for k8_64, p7_64, and core2_64.
#pragma routine tp k8_64 p7_64 core2_64
109
110
ಡೌನ್ಲೋಡ್ ಮಾಡಿ
ಜಾಹಿರಾತು