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
+13-16Lines changed: 13 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 performance of different Search implementations"
3
+
title: "Compare Search Performance Using Scalar and SVE2 MATCH on Arm Servers"
4
4
5
5
weight: 2
6
6
@@ -10,39 +10,37 @@ 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 impact overall application performance, especially when dealing with large datasets.
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
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.
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.
16
16
17
17
## What is SVE2 MATCH?
18
18
19
19
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
20
21
-
## Set Up Your Environment
21
+
## Set up your environment
22
22
23
23
To follow this learning path, you will need:
24
24
25
-
1. An AWS Graviton4 instance running `Ubuntu 24.04`.
25
+
1. An AWS Graviton4 instance running `Ubuntu 24.04`
26
26
2. GCC compiler with SVE support
27
27
28
-
Let's start by setting up our environment:
28
+
Start by setting up your environment:
29
29
30
30
```bash
31
31
sudo apt-get update
32
32
sudo apt-get install -y build-essential gcc g++
33
33
```
34
-
An effective way to achieve optimal performance on Arm is not only through optimal flag usage, but also by using the most
35
-
recent compiler version. This Learning path was tested with GCC 13 which is the default version on `Ubuntu 24.04` but you
36
-
can run it with newer versions of GCC as well.
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.
37
35
38
-
Create a directory for our implementations:
36
+
Create a directory for your implementations:
39
37
```bash
40
38
mkdir -p sve2_match_demo
41
39
cd sve2_match_demo
42
40
```
43
41
## Understanding the Problem
44
42
45
-
Our goal is to implement a function that searches for any occurrence of a set of keys in an array. The function should return true if any element in the array matches any of the keys, and false otherwise.
43
+
Your goal is to implement a function that searches for any occurrence of a set of keys in an array. The function should return true if any element in the array matches any of the keys, and false otherwise.
46
44
47
45
This type of search operation is common in many applications:
48
46
@@ -51,13 +49,13 @@ This type of search operation is common in many applications:
51
49
3.**Network Packet Inspection**: Looking for specific byte patterns
52
50
4.**Image Processing**: Finding specific pixel values
53
51
54
-
## Implementing Search Algorithms
52
+
## Implementing search algorithms
55
53
56
54
Let's implement three versions of our search function:
57
55
58
-
### 1. Generic Scalar Implementation
56
+
### 1. Generic scalar implementation
59
57
60
-
Create a generic implementation in C, checking 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`:
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`:
- Processes 4 vectors per iteration instead of just one and stops immediately when any match is found in any of the 4 vectors.
247
+
- Processes four vectors per iteration instead of just one and stops immediately when any match is found in any of the four vectors.
250
248
- Uses prefetching (__builtin_prefetch) to reduce memory latency
251
249
- Leverages the svmatch_u8/u16 instruction to efficiently compare each element against multiple keys in a single operation
252
250
- Aligns memory to 64-byte boundaries for better memory access performance
@@ -565,4 +563,3 @@ For image processing, MATCH can accelerate:
565
563
566
564
The SVE2 MATCH instruction provides a powerful way to accelerate search operations in byte and half word arrays. By implementing these optimizations on Graviton4 instances, you can achieve significant performance improvements for your applications.
0 commit comments