Skip to content

Commit 30c3837

Browse files
authored
Update sve2-match-search.md
1 parent 40298f4 commit 30c3837

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

content/learning-paths/servers-and-cloud-computing/sve2-match/sve2-match-search.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ int search_generic_u16(const uint16_t *hay, size_t n, const uint16_t *keys,
8989
return 0;
9090
}
9191
```
92+
The `search_generic_u8()` and `search_generic_u16()` functions both return 1 immediately when a match is found in the inner loop.
9293
9394
### 2. SVE2 MATCH Implementation
9495
@@ -137,11 +138,11 @@ int search_sve2_match_u16(const uint16_t *hay, size_t n, const uint16_t *keys,
137138
return 0;
138139
}
139140
```
140-
The SVE2 MATCH implementation provides an efficient vectorized search approach with these key technical aspects:
141+
The SVE MATCH implementation with the `search_sve2_match_u8()` and `search_sve2_match_u16()` functions provide an efficient vectorized search approach with these key technical aspects:
141142
- Uses SVE2's specialized MATCH instruction to compare multiple elements against multiple keys in parallel
142143
- Leverages hardware-specific vector length through svcntb() for scalability
143144
- Prepares a vector of search keys that's compared against blocks of data
144-
- Processes data in vector-sized chunks with early termination when matches are found
145+
- Processes data in vector-sized chunks with early termination when matches are found. Stops immediately when any element in the vector matches.
145146
- Falls back to scalar code for remainder elements
146147

147148
### 3. Optimized SVE2 MATCH Implementation
@@ -245,7 +246,7 @@ if (svptest_any(pg, match1) || svptest_any(pg, match2) ||
245246
}
246247
```
247248
The main highlights of this implementation are:
248-
- Processes 4 vectors per iteration instead of just one
249+
- Processes 4 vectors per iteration instead of just one and stops immediately when any match is found in any of the 4 vectors.
249250
- Uses prefetching (__builtin_prefetch) to reduce memory latency
250251
- Leverages the svmatch_u8/u16 instruction to efficiently compare each element against multiple keys in a single operation
251252
- Aligns memory to 64-byte boundaries for better memory access performance

0 commit comments

Comments
 (0)