Compiling Serial Programs
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
GNU Compilers
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:
For GCC, there is no straightforward equivalent to -xCORE-AVX512
, but the following options should be appropriate for Cascade Lake:
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
).