To optimize your application:
Start by compiling your application with the
-O3compiler options. Consider using the
-Ofastoption. For C code, try compiling your application with the
-fsimdmathoption provides a vectorised implementation of common libm calls.
For Fortran source, vector implementations are used, when possible, by default, but can be disabled using the
-Ofastoption enables all the optimizations from
-O3, but also performs other aggressive optimizations that might violate strict compliance with language standards.
If your Fortran application runs into issues with
-Ofast, to force automatic arrays on the heap, try
-Ofastis not acceptable and produces the wrong results because of the reordering of math operations, use
-ffp-contract=fastdoes not produce the correct results, then use
Use the optimized Arm Performance Libraries with the
Arm Performance Libraries provide optimized standard core math libraries for high-performance computing applications on Arm processors:
- BLAS - Basic Linear Algebra Subprograms (including XBLAS, the
extended precision BLAS).
LAPACK - a comprehensive package of higher level linear algebra routines.
FFT - a set of Fast Fourier Transform routines for real and complex data. Arm Performance Libraries support FFTWs Basic, Advanced, Guru, and MPI interfaces.
The compiler option
-armplmakes these libraries significantly easier to use with a simple interface to select thread-parallelism and architectural tuning. Arm Performance Libraries also provides improved Fortran math intrinsics with auto-vectorization.
-mcpuoptions enable the compiler to find appropriate Arm Performance Libraries header files (during compilation) and libraries (during linking). Both options are required for the best results.
If your build process compiles and links as two separate steps, please ensure you add the same
-mcpuoptions to both. For more information about using the
-armploption, see Getting Started with Arm Performance Libraries on the Arm Developer website.
For GCC, you will need to load the correct environment module for the system and explicitly link to your chosen flavor (lp64/ilp64, mp) with full library path.
For more information, refer to the Arm Performance Libraries Developer web page.
Get help with optimization
In armflang, optimization remarks are enabled by passing
-Rpass command line options. Optimization remarks are a feature of LLVM compilers that provides information about the choices made by the compiler about inlining, vectorization, and more.
Optimization remarks are enabled by passing one or more of the following
-Rpass flags at the command line:
To request information about what Arm Compiler has optimized.
To request information about what Arm Compiler has analyzed.
To request information about what Arm Compiler failed to optimize.
In each case,
<regexp> is used to select the type of remarks to provide. For example, loop-vectorize for information on vectorization, and inline for information on in-lining.
Rpass accepts regular expressions, so (loop-vectorize|inline) can be used to capture any remark on vectorization or in-lining.
Optimization remarks are piped to
stdout at compile time. For more information, see Using Optimization Remarks with Arm Fortran Compiler or Using Optimization Remarks with Arm C/C++ Compiler.
Optimization remarks requires that an appropriate debug flag is set, such as
Use the Arm Compiler directives.
Arm Fortran Compiler supports general-purpose and OpenMP-specific directives:
!DIR$ IVDEP- A generic directive to force the compiler to ignore any potential memory dependencies of iterative loops and vectorize the loop.
!$OMP SIMD- An OpenMP directive to indicate a loop can be transformed into a SIMD loop.
!DIR$ VECTOR ALWAYS- Forces the compiler to vectorize a loop irrespective of any potential performance implications.
The loop must be vectorizable.
!DIR$ NO VECTOR- Disables vectorization of a loop.
!DIR$ UNROLL- Instructs the compiler to unroll the loop it precedes.
!DIR$ NOUNROLL- Instructs the compiler not to unroll the loop it precedes.
For more information, see the directives section of the Arm Fortran Compiler reference guide.
Optimize by iteration. Use Arm Forge Professional to iteratively debug and profile your ported application.
Arm Forge is composed of the Arm DDT debugger and the Arm MAP profiler:
Use Arm DDT to debug your code to ensure application correctness. It can be used both in an interactive and non-interactive debugging mode, and optionally, integrated into your CI workflows.
Use Arm MAP to profile your code to measure your application performance. MAP collects a broad set of performance metrics, time classification metrics, specific metrics (for example MPI call and message rates, I/O data rates, energy data), and instruction information (hardware counters), to ensure a comprehensive understanding of the performance of your code. MAP also supports custom metrics so you can develope your own set of metrics of interest.
Use the Arm Forge tools and follow an iterative identification and resolving cycle to optimize application performance:
The 50x, 10x, 5x, and 2x numbers in the figure below are potential slow down factors that Arm has observed in real-world applications (when that aspect of performance is done incorrectly).
For more information, see the Arm Forge User Guide.