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 multithreaded with OpenMP so it can use multiple cores on a single compute node.

NVIDIA Compilers
GNU Compilers
Performance Options

Additional compiler flags can be selected to optimize the performance of the code. For the NVIDIA compilers on Horizon, TACC recommends using the flag -fast, which creates a generally optimal set of flags during compilation. Additionally, it tells the compiler to optimize performance for the CPUs and GPUs that happen to be on the machine where the compiler is running. This approach is valid as long as the machine on which the code is compiled (e.g., a login node) has the same CPU as the target machine (e.g., a "Grace Blackwell" compute node). To make extra sure that your code is correctly optimized for Grace processors, you can add the flag -tp neoverse-v2; for GPU code, -gpu=cc100 could be added for Blackwell. For Vera, the appropriate flag is -mcpu=olympus. The full command lines for a CPU-only code therefore look like this:

With GCC, the -O3 flag tells the compiler to be aggressive in making code transformations for greater speed. However, by default, GCC compilers generate code that works on a wide range of processors of a given family. To produce code that is optimized for the CPUs on the specific machine where the compiler is running, the flag -march=native is also needed. The -march flag combines two flags: -mcpu, which ensures that the full instruction set for the selected CPU is available; and -mtune, which instructs the compiler to tune the code for that CPU during compilation. The more precise flag that pertains to NVIDIA Grace is -march=neoverse-v2, and for Vera it is -march=olympus Thus, with GCC, the command lines for a CPU-only code look like this:

As an alternative, you may use the environment variable $TACC_VEC_FLAGS to set the compiler flags appropriately for the compiler that you have selected through one of TACC's modules. To view the expanded set of options that $TACC_VEC_FLAGS brings in for the NVIDIA compiler, check the Building for Performance section of the Horizon User Guide.

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)