Skip to content

Commit a1293d3

Browse files
Merge pull request #3090 from madeline-underwood/vectorfri
Vectorfri
2 parents e622bd4 + 8610bc1 commit a1293d3

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

content/learning-paths/cross-platform/vectorization-friendly-data-layout/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Optimize SIMD code with vectorization-friendly data layout
33

44
minutes_to_complete: 45
55

6+
description: Learn how to optimize SIMD performance on Arm by restructuring data layouts from Array-of-Structures to Structure-of-Arrays, with practical examples using Neon and SVE intrinsics.
7+
68
who_is_this_for: This is an advanced topic for C/C++ developers who are interested in improving the performance of SIMD code.
79

810
learning_objectives:

content/learning-paths/cross-platform/vectorization-friendly-data-layout/data-layout-basics-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Before trying any optimization, it's important to understand the way the data is
1010

1111
In order to improve the data layout and help the compiler, you need to go back and look at the `object` struct in more detail. The memory layout of `object` is the following:
1212

13-
![Memory layout #center](memory-layout1.svg "Figure 1. struct object memory layout with vec3")
13+
![Diagram showing the memory layout of the object struct using vec3 fields, illustrating the 12-byte alignment issue that prevents efficient SIMD operations#center](memory-layout1.svg "Figure 1. struct object memory layout with vec3")
1414

1515
As the `vec3` types are triplets, their alignment `is 3 x 4 bytes = 12 bytes`. This makes usage of SIMD instructions difficult as they usually operate on data multiples of 16 bytes. Alignment to 16 bytes is also important. You can usually solve this by adding extra bytes in such structures as padding. This results in wasted bytes, but sometimes these can be used for extra information. Even if the extra bytes cannot be used, the performance benefit outweighs the loss in memory.
1616

@@ -72,7 +72,7 @@ void simulate_objects(object_t *objects, float duration, float step) {
7272

7373
The memory layout now looks like this:
7474

75-
![Memory layout #center](memory-layout2.svg "Figure 2. struct object memory layout with vec4")
75+
![Diagram showing the improved memory layout of the object struct using vec4 fields with padding, achieving 16-byte alignment for optimal SIMD performance#center](memory-layout2.svg "Figure 2. struct object memory layout with vec4")
7676

7777
After making the changes, compile the code again:
7878

0 commit comments

Comments
 (0)