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
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ Create a directory for your implementations:
38
38
mkdir -p sve2_match_demo
39
39
cd sve2_match_demo
40
40
```
41
-
## Understanding the Problem
41
+
## Understanding the problem
42
42
43
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.
44
44
@@ -89,7 +89,7 @@ int search_generic_u16(const uint16_t *hay, size_t n, const uint16_t *keys,
89
89
```
90
90
The `search_generic_u8()` and `search_generic_u16()` functions both return 1 immediately when a match is found in the inner loop.
91
91
92
-
### 2. SVE2 MATCH Implementation
92
+
### 2. SVE2 MATCH implementation
93
93
94
94
Now create an implementation that uses SVE2 MATCH instructions to process multiple elements in parallel. Copy the code shown into the same file:
95
95
@@ -143,7 +143,7 @@ The SVE MATCH implementation with the `search_sve2_match_u8()` and `search_sve2_
143
143
- Processes data in vector-sized chunks with early termination when matches are found. Stops immediately when any element in the vector matches.
144
144
- Falls back to scalar code for remainder elements
145
145
146
-
### 3. Optimized SVE2 MATCH Implementation
146
+
### 3. Optimized SVE2 MATCH implementation
147
147
148
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:
149
149
@@ -249,9 +249,9 @@ The main highlights of this implementation are:
249
249
- Leverages the svmatch_u8/u16 instruction to efficiently compare each element against multiple keys in a single operation
250
250
- Aligns memory to 64-byte boundaries for better memory access performance
251
251
252
-
## Benchmarking Framework
252
+
## Benchmarking framework
253
253
254
-
To compare the performance of the three implementations, you will use a benchmarking framework that measures the execution time of each implementation. You will also add helper functions for membership testing that are needed to setup the test data with controlled hit rates:
254
+
To compare the performance of the three implementations, use a benchmarking framework that measures the execution time of each implementation. You will also add helper functions for membership testing that are needed to setup the test data with controlled hit rates:
255
255
256
256
```c
257
257
// Timing function
@@ -423,7 +423,7 @@ You can now compile the different search implementations:
Now run the benchmark on a dataset of 65,536 elements (2^16) with a 0.001% hit rate:
426
+
Run the benchmark on a dataset of 65,536 elements (2^16) with a 0.001% hit rate:
427
427
428
428
```bash
429
429
./sve2_match_demo $((1<<16)) 3 0.00001
@@ -455,7 +455,7 @@ You can experiment with different haystack lengths, iterations and hit probabili
455
455
```
456
456
## Performance Results
457
457
458
-
When running on a Graviton4 instance with Ubuntu 24.04 and a dataset of 65,536 elements (2^16), you will observe the following results for different hit probabilities:
458
+
When running on a Graviton4 instance with Ubuntu 24.04 and a dataset of 65,536 elements (2^16), you will see different hit probabilities, as shown in the following results:
459
459
460
460
### Latency (ns per iteration) for Different Hit Rates (8-bit)
0 commit comments