This chapter and Chapter 5, “Additional Development Tools” describe the similarities and differences between the development tools environments found on IRIX and ProPack (Linux) on Altix systems. This chapter concentrates on the compilation process and tools available for Altix systems while Chapter 5, “Additional Development Tools” outlines other development tools. Both chapters provide links to more detailed information available on the Web as well as in other SGI Technical Publications.
The development process can be thought of as a chain of processes aided by a variety of software tools. shows this in table form.
Table 4-1. Development Process
Activity | Tools | IRIX versions | Linux versions |
|---|---|---|---|
Source code development | Editors | vi, emacs, jot, etc | vi, emacs, etc. |
Executable creation | Compilers | cc, CC, f77, f90 | ecc, gcc, efc/ifort, g77 |
Object file creation | Assemblers | as | ias, as |
Linkage | Linker | ld | ld |
Archiving | Archiver | ar | ar |
Object file inspection | Object tools | elfdump, dwarfdump | objdump |
Debugging | Debuggers | dbx, cvd | gdb, idb, ddd, DDT |
Performance analysis | Profilers | SpeedShop, perfex | VTUNE, perfmon, histx |
Automation | Make | make, smake, pmake | gmake |
Environment configuration | Scripts/tools | modules | modules |
A variety of editors are supported on both IRIX and Linux platforms. The two most common UNIX editors, vi(1) and emacs(1) are available on both platforms.
Compilers for Altix fall into two major categories:
Proprietary compilers from Intel
Open Source compilers from the Free Software Foundation (GNU)
Intel provides compilers that support C/ C++, and Fortran95. For information, see http://www.intel.com/software/products/compilers/linux/
As of this writing Intel has delivered the 8.0 Compilers which offer a new Fortran95 front-end compatible with Compaq Visual Fortran 6.6.
Table 4-2 shows the various releases of the Intel compilers. It should be noted that the 8.0 Fortran compiler is not binary compatible with the earlier 7.x compilers and you will need to recompile your application to work with libraries compiled with Intel Fortran95 version 8.0.
Table 4-2. Intel Compiler Versions
Version | Date of Release |
|---|---|
7.0 Compilers | November 2002 |
7.1 Compilers | March 2003 |
8.0 Compilers | December 2003 |
The compilers themselves can be installed in a modules environment (also available on IRIX), which allows several versions to co-exist.
The following script called run_latest shows an example of the use of modules. This script sets up a C-shell modules environment where the 8.0 compilers are configured to be the default (the 8.0 Intel compilers were installed in a module called intel-compilers-8):
Example 4-1. Script to Set Up C-shell Modules Environment
%cat run_latest source /sw/com/modules/init/csh # to set up module command module avail # to display what are on a system module load intel-compilers-8 # make 8.0 default compilers |
The example /sw/com/modules/init/csh script initializes the modules environment with locations where the various modules are installed.
Example 4-2. Script to Initialize Modules Environment
% cat /sw/com/modules/init/csh
# Generated automatically from csh.in by configure.
if ( $?tcsh ) then
set modules_shell = “tcsh”
else
set modules_shell = “csh”
endif
set exec_prefix=”/sw/com/modules”
if ( $?histchars ) then
set histchar = `echo $histchars | cut -c1`
set _histchars = $histchars
alias module `unset histchars; \
eval `$exec_prefix/bin/modulecmd $modules_shell `$histchar'*`; \
set histchars = $_histchars'
unset histchar
else
alias module `eval `$exec_prefix/bin/modulecmd $modules_shell \!*`'
endif
setenv MODULESHOME /sw/com/modules
if (! $?MODULEPATH ) then
setenv MODULEPATH /sw/com/modulefiles
endif
if (! $?LOADEDMODULES ) then
setenv LOADEDMODULES
endif
|
The command names of the compiler are given below. They are different from the cc, CC, f77 and f90 compiler commands available on IRIX.
The ecc command can be used on both c and C++ filenames, while the efc command works on a variety of Fortran suffixes. Example 4-3 summarizes the command line syntax for the Intel 7.x Compilers.
Example 4-3. Compiler Command Line Syntax For Intel Version 7.x Compilers
ecc [ option(s) ] filename.{c|C|cc|cpp|cxx|i}
efc [ option(s) ] filename.{f|for|ftn|f90|fpp}
|
For the Intel 8.0 compilers, the command names have been changed to ifort and icc respectively though the old names will also be accepted. (A warning will be generated however, and Intel reserves the right to stop supporting the 7.x command names in a future release.) Example 4-4 summarizes these commands.
Example 4-4. Compiler Command Line Syntax For Intel Version 8.0 Compilers
icc [ option(s) ] filename.{c|C|cc|cpp|cxx|i}
ifort [ option(s) ] filename.{f|for|ftn|f90|fpp}
|
The GNU compilers are provided by the Free Software Foundation. They have been ported to a variety of architectures and offer easy migration to and from other platforms. The Linux kernel itself and various other system utilities on ProPack are compiled with gcc.
The URL http://www.gnu.org/directory/gcc.html is the top level web site for the gcc compilers.
The GNU compiler command names are different from the MIPSpro compilers on IRIX and the Intel compilers, though they are standard on all GNU supported platforms. Example 4-5 summarizes these commands.
Example 4-5. Compiler Command Line Syntax for the GNU Compilers
gcc [ option(s) ] filename.{c|C|cc|cxx|m|i}
g++ [ option(s) ] filename.{c|C|cc|cxx|m|i}
g77 [ option(s) ] filename.{f|for|fpp|F}
|
Compilers provide common programming environments through the support of standards. Non-standard features are called extensions. Normally vendors provide features outside of the standards to provide capabilities that are not possible to achieve with standard compliant code. Another reason for extensions are to provide access to unique performance enhancing capabilities. Finally extensions are often provided to ensure capabilities with obsoleted features that have been removed from more current standards.
The Intel compilers support the new ANSI C Standard (1999) or C99 with the -c99 flag (or by setting -std=c99). This is on by default on Altix whereas under MIPSpro 7.4.x on IRIX the -c99 flag or c99 command had to be used. Also supported is the older ANSI Standard (1989) c89 as well as Amendment 1 (1990).
The GNU Compilers offer compatibility with the C89 standard and limited support of C99. For information, see http://gcc.gnu.org/onlinedocs/gcc-3.3.2/gcc/Standards.html#Standards and http://gcc.gnu.org/gcc-3.3/c99status.html (which describes what features of c99 are supported when -std=c99 is used.
The GNU Compilers also offer a variety of extensions to the C language These features are often used in open source software and can be thought of as a standard in itself. For more information see: http://gcc.gnu.org/onlinedocs/gcc-3.3.2/gcc/C-Extensions.html#C%20Extensions.
The Intel C compiler provides a large level of compatibility with gcc. In general one can freely mix object files compiled with the Intel compilers and those built with gcc. For more information see: Intel Compilers for Linux: Compatibility with GNU Compilers at http://www.intel.com/software/products/compilers/techtopics/LinuxCompilersCompatibility702.htm .
Table 4-3 summarizes the standards compliance by the different compilers.
Table 4-3. C Language Standard Support Summary
Standard | Intel | MIPSpro | GNU |
|---|---|---|---|
C89 | X | X | X |
C99 | X | X | partial |
GNU extensions | many | some | X |
OpenMP1.0 | X | X |
|
OpenMP2.0 | X | X |
|
The Intel compilers support the ANSI C++ Standard (1998) with the exception of the export keyword. In general this is a superset of the ANSI standard compliance provided by the MIPSpro 7.4.x C++ compiler (under the default -LANG:std=on setting).
The GNU compilers offer a variety of extensions to standard C++. For more information see: http://gcc.gnu.org/onlinedocs/gcc-3.3.2/gcc/C-Extensions.html#C++%20Extensions
The Intel compilers support the ANSI FORTRAN77, Fortran90 and Fortran 95 standards. They also provide support for a new Fortran2003 feature. In addition, the Intel compilers provide the ability to handle both big and little endian files. This allows the program to handle data files generated on IRIX (big endian) system. A set of environment variables control whether files are read in big or little endian mode, as shown in the following examples:
% setenv F_UFMTENDIAN big # READS and WRITES big endian files % setenv F_UFMTENDIAN big:10 # perform conversion only on unit 10 |
On IRIX there were two different Fortran compiler products. MIPSpro FORTRAN77 provided support for the FORTRAN77 standard as well as various VAX extensions. MIPSpro Fortran90, despite its name, provided support for almost all of Fortran95 in addition to Fortran90 (as it name implies) and FORTRAN77. The IRIX man page f77.f90.difs(5) provided detailed information about the differences in language support between MIPSpro FORTRAN77 and MIPSpro Fortran90.
The GNU compilers provide FORTRAN77 support, some Fortran90 features and some extensions. For more information see: http://gcc.gnu.org/onlinedocs/gcc-3.3.2/g77/Language.html#Language
Table 4-4 summarizes the standards compliance and provision of extensions by the various compilers
Table 4-4. Fortran Language Standard Support Summary
| MIPSpro | MIPSpro | Intel | g77 |
|---|---|---|---|---|
Fortran2003 |
|
| [a] |
|
Fortran95 |
| X [b] | X |
|
Fortran90 |
| X | X | a |
Vax Extensions | X |
| X |
|
ACCESS='KEYED' | X |
|
|
|
CRAY pointers | X | X | X |
|
VOLATILE keyword |
| X | X |
|
FORTRAN77 | X | X | X | X |
Hollerith constants | X | X | X |
|
Cross Endian support |
|
| X |
|
POSIX Interfaces | a | X | X |
|
Options for default size of integer and real (-i8, -r8) | X | X | X |
|
[a] Some functionality is provided [b] Some caveats apply | ||||
OpenMP is a standard set of programming directives, application program interfaces and environment variables that provide a portable interface for developing parallel applications on shared memory systems. For more information see http://www.openmp.org/ .
Both the MIPSpro 7.4 Fortran90 and Intel Fortran compilers support the OpenMP 2.0 standard with some restrictions. The MIPSpro compilers will serialize nested parallel regions. The Intel compiler does not support the WORKSHARE directive. Also, the MIPSpro compilers supported proprietary data distribution directives which are not supported by the Intel compilers.
In addition to the standard OpenMP directives and environment variables, the Intel Compilers support the following environment variables as extensions:
| KMP_LIBRARY | Selects the OpenMP run-time library throughput | |
| KMP_STACKSIZE | Sets the number of bytes to allocate for each parallel thread. (Default is 4megabytes) This is similar to the MP_SLAVE_STACKSIZE environment variable under MIPSpro. |
The GNU compilers do not support any OpenMP directives or environment variables.
Although there are many differences between the set of flags that each compiler supports, there are also flags common to all three compilers (MIPSpro, Intel, GNU). Table 4-5 summarizes this list.
Table 4-5. Common Compiler Flags on IRIX and Linux (Both Intel and GNU)
-ansi | Support all ANSI standard C programs |
-c | Compiles but does not link. Creates a .o file. |
-Dmacro | Define macro on command line |
-I dir_name | Searches for include files in dir_name |
-g | Produces symbolic information for debugging |
-help | Print list of compiler options. (--help with gcc) |
-L dir_name | instruct linker to search dir_name for libraries. |
-M | Generate makefile dependency lines for each source file. |
-o file_name | Creates output file with file_name.. |
-O | Invokes default optimization level. |
-S | Creates assembly language (.s) file. |
-Umacro | Undefine macro. |
-v | Verbose. Prints the passes as they execute with their arguments and their input and output files. |
-W | Suppress warning information. |
The MIPSpro and Intel compilers also provide many of the same types of functionality, often through the use of similar but slightly different flags. Table 4-6 summarizes these compiler flags.
Table 4-6. Similar Compiler Flags on MIPSpro and Intel compilers
| MIPSpro | Intel |
|---|---|---|
Automatic parallelization | -apo | -parallel |
Check array bounds | -C | -CB |
Turn warnings into errors | -diag_error | -Werror |
Use Fortran preprocessor | -ftpp | -fpp |
Interprocedural optimization | -ipa | -ipo |
Interpret OpenMP directives | -mp | -openmp |
Select optimizations that enhance performance | -Ofast | -fast |
Set maximum number of times to unroll loops | -OPT:unroll_times_max=n | -unrolln |
Provide compiler version | -V (with no file) | -V |
There is a small set of flags which are common to the MIPSpro and Intel compilers but which have completely different meanings. These flags are described in Table 4-7.
Table 4-7. Conflicting Compiler Options
Flag | MIPSpro meaning | Intel meaning |
|---|---|---|
-C | Check array bounds. | Preserve comments in preprocessed source output. |
-mp | Cause the compiler to recognize multiprocessor directives. | Restrict optimizations in floating point applications to ensure arithmetic conforms to IEEE standards. |
-static | Statically allocate all local variables. | Use the static library for linking |
Finally, there are those flags that are available only on the Intel compilers. Table 4-8 provides a partial list of these flags.
-auto | Direct all local variables to be automatic (Fortran) |
-EP | Direct the preprocessor to expand source and output it to standard output, but #line directives are not included in the output. (-EP is equivalent to -E -P.) |
-convert keyword | Specifies format of unformatted files containing numerical data. |
-fno-alias | Use pointers with no aliasing in C. |
-ftz | Force flushing of denormalized results to zero. |
-IPF_Fltacc | Disable optimizations that affect floating-point accuracy. |
-opt_report | Generate an optimization report and direct it to stderr (or to file if -opt_report_file is specified. |
-safe_cray_pointer | No aliasing for Cray pointers. (Fortran) |
-stack_temps | Allocate arrays on stack. (Fortran) |
-Wp64 | Print diagnostics for 64-bit porting. |
Table 4-9 provides s a subset of directives that are supported by the Intel compilers which may aid in tuning or debugging applications:
The Fortran form for these directives is the following:
cdir$ directive_name |
The C form for these directives is the following:
#pragma pragma_name |
The directive_name and pragma_name variables are the same. For brevity, Table 4-9 provides the Fortran form only.
Table 4-9. Compiler Directives for Tuning and Debugging
cdir$ ivep | Ignore vector dependencies |
cdir$ swp | Try to software pipeline an inner loop |
cdir$ noswp | disable software pipelining |
cdir$ loop count N | Software pipelining hint |
cdir$ distribute point | Split large loop |
cdir$ unroll N | Unroll loop N times |
cdir$ nounroll | Do not unroll loop |
cdir$ prefetch A | Prefetch Array A |
cdir$ noprefetch A | Do not prefetch array A |
For more information about these and other directives supported by the Intel Compilers see “Chapter 14 Directive Enhanced Compilation, Intel Fortran Language Reference” at http://www.intel.com/software/products/compilers/flin/docs/for_lang.htm .
Both Intel and GNU provide assemblers for IA64. The Intel assembler is called ias; the GNU assembler is called as. The Intel compiler normally bypasses calling the assembler by directly compiling into a an object file, while gcc normally creates an assembly language file (.s) and then calls the assembler to assemble it into an object file.
Since assembly language programming is inherently unportable, you will need to entirely rewrite assembly language code when porting from IRIX to Altix. A clear understanding of the machine architecture is required.
More information about the Intel assembler can be found at: http://www.intel.com/software/products/opensource/tools1/tol_white.htm .
More information about the GNU assembler can be found by consulting its man page:
%man as |
The GNU linker ( /usr/bin/ld ) is used by both the Intel compiler and gcc to combine a number of object files and archives into an executable. It supports the standard -Ldirectory and -lname options to specify which directory to search for libname.a or libname.so, as well as the -oexecutable option to name the resulting executable file.
The ld linker also supports a variety of options which in general, are different from the MIPSpro linker. (It should also be mentioned that the GNU linker is more sensitive to the order of libraries given on the command line than its MIPSpro counterpart.)
For options whose names are a single letter, option arguments must either follow the option letter without whitespace, or be given as separate arguments immediately following the option that requires them.
For options whose names are multiple letters, either one dash or two can precede the option name; for example, -trace-symbol and --trace-symbol are equivalent.
If the linker is being invoked by either the Intel compiler or gcc then all of the linker command line options should be provided and prefixed by -Wl.
For more information on the GNU linker, consult the ld(1) man page.