Here are some simple examples to show how to use the available compilers to build an executable from source code. These examples apply either to a serial code, or to a code that is OpenMP with multithreaded so it can use multiple cores on a single compute node.

Intel Compilers
$ icc mycode.c                     # C source file; executable a.out
$ icc mycode.c          -o myexe   # C source file; executable myexe
$ icpc mycode.cpp       -o myexe   # C++ source file
$ ifort mycode.f90      -o myexe   # Fortran 90 source file
$ icc -qopenmp mycode.c -o myexe   # OpenMP 
GNU Compilers
$ gcc mycode.c                     # C source file; executable a.out
$ gcc mycode.c          -o myexe   # C source file; executable myexe
$ g++ mycode.cpp        -o myexe   # C++ source file
$ gfortran mycode.f90   -o myexe   # Fortran90 source file
$ gcc -fopenmp mycode.c -o myexe   # OpenMP; GNU flag is different than Intel
Performance Options

Additional compiler flags can be selected to optimize the performance of the code. For Intel, the most important flags are -xCORE-AVX512, which tells the compiler to use the AVX-512 instruction set appropriate for Cascade Lake processors, and -O3, which says to be aggressive in making code transformations for greater speed. The full command lines look like this:

$ icc   -xCORE-AVX512 -O3 mycode.c   -o myexe  # will run only on CLX/SKX
$ ifort -xCORE-AVX512 -O3 mycode.f90 -o myexe  # will run only on CLX/SKX

For GCC, there is no straightforward equivalent to -xCORE-AVX512, but the following options should be appropriate for Cascade Lake:

$ gcc      -march=cascadelake -O3 mycode.c   -o myexe  # will run only on CLX
$ gfortran -march=cascadelake -O3 mycode.f90 -o myexe  # will run only on CLX

The same goal can be accomplished indirectly by telling the compiler to optimize performance for the processor that happens to be on the machine where the compiler is running (e.g., a login node). This approach is valid as long as the target machine (e.g., a compute node) has the same type of processor. The flag that does this optimization is -xHost for Intel and -march=native for GCC.

One option not to use with Intel is -static, as shared (non-static) libraries are strongly preferred when running multiple identical tasks on the same node. This flag is included in Intel's catch-all option -fast, so that flag should not be used either. However, some of the other constituent suboptions of -fast may be useful (-ipo -O3 -no-prec-div -fp-model fast=2 -xHost).

 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement