Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vectorize std::search of 1 and 2 bytes elements with pcmpestri #4745

Merged
merged 49 commits into from
Sep 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
73c96da
vectorize search
AlexGuteniev May 5, 2024
0c17a53
very tail fix
AlexGuteniev May 5, 2024
11c05ee
I 🧡 ADL
AlexGuteniev May 5, 2024
d4fcc96
unify ipsum
AlexGuteniev May 5, 2024
da5cf2e
-newline
AlexGuteniev May 5, 2024
da157b1
`strstr` for competition
AlexGuteniev May 5, 2024
772c513
missing progress
AlexGuteniev May 5, 2024
2c6c329
coverage
AlexGuteniev May 5, 2024
81a6000
these tests are too long
AlexGuteniev May 5, 2024
0b59b2e
missing include
AlexGuteniev May 5, 2024
f2806c5
default_searcher
AlexGuteniev May 5, 2024
15e54a9
ADL again
AlexGuteniev May 5, 2024
26646fe
avoid `memcmp` in fallback
AlexGuteniev May 5, 2024
0c473a4
partial review comment
AlexGuteniev Jun 7, 2024
3452fcc
Merge branch 'main' into search
StephanTLavavej Jun 10, 2024
629afd4
Internal static assert `sizeof(_Ty1) == sizeof(_Ty2)`.
StephanTLavavej Jun 10, 2024
a24e6eb
Use `+=` and `+` instead of `_RANGES next`.
StephanTLavavej Jun 10, 2024
9d07a40
Style: Return `_Ptr_res1` instead of `_Ptr_last1` when they're equal.
StephanTLavavej Jun 10, 2024
d57f9b6
Style: In `<algorithm>` and `<functional>`, `_Ptr_last1` doesn't need…
StephanTLavavej Jun 10, 2024
e51b98d
Restore top-level constness for `_UFirst2`.
StephanTLavavej Jun 10, 2024
d4462a5
Benchmark classic search().
StephanTLavavej Jun 10, 2024
95ba820
Simplify `last_known_good_search()`.
StephanTLavavej Jun 10, 2024
72a0d29
Revert vectorized implementation.
StephanTLavavej Jun 10, 2024
38b32d6
Drop `memcmp` paths from `_Equal_rev_pred_unchecked` and `_Equal_rev_…
StephanTLavavej Jun 10, 2024
1e16233
Merge remote-tracking branch 'upstream/main' into search
AlexGuteniev Jun 20, 2024
f269d6c
Revert "Revert vectorized implementation."
AlexGuteniev Jun 20, 2024
dc7eb5b
drop 4 and 8 bytes search optimization for now
AlexGuteniev Jun 24, 2024
0926486
SSE4.2 madness
AlexGuteniev Jun 24, 2024
ba63dbb
better approach
AlexGuteniev Jun 25, 2024
c293748
elegant tail
AlexGuteniev Jun 25, 2024
004d431
big needle benchmark
AlexGuteniev Jun 28, 2024
709ed47
large needle optimization
AlexGuteniev Jun 28, 2024
1c66f01
prevent found data withing overflown part
AlexGuteniev Jun 29, 2024
43e0eec
proper tail length
AlexGuteniev Jun 29, 2024
1420757
better match coverage
AlexGuteniev Jun 29, 2024
fa9d52f
bring back optimization
AlexGuteniev Jun 29, 2024
dfd69e8
i consistent
AlexGuteniev Jun 29, 2024
93cdcf0
Merge branch 'main' into search
StephanTLavavej Sep 4, 2024
96a4d58
Avoid truncation warnings in `_First1 + _Count2`.
StephanTLavavej Sep 5, 2024
2a239a7
Style and comment nitpicks.
StephanTLavavej Sep 5, 2024
3bc1d56
Benchmark: Use a constexpr array of string_view.
StephanTLavavej Sep 5, 2024
c1aaba7
Add const.
StephanTLavavej Sep 5, 2024
6276567
Don't help the compiler - let it deduce `_Ty`.
StephanTLavavej Sep 5, 2024
05e435d
Drop inconsistent `_CSTD`.
StephanTLavavej Sep 5, 2024
e7ec67a
input_needle is guaranteed non-empty here.
StephanTLavavej Sep 5, 2024
9d11dcc
Avoid permanently modifying the haystack.
StephanTLavavej Sep 5, 2024
abae4ed
Bugfix: Use an unaligned load from `_First2`.
StephanTLavavej Sep 5, 2024
e96407b
`_Count2` is more natural than `_Last2`
AlexGuteniev Sep 7, 2024
e0c843d
-hiding
AlexGuteniev Sep 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Benchmark: Use a constexpr array of string_view.
StephanTLavavej committed Sep 5, 2024
commit 3bc1d5689fb0a46ba2248b6dbc4f04c0f07a6468
9 changes: 6 additions & 3 deletions benchmarks/src/search.cpp
Original file line number Diff line number Diff line change
@@ -2,12 +2,15 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <algorithm>
#include <array>
#include <benchmark/benchmark.h>
#include <cstdint>
#include <cstring>
#include <functional>
#include <string>
#include <string_view>
#include <vector>
using namespace std::string_view_literals;

const char src_haystack[] =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mollis imperdiet massa, at dapibus elit interdum "
@@ -40,9 +43,9 @@ const char src_haystack[] =
"euismod eros, ut posuere ligula ullamcorper id. Nullam aliquet malesuada est at dignissim. Pellentesque finibus "
"sagittis libero nec bibendum. Phasellus dolor ipsum, finibus quis turpis quis, mollis interdum felis.";

const std::vector<std::string> patterns = {
"aliquet",
"aliquet malesuada",
constexpr std::array patterns = {
"aliquet"sv,
"aliquet malesuada"sv,
};

void c_strstr(benchmark::State& state) {