Loading GCC

  • modulegcc-stack โ€” GCC 13.2 + MVAPICH 2.3.7 (recommended)
  • modulegcc/13.2.0 ยท mvapich2/gcc13.2/2.3.7
  • modulegcc/12.1.0 ยท mvapich2/gcc12.1/2.3.7 (alternative)
Tip: load modules inside your SLURM job script, not just on the login node, so compute nodes see the same environment. Verify with which after loading.

Commands

  • gccC compiler
  • g++C++ compiler
  • gfortranFortran compiler
  • mpicc / mpicxx / mpif90MVAPICH MPI wrappers

Example usage

Load the recommended GCC stack

module load gcc-stack

Compile with GCC compilers

gcc myprogram.c -o myprogram
g++ myprogram.cpp -o myprogram
gfortran myprogram.f90 -o myprogram

Compile MPI programs with wrapper scripts

mpicc mpi_program.c -o mpi_program
mpicxx mpi_program.cpp -o mpi_program
mpif90 mpi_program.f90 -o mpi_program

Optimization examples

gcc -O3 myprogram.c -o myprogram
gcc -Ofast myprogram.c -o myprogram
gcc -march=native myprogram.c -o myprogram
gcc -O3 -ftree-vectorize -fopt-info-vec myprogram.c -o myprogram
gcc -O3 -fprofile-generate myprogram.c -o myprogram
./myprogram
gcc -O3 -fprofile-use myprogram.c -o myprogram

SLURM script example (GCC + MVAPICH)

#!/bin/bash
#SBATCH --job-name=gcc_test
#SBATCH --output=gcc_test.out
#SBATCH -p short-40core
#SBATCH --ntasks=40
#SBATCH --time=01:00:00 # Load necessary modules module load gcc-stack # Compile and run your code mpicc -O3 mpi_example.c -o mpi_example
mpirun -np $SLURM_NTASKS ./mpi_example

Availability

GCC is available on: SeaWulf, NVwulf, ClinWulf.