You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/servers-and-cloud-computing/sve2-match/sve2-match-search.md
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
# User change
3
-
title: "Compare Search Performance Using Scalar and SVE2 MATCH on Arm Servers"
3
+
title: "Compare search performance using scalar and SVE2 MATCH on Arm Servers"
4
4
5
5
weight: 2
6
6
@@ -10,30 +10,29 @@ layout: "learningpathall"
10
10
---
11
11
## Introduction
12
12
13
-
Searching for specific values in large arrays is a fundamental operation in many applications, from databases to text processing. The performance of these search operations can significantly affect overall application performance, especially when dealing with large datasets.
14
-
15
-
In this Learning Path, you will learn how to use the SVE2 MATCH instructions available on Arm Neoverse V2 based AWS Graviton4 processors to optimize search operations in byte and half word arrays. You will compare the performance of scalar and SVE2 MATCH implementations to demonstrate the significant performance benefits of using specialized vector instructions.
13
+
Searching large arrays for specific values is a core task in performance-sensitive applications—from filtering records in a database to detecting patterns in text or images. On Arm Neoverse-based servers, SVE2 MATCH instructions unlock massive performance gains by vectorizing these operations. In this Learning Path, you’ll implement and benchmark both scalar and vectorized versions of search functions to see just how much faster your workloads can run.
16
14
17
15
## What is SVE2 MATCH?
18
16
19
17
SVE2 (Scalable Vector Extension 2) is an extension to the Arm architecture that provides vector processing capabilities with a length-agnostic programming model. The MATCH instruction is a specialized SVE2 instruction that efficiently searches for elements in a vector that match any element in another vector.
20
18
21
19
## Set up your environment
22
20
23
-
To follow this learning path, you will need:
21
+
To work through these examples, you require:
24
22
25
-
1. An AWS Graviton4 instance running `Ubuntu 24.04`
26
-
2. GCC compiler with SVE support
23
+
* An AWS Graviton4 instance running `Ubuntu 24.04`
24
+
* GCC compiler with SVE support
27
25
28
26
Start by setting up your environment:
29
27
30
28
```bash
31
29
sudo apt-get update
32
30
sudo apt-get install -y build-essential gcc g++
33
31
```
34
-
An effective way to achieve optimal performance on Arm is not only through optimal flag usage, but also by using the most recent compiler version. This Learning path was tested with GCC 13 which is the default version on `Ubuntu 24.04` but you can run it with newer versions of GCC as well.
32
+
An effective way to achieve optimal performance on Arm is not only through optimal flag usage, but also by using the most recent compiler version. This Learning path was tested with GCC 13 which is the default version on `Ubuntu 24.04`, but you can run it with newer versions of GCC as well.
35
33
36
34
Create a directory for your implementations:
35
+
37
36
```bash
38
37
mkdir -p sve2_match_demo
39
38
cd sve2_match_demo
@@ -44,18 +43,18 @@ Your goal is to implement a function that searches for any occurrence of a set o
44
43
45
44
This type of search operation is common in many applications:
46
45
47
-
1.**Database Systems**: Checking if a value exists in a column
48
-
2.**Text Processing**: Finding specific characters in a text
49
-
3.**Network Packet Inspection**: Looking for specific byte patterns
50
-
4.**Image Processing**: Finding specific pixel values
46
+
***Database systems**: checking if a value exists in a column
47
+
***Text processing**: finding specific characters in a text
48
+
***Network packet inspection**: looking for specific byte patterns
49
+
***Image processing**: finding specific pixel values
51
50
52
51
## Implementing search algorithms
53
52
54
53
Let's implement three versions of our search function:
55
54
56
55
### 1. Generic scalar implementation
57
56
58
-
Create a generic implementation in C that checks each element individually against each key. Open a editor of your choice and copy the code shown into a file named `sve2_match_demo.c`:
57
+
Create a generic implementation in C that checks each element individually against each key. Open an editor of your choice and copy the code shown into a file named `sve2_match_demo.c`:
59
58
60
59
```c
61
60
#include<arm_sve.h>
@@ -145,7 +144,9 @@ The SVE MATCH implementation with the `search_sve2_match_u8()` and `search_sve2_
145
144
146
145
### 3. Optimized SVE2 MATCH implementation
147
146
148
-
In this next SVE2 implementation you will add loop unrolling and prefetching to further improve performance. Copy the code shown into the same source file:
147
+
In this next SVE2 implementation you will add loop unrolling and prefetching to further improve performance.
148
+
149
+
Copy the code shown into the same source file:
149
150
150
151
```c
151
152
intsearch_sve2_match_u8_unrolled(const uint8_t *hay, size_t n, const uint8_t *keys,
@@ -522,8 +523,8 @@ This pattern makes SVE2 MATCH particularly well-suited for applications where ma
522
523
523
524
The unrolled implementation consistently outperforms the basic SVE2 MATCH implementation:
524
525
525
-
1.**Low Hit Rates**: Up to 30% additional speedup
526
-
2.**Higher Hit Rates**: 5-20% additional speedup
526
+
***Low Hit Rates**: Up to 30% additional speedup
527
+
***Higher Hit Rates**: 5-20% additional speedup
527
528
528
529
This demonstrates the value of combining algorithmic optimizations (loop unrolling, prefetching) with hardware-specific instructions for maximum performance.
0 commit comments