Who is this for?

This is an introductory topic for Arm developers who want to learn about memory latency and cache usage in application programming.

What will you learn?

Upon completion of this Learning Path, you will be able to:

  • Explain the importance of memory latency and how to reduce its impact
  • Identify how cache alignment impacts performance
  • Use cache prefetching to improve performance

Prerequisites

Before starting, you will need the following:

  • An Arm computer running Linux with recent versions of Clang or GCC installed.

Summary

AI-assisted

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.

Close
?
You’ll explore memory latency with a small C workload on Arm Linux. First, you’ll modify the application in stages: add an allocator for locality, adjust structure layout and cache alignment, and add prefetching to bring data closer to the CPU. Then, you’ll build and run each version. You’ll compare relative runtime trends, choose an effective alignment, and tune the prefetch distance to overlap memory access with computation.

Frequently asked questions

AI-assisted

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.

Close
?
What should I check if my results differ from the sample output?
Differences are expected because processor and system details vary. Confirm that you built and ran the intended source file for each version, then compare relative changes rather than exact numbers.
How do I confirm the allocator changes in `memory-latency2.c` are being used?
Verify that the new allocator code is present and that you build memory-latency2.c. Run the program and confirm that it completes without the allocator error message from the source.
Which alignment or structure layout should I use for the node type?
Apply the changes shown in the steps, then test the provided alternatives and compare runtime behavior. Keep the version that performs better on your Arm system.
How far ahead should I prefetch in the loop?
Prefetch a few iterations ahead. Prefetching only the next iteration is often insufficient with typical RAM latency of about 100 ns. Adjust the distance empirically and keep the setting that improves runtime trends.
How do I know if cache alignment or prefetching helped?
Build each variant, run it under the same conditions, and compare runtimes or other observable behavior. A consistent improvement across multiple runs indicates that the change benefits your system.
Next