COMPILER ENVIRONMENT – PARAMPRAVEGA

Parampravega supports the GNU and Intel compilers on the CPU and High-Memory CPU nodes. On the GPU nodes, users can use Nvidia-CUDA and OpenACC compiler programming environment modules. The use of modules, together with compiler wrapper scripts, enables makefiles not to be changed whenever there is a change in the programming environment.

GNU Compiler: The GNU Compiler Collection (GCC) is widely used opensource collection including C(gcc),C++(g++) and Fortran(gfortran) compilers. The default version of GCC on the system is 4.8.5. Other versions of the GCC compiler suite can be viewed and accessed using modules.

Intel Compiler: Intel suite has C, C++, and Fortran compilers that are well suited for the system’s architecture. These compilers enable users build applications to exploit the architecture specificity of the system. The default version of these compilers on the system is 18.0.5.

NVIDIA CUDA Compiler (NVCC): NVCC is the compiler offered by Nvidia to build applications on their GPUs. CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA. It allows users to build applications to execute on a CUDA-enabled graphics processing unit(GPU).

OpenACC: Open Accelerators is a programming standard for parallel computing on accelerators. It is designed to simplify GPU Programming. The basic approach is to insert comments (Directives) into the code to offload computation onto GPUs and parallelize the code at the level of GPU (CUDA) cores.

Intel OneAPI: This toolkit is an add-on to the Intel oneAPI Base Toolkit, which is required for full functionality. It also includes access to the Intel Distribution for Python, the Intel oneAPI DPC++/C++ Compiler, powerful data-centric libraries, and advanced analysis tools. This toolkit delivers what developers need to build, analyze, optimize and scale HPC applications with the latest techniques in vectorization, multithreading, multi-node parallelization and memory optimization.

All these compiler environments are enabled for use through spack package. One can view version of compiler activated via ‘spack load’ command as explained below.

 

SPACK COMPILERS:

spack could build packages with multiple compilers and compiler versions. spack searches for compilers on your machine automatically the first time it is run. It does this by inspecting your path.

Users can see which compilers spack has found by running ‘spack compilers’ or ‘spack compiler list’. spack manages a list of available compilers on the system, detected automatically from the user’s PATH variable. The following screenshot illustrates some examples of using the spack command for listing compilers installed on the system.

Commands to load the Compilers in spack Explanation
spack load gcc@<version>
versions– gcc11.2.0,8.3.0,4.8.5
//To load gcc compilers
spack load intel@<version >
Version-2021.4.0,19.1.0,19.0.5.281,18.0.5
//To load Intel compilers
Spack load nvhpc@<version>
Version- 21.11
//To load nvhpc compiler
spack load oneapi@<version>
version- 2021.4.0
//To load oneapi compiler

 

SPACK Compiler flags

spack accepts cppflags, cflags, cxxflags, fflags, ldflags, and ldlibs parameters. The values of these fields must be quoted on the command line if they include spaces. These values are injected into the compile line automatically by the spack compiler wrappers.

SETTING UP ENVIRONMENT

C Program:

Setting up of environment:
spack load intel-oneapi-compilers gcc@11.2.0
compilation: icc -O3 -xHost <<prog_name.c>>

C + OpenMP Program:

Setting up of environment:
spack load intel-oneapi-compilers gcc@11.2.0
Compilation: icc -O3 -xHost -qopenmp <<prog_name.c>>

C + MPI Program:

Setting up of environment:
spack load intel-oneapi-compilers gcc@11.2.0
Compilation: mpiicc -O3 -xHost <<prog_name.c>>

C + MKL Program:

Setting up of environment:
spack load intel-oneapi-compilers gcc@11.2.0
Compilation: icc -O3 -xHost -mkl <<prog_name.c>>

CUDA Program:

Setting up of environment:
spack load cuda@10.1 gcc@11.2.0
Example (1)
Compilation: nvcc -arch=sm_70<<prog_name.cu>>

Note: The optimization switch -arch=sm_70 is intended for Volta V100 GPUs and is valid for CUDA 9 and later. Similarly, older versions of CUDA have compatibility with lower versions of GCC only. Accordingly, appropriate modules of GCC must be loaded.
Example (2)
Compilation: nvcc -arch=sm_70 /home/apps/Docs/samples/mm_blas.cu -lcublas

OpenACC Program:

Setting up of environment:
spack load pgi@19.10 cuda@10.1
Compilation for GPU: pgcc -acc -fast -Minfo=all -ta=tesla:cc70,managed/home/apps/Docs/samples/laplace_acc.c

Compilation for CPU: pgcc -acc -fast -Minfo=all -ta=multicore-tp=skylake /home/apps/Docs/samples/laplace_acc.c