Code Optimization

In general C and Fortran compilers have 4 levels of optimization. Level 0 is no optimization, level 1 is safe optimizations, level 2 is mostly safe optimizations and level 3 is all optimizations possible. It is always a good idea to verify your code after optimizing it to see if the results are still the same or close enough to what you expect. You may find that your code works fine up to second level optimization but breaks when you try level 3.

There are also advanced instruction sets which are chipset dependent. On Odyssey 2 we have a heterogenous environment running many different versions of Intel and AMD processors. Thus it is important that if you want to do chipset dependent optimization you pick the level of optimization correct for the processor you are using. For instance the Abu Dhabi processors on the main Odyssey 2 queues can accept AVX2 and FMA4 instruction sets. So if your compiler can optimize for those and your code can leverage those it is a good idea to build with them.

Some compilers also come with auto-optimization for chipsets. This option detects that processor being run on and does the optimization for you. In this case you want to be sure you are compiling on the same hardware that you run on. On Odyssey 2 the login nodes are Intel based while the general queue is AMD. Thus if you use the automatic optimization for chipset you will want to compile in an interactive job on the queue you are interested in using.

For more information on how optimization works and what optimizations are available please see the man pages or documentation of the compilers you are using. Typically each optimization level is listed in the compiler as well as what it does and how safe it is. It is best to always be aware of what optimizations are being applied as they can impact the performance of your code and the results of your program.

CC BY-NC 4.0 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. Permissions beyond the scope of this license may be available at Attribution.