The Compilation Process
HPC and Data for Lattice QCD
The Compilation Process
General description
The NLCC compiler comes with a set of programs handling at different stage a C application.
-
ncpp: performs a the preprocessing and remove bodies of unused functions using a “cflow” header.
-
lcc: is a wrapper for the preprocessing and the C compilation. It is independent of any context and generate a high level assembly code (SASM).
-
nlcc: is the main compiler, calling all the compilation chain and generating a binary for the machine (MEM file).
-
rcc: is the core compiler taking a propreprocessed file and generating the Apenext assembly. This program is not supposed to be used directly.
ncpp, the preprocessor.
This program perform a C preprocessing of the code and extract unused function of the code generation.
The C preprocessing.
Ncpp does not include a C preprocessor and for this it relies on an external tool. The external preprocessing tool must be called “cpp” and is seached in the following search path in this order:
-
${lccdir}/
-
${lccdir}/../lib/nlcc/
-
${lccdir}/../nlcc/
-
/usr/bin/
-
/usr/ccs/lib/
The ${lccdir} variable is extracted from the directory in which ncpp is stored. It is the expected installation directory.
The preprocessing procedure
The preprocessing procedure try to extract from the C code all unused function. For this these functions must use a special header called the “cflow” header. In For a file “myfilename.h” where we have a function called “my_function” the syntax is the following:
#if !defined(__cflow_processed) || defined(_uses_my_function_myfilename_h)
inline void my_function(int i) { ... }
#endif
The nlcc preprocessing will first perform a general preprocessing that will include all functions. Then an internal library of “prcc” will extract all functions called inside each function body. The result is then analysed by the prcg that created the call graph and generate .D containing all needed definitions for a second C preprocessing.
The .D file contains a list of preprocessing definitions activating needed functions. In our case, if “my_function” is used, it would contain:
#define _uses_my_function_myfilename_h
Command line options
Option |
Description |
---|---|
-o <file> |
Specify a destination |
-k |
Keep intermediate files |
-V |
Print the version |
<cpp options> |
All preprocessing options will be forwarded to the preprocessor |
-tempdir=<dir> |
place temporary files in `dir/', default is /tmp |
-v |
show commands as they are executed; 2nd -v suppresses execution |
lcc, the simple C compiler.
This program perform the compilation of a C code until the high level assembly. Basically, it is in charge of calling the preprocessing and the C compiler and do not perform any further transformation, making it independent of all other Apenext tools.
Command line options
Option |
Description |
---|---|
-A |
warn about nonANSI usage; 2nd -A warns more |
-Bdir/ |
use the compiler named `dir/rcc' |
-E |
run only the preprocessor on the named C programs and unsuffixed files |
-dn |
set switch statement density to `n' |
-g |
produce symbol table information for debuggers |
-gl |
request the print of C source code lines in sasm file. |
-gp |
like -gl but compatible with nperf. |
-Ob=n |
burst memory access up to size n (not yet) |
-Or[=(off|on)] |
optimized register usage |
-Ol[=(off|on)] |
local memory access |
-Oa[=<n>] |
align memory blocks to <n> words (default 4) |
-Oc[=(off|on)] |
do complex normalization (may introduce numerical errors !) |
-O |
Perform some optimisations, equivalent to -Ol -Or -Oa -Oc |
-physregs |
allocate physical registers for variables (default) |
-virtregs |
use only virtual registers |
-o file |
leave the output in `file' |
-k |
keep all files locally |
-P |
print ANSI-style declarations for globals |
-nostdinc |
do not search the standard directories for #include files |
-w |
suppress warnings |
-Woarg |
specify system-specific `arg' |
-W[pf]arg |
pass `arg' to the preprocessor or the compiler |
-W[pf]=exe |
use 'exe' as the (full) path for the preprocessor or the compiler |
<cpp option> |
all kind of options accepted by ncpp. |
-help or -? |
print this message |
-V |
show version |
-tempdir=<dir> |
place temporary files in `dir/', default is /tmp |
-v |
show commands as they are executed; 2nd -v suppresses execution |