After reading the basic instructions on compiling code, check here for more tips on compiling. This page is under construction.
A Universal Binary, or Fat Binary, is a binary that will have different runtime instructions based on the architecture of the node it is run on. The instructions below for creating universal binaries are currently tested for serial code only. The GNU compiler does not have the option of creating a universal binary. To optimize for different architectures with GNU, create multiple executables.
By default, the PGI compiler will perform optimizations based on the node it was compiled on. If a PGI program is compiled on a login node it may not run on an older node, resulting in an error of illegal instruction. This will both limit the number of nodes the executable may run on and also create executables that may not be optimized for the newest existing nodes.
Creating a universal binary with PGI is not possible using the current PGI default module load commands. To set the PGI environment for compiling a universal binary, set the PATH and LD_LIBRARY_PATH manually, and use the -tp flag. For example, when compiling the source code universe.F90 to create an executable universe.exe that will both run on and be optimized for all types of Hazel architecture, do the following:
export PATH = /usr/local/pgi/linux86-64-nollvm/19.4/bin:$PATH export LD_LIBRARY_PATH = /usr/local/pgi/linux86-64-nollvm/19.4/bin:$LD_LIBRARY_PATH pgf90 -o universe.exe -tp=nehalem,sandybridge,haswell,skylake universe.F90
The latest version of the PGI compiler must be used in order to target the latest architecture.
By default, the Intel compiler will not perform optimizations based on architecture. To do architecture dependent optimizations, a user must specify the architecture or compile directly on the target architecture and use -xhost. Running an executable compiled for targeted architecture or with -xhost will result in errors of illegal instruction when running on incompatible nodes.
As an example on how to create a universal binary with Intel, when compiling the source code universe.F90 to create an executable universe.exe that will both run on and be optimized for all types of Hazel architecture, do the following:
module load PrgEnv-intel/2019.4.243 ifort -o universe.exe -diag-enable=all -qopt-report -xSSE3 -axSSE4.2,AVX,CORE-AVX-I,CORE-AVX2,CORE-AVX512 universe.F90
The above command will also generate a report that details the optimizations made for the different architectures. Intel may not show an error at compile time if the architecture flags are invalid or misspelled. Instead, it may silently skip the invalid options.
The latest version of the Intel compiler must be used in order to target the latest architecture.