https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/optimizing-your-programs-for-arm-platforms Arm Community Arm Community * Site * Search [ ] * User * Site * Search * User * Groups + Education Hub + Open Source Software and Platforms + Research Collaboration and Enablement * Forums + AI and ML forum + Architectures and Processors forum + Arm Development Platforms forum + Arm Development Studio forum + Arm Virtual Hardware forum + Automotive forum + Compilers and Libraries forum + Graphics, Gaming, and VR forum + High Performance Computing (HPC) forum + Infrastructure Solutions forum + Internet of Things (IoT) forum + Keil forum + Morello forum + Operating Systems forum + SoC Design and Simulation forum + SystemReady Forum * Blogs + AI and ML blog + Announcements + Architectures and Processors blog + Automotive blog + Graphics, Gaming, and VR blog + High Performance Computing (HPC) blog + Infrastructure Solutions blog + Internet of Things (IoT) blog + Operating Systems blog + SoC Design and Simulation blog + Tools, Software and IDEs blog * Support + Arm Support Services + Documentation + Downloads + Training + Arm Approved program + Arm Design Reviews * Community Help * More * Cancel Arm Community blogs Arm Community blogs Architectures and Processors blog Optimizing your programs for Arm platforms * Blogs * Mentions * Sub-Groups * Tags * Jump... * Cancel More blogs in Arm Community blogs * AI and ML blog * Announcements * Architectures and Processors blog * Automotive blog * Embedded blog * Graphics, Gaming, and VR blog * High Performance Computing (HPC) blog * Infrastructure Solutions blog * Internet of Things (IoT) blog * Operating Systems blog * SoC Design and Simulation blog * Tools, Software and IDEs blog Tell us what you think Tags * Android * performance * Learn the Architecture * Compilers Actions * RSS * More * Cancel Related blog posts Related forum threads Optimizing your programs for Arm platforms [8468] Tamar Christina Tamar Christina April 24, 2024 3 minute read time. Today's compilers are quite good at producing highly optimized code on their own. However, there are several cases where you as the programmer can help compilers generate better code. This blog post covers techniques and tips that are useful to create better performing programs whether you are creating Android, Desktop or Server applications. Memory aliasing and the 'restrict' keyword Whenever a compiler auto-vectorizes code, it needs to first be sure that this is safe to do. One of the performed safety checks is for pointer aliasing. This check is used to see if the pointers the compiler is reading and writing can be pointing to the same data. When the compiler cannot determine this statically, it has to insert a runtime check. These checks can slow your program down significantly or, even worse, fail to vectorize entirely if it can not insert the runtime checks. However, there is a way for you as the programmer to tell the compiler to go ahead and assume the pointers do not alias. Read the following Learning Path in the URL that explains the importance of using the 'restrict' keyword in C correctly. Learn about the restrict keyword Memory latency Loading and storing data to memory is an activity that takes time for the CPU to complete. How much time depends on several factors, but there are various things that you as the programmer can do to improve this access time. Often compilers cannot do these for you and so knowing these techniques can give your program the edge it needs. Read the Memory Latency Learning Path in the following URL to gain a better understanding of caches, prefetching and data alignment on Arm platforms. Learn about memory latency Leveraging integer vs floating point Performing operations using integer arithmetic instead of floating-point arithmetic can often result in significantly faster programs, as CPUs tend to have more bandwidth to perform integer arithmetic. However, there are cases where, due to the semantics of the programming language, you inadvertently end up with floating point operations. One common pitfall is implicit conversions to floating-point. Read the Speed benefit of integer vs float Learning Path in the following URL to find out how to avoid these pitfalls and leverage the power of integer performance for faster programs. Learn about integer vs floating point performance Leveraging auto-vectorization in compilers Modern compilers are often referred to as optimizing compilers, because they perform various optimizations and transformations on your input program to get better performance. One such optimization is the transformation of your program from scalar to vector. The act of vectorization refers to transforming your program from handling one value at a time into one that can handle multiple values at a time in each operation. While compilers are very good at this and constantly improving, there are still various ways you can structure the flow of your program to make it easier for the compiler to perform auto-vectorization and leverage the power of Advanced SIMD and SVE instructions. Intrigued? Read more in the following URL: Learn how to leverage auto-vectorization Modifying loop layout to be auto-vectorization friendly Of equal importance when writing auto-vectorization friendly programs is the data layout. When the compiler is transforming loops during auto-vectorization It makes a significant difference whether it can be load data sequentially, or whether it needs to skip some elements, for instance loading every other element. Even accesses like reading a field of a struct inside an array, such as data[i].x, can result in strided accesses. An efficient data layout can be the difference between a slow and very fast program. This is one area where the compiler often does not have enough context to be able to help and where it is important for the programmer to understand how they can help the compiler. Interested in taking your program's performance to the next level? Read more in the link below. Learn about data layout Summary The Arm architecture has plenty of great features that when used properly can significantly improve your program's performance. It is easy to take advantage of them if you keep the tips and background knowledge in mind. Be sure to read the other Learning Paths here: https://learn.arm.com for other helpful and informative tips on how to best leverage all that the Arm platform provides. Read more Arm Learning Paths Anonymous * [ ] [ ] Architectures and Processors blog * [ARM1185_5F] MPAM-Style cache partitioning with ATP-Engine and gem5 Hristo Belchev Hristo Belchev Upstream gem5 and ATP-Engine MPAM-style cache partitioning are discussed, with experiments for the feature being proposed and analyzed. + April 24, 2024 * [8468] Optimizing your programs for Arm platforms Tamar Christina Tamar Christina This blog covers techniques and tips that are useful to create better performing programs through compilers whether you are creating Android, Desktop or Server applications. + April 24, 2024 * [ARM1783_5F] Deep dive into the PMU value of L2D_CACHE_WR on the Neoverse N2 server Ker Liu Ker Liu In-depth analysis of what the PMU of L2D_CACHE_WR counts on the Neoverse N2 server. + April 15, 2024