ARCHIVED: Compile programs on Big Red 3 at IU
On this page:
- Available programming environments
- Use the Cray programming environment
- Use the GNU programming environment
- Use the Intel programming environment
- Use the PGI programming environment
- Get help
Available programming environments
Programming environments for the Cray, Intel, PGI, and GNU Compiler Collection (GCC) compilers are provided. Each programming environment defines system paths and environment variables specific to its associated compiler collection:
Programming environment module | Compiler collection |
---|---|
PrgEnv-cray |
Cray |
PrgEnv-intel |
Intel |
PrgEnv-pgi |
PGI |
PrgEnv-gnu |
GCC |
Once the desired programming environment module is loaded, use the appropriate compiler driver command to invoke the desired compiler; for information about each compiler driver command, see its manual page:
Compiler driver command | Description | Manual page |
---|---|---|
cc |
Invokes the C compiler for the currently loaded programming environment | man cc |
CC |
Invokes the C++ compiler for the currently loaded programming environment | man CC
|
ftn |
Invokes the Fortran compiler for the currently loaded programming environment | man ftn |
- To compile a program that will run on the compute nodes, you must use the appropriate compiler driver command. Do not directly invoke the Cray, GCC, Intel, or PGI compilers unless you intend to run your executable only on the login or service nodes. For example, if you compile a C++ code using
pgCC
org++
compiler instead of theCC
compiler driver command, the resulting executable will not run on the compute nodes. - The only switches that are common to all three compiler driver commands (and work across all programming environments) are
-shared
,-static
,-dynamic
, and-hugetlbfs
(which links 2 MB pages instead of the default 4 KB). Additionally, the Fortran compiler driver has a-default64
switch available that works across all programming environments; it promotes all integers and real numbers to a 64-bit default, and is compatible with the 64-bit MPI libraries.
The compiler driver commands also take most of the switches associated with the compilers they target, as determined by the currently loaded programming environment. For more, see the "Options and switches" sections in the following information about the Cray, GNU, Intel, and PGI programming environments.
Use the Cray programming environment
Setting up your user environment
The Cray programming environment module (PrgEnv-cray
) supplies the system paths and environment variables needed to use the Cray C, C++, and Fortran compilers on Big Red 3. To determine which programming environment is currently loaded, view the list of currently loaded modules; on the command line, enter:
module list
To switch to a programming environment that is not currently loaded, use the module swap
command; for example, on Big Red 3, to replace the default programming environment (PrgEnv-intel
) with the Cray programming environment (PrgEnv-cray
), on the command line, enter:
module swap PrgEnv-intel PrgEnv-cray
You can save your customized user environment so that it loads every time you start a new session; for instructions, see Use modules to manage your software environment on IU research supercomputers.
Examples
With the PrgEnv-cray
module loaded, use the cc
, CC
, and ftn
compiler driver commands to invoke the craycc
, crayCC
, and crayftn
compilers, respectively. For example:
- To compile the C program
my_program.c
to create the binarymy_program
, on the command line, enter:cc -o my_program my_program.c
- To compile the C++ program
my_program.CC
to create the binarymy_program
, on the command line, enter:CC -o my_program my_program.CC
- To compile the Fortran program
my_program.f95
to create the binarymy_program
, on the command line, enter:ftn -o my_program my_program.f95
crayCC
compiler instead of the CC
compiler driver command, the resulting executable will not run on the Big Red 3 compute nodes.
Options and switches
- Compiler driver switches: The only switches that are common to all three compiler driver commands (and work across all programming environments) are
-shared
,-static
,-dynamic
, and-hugetlbfs
(which links 2 MB pages instead of the default 4 KB). Additionally, the Fortran compiler driver has a-default64
switch available (it promotes all integers and real numbers to a 64-bit default, and is compatible with the 64-bit MPI libraries). - Cray compiler options: With the
PrgEnv-cray
module loaded, the compiler driver commands (cc
,CC
, andftn
) take many of the same options available to the Cray compilers they invoke. Additionally, you can access the manual page for each Cray compiler to view the options available to it; at the command prompt, enter:man craycc
man crayCC
man crayftn
Note:The Cray compiler switches are heavily treed. The top-level switches contain most legacy switches, such as-o
(output file),-O
(optimization; default is-O2
),-l
(library name), and-L
(library directory). Other switches, such as-e
(enable compiling options),-d
(disable compiling options), and-h
(arguments), have multiple sub-options.
Use the GNU programming environment
Setting up your user environment
The GNU programming environment module (PrgEnv-gnu
) supplies the system paths and environment variables needed to use the GCC C, C++, and Fortran compilers on Big Red 3. To determine which programming environment is currently loaded, view the list of currently loaded modules; on the command line, enter:
module list
To switch to a programming environment that is not currently loaded, use the module swap
command; for example, on Big Red 3, to replace the default programming environment (PrgEnv-intel
) with the GNU programming environment (PrgEnv-gnu
), on the command line, enter:
module swap PrgEnv-intel PrgEnv-gnu
You can save your customized user environment so that it loads every time you start a new session; for instructions, see Use modules to manage your software environment on IU research supercomputers.
Examples
With the PrgEnv-gnu
module loaded, use the cc
, CC
, and ftn
compiler driver commands to invoke the gcc
, g++
, and gfortran
compilers, respectively. For example:
- To compile the C program
my_program.c
to create the binarymy_program
, on the command line, enter:cc -o my_program my_program.c
- To compile the C++ program
my_program.CC
to create the binarymy_program
, on the command line, enter:CC -o my_program my_program.CC
- To compile the Fortran program
my_program.f95
to create the binarymy_program
, on the command line, enter:ftn -o my_program my_program.f95
g++
compiler instead of the CC
compiler driver command, the resulting executable will not run on the Big Red 3 compute nodes.
Options and switches
- Compiler driver switches: The only switches that are common to all three compiler driver commands (and work across all programming environments) are
-shared
,-static
,-dynamic
, and-hugetlbfs
(which links 2 MB pages instead of the default 4 KB). Additionally, the Fortran compiler driver has a-default64
switch available (it promotes all integers and real numbers to a 64-bit default, and is compatible with the 64-bit MPI libraries). - GCC compiler options: With the
PrgEnv-gnu
module loaded, the compiler driver commands (cc
,CC
, andftn
) take many of the same options available to the GCC compilers they invoke. Additionally, you can access the manual page for each GCC compiler to view the options available to it; at the command prompt, enter:man gcc
man g++
man gfortran
Use the Intel programming environment
Setting up your user environment
The Intel programming environment module (PrgEnv-intel
) supplies the system paths and environment variables needed to use the Intel C, C++, and Fortran compilers on Big Red 3. To determine which programming environment is currently loaded, view the list of currently loaded modules; on the command line, enter:
module list
To switch to a programming environment that is not currently loaded, use the module swap
command; for example, on Big Red 3, to replace the default programming environment (PrgEnv-cray
) with the Intel programming environment (PrgEnv-intel
), on the command line, enter:
module swap PrgEnv-cray PrgEnv-intel
You can save your customized user environment so that it loads every time you start a new session; for instructions, see Use modules to manage your software environment on IU research supercomputers.
Examples
With the PrgEnv-intel
module loaded, use the cc
, CC
, and ftn
compiler driver commands to invoke the icc
, icpc
, and ifort
compilers, respectively. For example:
- To compile the C program
my_program.c
to create the binarymy_program
, on the command line, enter:cc -o my_program my_program.c
- To compile the C++ program
my_program.CC
to create the binarymy_program
, on the command line, enter:CC -o my_program my_program.CC
- To compile the Fortran program
my_program.f95
to create the binarymy_program
, on the command line, enter:ftn -o my_program my_program.f95
icpc
compiler instead of the CC
compiler driver command, the resulting executable will not run on the Big Red 3 compute nodes.
Options and switches
- Compiler driver switches: The only switches that are common to all three compiler driver commands (and work across all programming environments) are
-shared
,-static
,-dynamic
, and-hugetlbfs
(which links 2 MB pages instead of the default 4 KB). Additionally, the Fortran compiler driver has a-default64
switch available (it promotes all integers and real numbers to a 64-bit default, and is compatible with the 64-bit MPI libraries). - Intel compiler options: With the
PrgEnv-intel
module loaded, the compiler driver commands (cc
,CC
, andftn
) take many of the same options available to the Intel compilers they invoke. Additionally, you can access the manual page for each Intel compiler to view the options available to it; at the command prompt, enter:man icc
man icpc
man ifort
Use the PGI programming environment
Setting up your user environment
The PGI programming environment module (PrgEnv-pgi
) supplies the system paths and environment variables needed to use the PGI C, C++, and Fortran compilers on Big Red 3. To determine which programming environment is currently loaded, view the list of currently loaded modules; on the command line, enter:
module list
To switch to a programming environment that is not currently loaded, use the module swap
command; for example, on Big Red 3, to replace the default programming environment (PrgEnv-intel
) with the PGI programming environment (PrgEnv-pgi
), on the command line, enter:
module swap PrgEnv-intel PrgEnv-pgi
You can save your customized user environment so that it loads every time you start a new session; for instructions, see Use modules to manage your software environment on IU research supercomputers.
Examples
With the PrgEnv-pgi
module loaded, use the cc
, CC
, and ftn
compiler driver commands to invoke the pgcc
, pgCC
, and pgf95
compilers, respectively. For example:
- To compile the C program
my_program.c
to create the binarymy_program
, on the command line, enter:cc -o my_program my_program.c
- To compile the C++ program
my_program.CC
to create the binarymy_program
, on the command line, enter:CC -o my_program my_program.CC
- To compile the Fortran program
my_program.f95
to create the binarymy_program
, on the command line, enter:ftn -o my_program my_program.f95
pgCC
compiler instead of the CC
compiler driver command, the resulting executable will not run on the Big Red 3 compute nodes.
Options and switches
- Compiler driver switches: The only switches that are common to all three compiler driver commands (and work across all programming environments) are
-shared
,-static
,-dynamic
, and-hugetlbfs
(which links 2 MB pages instead of the default 4 KB). Additionally, the Fortran compiler driver has a-default64
switch available (it promotes all integers and real numbers to a 64-bit default, and is compatible with the 64-bit MPI libraries). - PGI compiler options: With the
PrgEnv-pgi
module loaded, the compiler driver commands (cc
,CC
, andftn
) take many of the same options available to the PGI compilers they invoke. Additionally, you can access the manual page for each PGI compiler to view the options available to it; at the command prompt, enter:man pgcc
man pgCC
man pgf95
Note:Big Red 3 does not support the-Mprof=mpi
,-Mmpi
, and-Mscalapack
PGI compiler switches.
Get help
If you have questions about compilers on the IU research supercomputers or need help, contact the UITS Research Applications and Deep Learning team.
This is document bdnv in the Knowledge Base.
Last modified on 2023-08-13 07:17:25.