Vectorizing with Compilers
Steve Lantz
Cornell Center for Advanced Computing
Revisions: 9/2022, 5/2021, 1/2021, 5/2018, 6/2017, 10/2013 (original)
Acknowledgments: Contributions from Aaron Birkland and the Texas Advanced Computing Center
As has been mentioned earlier in this Cornell Virtual Workshop roadmap, most compilers are capable of vectorizing code automatically. This topic tells how to instruct the compiler to perform automatic vectorization, as well as how to analyze the compiler's output to identify the areas of code that it was unable to vectorize. Furthermore, compilers typically allow developers to provide hints (or really, guarantees) and certain tuning parameters that can help it determine whether a section of code is vectorizable; therefore, this topic also discusses how to implement some of the hints that compilers recognize during the vectorization process.
Objectives
After you complete this topic, you should be able to:
- Explain why compiler options pertaining to optimization and architecture are important for vector performance
- Define the term "fat binary"
- Describe how to produce an optimization report and how it is used to improve the vectorization of a code
- Explain why a compiler needs to be conservative when vectorizing loops
Prerequisites
- Knowledge of C and/or Fortran, as well as a basic knowledge of what assembly language is
- Familiarity with batch job submission on large compute clusters