Compilers on Rivanna
Rivanna offers multiple compiler bundles for C, C++, and Fortran. Different compilers have different strengths and weaknesses and different error messaging and debugging features, so users should be willing to try another one when appropriate. The modules system manages the compiler environment and ensures that only compatible libraries are available for loading.
Many users of compiled languages are working with codes that can employ MPI for multinode parallel runs. MPI users should first understand how their chosen compiler works, then see the MPI instructions at our parallel programming page.
Compiled languages can be more difficult to debug, and the assistance of a good debugger can be essential.
Building Your Code on Rivanna
Building your Application Creating an executable from source with a compiled language requires two steps, compiling and linking. The combination of these is generally called building. The output of the compiler is generally an object file, which on Unix will end in a .o suffix. Object files are machine code and are not human-readable, but they are not standalone and cannot be executed. The linker, which is usually invoked through the compiler, takes all object files, along with any external libraries, and creates the executable (also called a binary).
Compilers are invoked on source files with a line such as
Debuggers and Profilers
Debuggers To use a debugger, it is necessary to rebuild your code with the -g flag added. All object files must be removed anytime compiler flags change. If you have a Makefile run make clean if it is available. The program must then be run under the control of the debugger. For example, if you are using gdb, you run
gdb ./myexec Adding debugging flags generally disables any optimization flags you may have added, and can slow down the code. Please remember to recompile with -g removed once you have found your bugs.
Gnu Debugger (gdb) and Profiler (gprof) The Gnu Compiler Collection compilers are free, open-source tools.
Compiling for a GPU Using a GPU can accelerate a code, but requires special programming and compiling. Several options are available for GPU-enabled programs.
OpenACC OpenACC is a standard
Available NVIDIA CUDA Compilers ModuleVersion Module Load Command cuda10.2.89 module load cuda/10.2.89 cuda11.4.2 module load cuda/11.4.2 cuda12.2.2 module load cuda/12.2.2 ModuleVersion Module Load Command nvhpc23.7 module load nvhpc/23.7 nvhpc24.1 module load nvhpc/24.1 GPU architecture According to the CUDA documentation, “in the CUDA naming scheme, GPUs are named sm_xy, where x denotes the GPU generation number, and y the version in that generation.