Compiler (C, C++, Fortran) Options to Use/Avoid
When Developing Code for Spirit
Recommendations in this document apply to the Fortran, C, and C++ compilers.
The following compiler options are recommended when porting to or developing code on Spirit:
|-g||Builds a symbol table that allows you to look at variables in your code while it is running.|
|-O2||Optimization level 2: Speeds up your code without rewriting your code too drastically.|
The following compiler options should be avoided when porting to or developing code on Spirit:
|-O0||Optimization level 0: Makes the code run too slowly.|
|-O3||Optimization level 3: This should only be used for software with well-defined algorithms.|
|-fast, -static||The "-fast" and "-static" options cannot be used when building MPI applications on SGI systems. That's because SGI does not provide static MPI libraries.|
All optimization levels above 0 rewrite your code, but O2 is pretty safe and doesn't force optimizations that are unwanted or not useful. For optimizations above 2, the compiler might rewrite something that is against its better judgment, with disastrous to catastrophic results.
Before you can optimize a program, you have to establish a baseline from which to work. Drawing an analogy, you don't want to try to make your code run before you know it can walk, but you don't want it to run too slowly either. O2 should provide a nice pace, and any code that requires O0 or O1 to run probably needs to be rewritten.
With regards to "-fast" and "-static", it is possible to link applications using a mix of static and dynamic libraries. However, we discourage static builds because it does not enable multiple processes to share library code pages.
MPT is the default MPI library on Spirit. It is usually necessary to unload the "mpt" module when using another vendor's MPI library.