Learn about optimization techniques using the g++ compiler
Introduction
Compiler basics
Set up Your Environment
Find specific Neoverse features
Try an example application
Next Steps
Learn about optimization techniques using the g++ compiler
Who is this for?
This Learning Path is for beginner C++ developers who are looking to optimize applications on Arm-based cloud instances using compiler flags.
What will you learn?
Upon completion of this Learning Path, you will be able to:
- Compile a C++ program for a specific Arm target.
- Use compiler flags to manage optimizations.
Prerequisites
Before starting, you will need the following:
- Basic understanding of C++
- Basic understanding of compilers
- Access to a Neoverse-based system running Ubuntu 24.04 LTS, such as an AWS Graviton-based instance or an Arm AGI CPU platform
Summary
This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
You’ll compile and tune a C++ application with
g++ on an Arm Neoverse-based Linux system. You’ll inspect the CPU with lscpu, choose between -march for portability and -mcpu for processor-specific tuning, and consider size-sensitive container builds. You’ll build and run the example, then learn to make flag choices based on portability, binary size, and performance.Frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Run
lscpu | grep -i model and look for a Model name line such as Neoverse-*. If lscpu omits the model name, use the tip in the step to read the CPU part number.Use
-march= with a value that matches the lowest Arm architecture across your target systems for portability. Use -mcpu= to tune for a specific processor when you plan to run only on that CPU.No. Any Neoverse-based system running Ubuntu 24.04 LTS works, including the examples mentioned. The workflow assumes an Arm-native environment on such a system.
Optimize for size as outlined in the example step. Choose compiler options that reduce binary size and accept the trade-offs they introduce.
The program should compile and run on the Arm instance. A portable build using
-march is intended to run on other Arm servers that meet that baseline, while a CPU-tuned build targets the specified processor.