-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vectorize
find_first_of
for 8 and 16 bit elements with SSE4.2 `pcmp…
…estri` (#4466) Co-authored-by: Stephan T. Lavavej <[email protected]>
- Loading branch information
1 parent
1e7d7f8
commit 9d761bd
Showing
5 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <algorithm> | ||
#include <benchmark/benchmark.h> | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <numeric> | ||
#include <vector> | ||
|
||
using namespace std; | ||
|
||
template <class T, size_t Pos, size_t NSize, size_t HSize = Pos * 2, size_t Which = 0> | ||
void bm(benchmark::State& state) { | ||
vector<T> h(HSize, T{'.'}); | ||
vector<T> n(NSize); | ||
iota(n.begin(), n.end(), T{'a'}); | ||
|
||
static_assert(Pos < HSize); | ||
static_assert(Which < NSize); | ||
h[Pos] = n[Which]; | ||
|
||
for (auto _ : state) { | ||
benchmark::DoNotOptimize(find_first_of(h.begin(), h.end(), n.begin(), n.end())); | ||
} | ||
} | ||
|
||
BENCHMARK(bm<uint8_t, 2, 3>); | ||
BENCHMARK(bm<uint16_t, 2, 3>); | ||
|
||
BENCHMARK(bm<uint8_t, 7, 4>); | ||
BENCHMARK(bm<uint16_t, 7, 4>); | ||
|
||
BENCHMARK(bm<uint8_t, 9, 3>); | ||
BENCHMARK(bm<uint16_t, 9, 3>); | ||
|
||
BENCHMARK(bm<uint8_t, 22, 5>); | ||
BENCHMARK(bm<uint16_t, 22, 5>); | ||
|
||
BENCHMARK(bm<uint8_t, 3056, 7>); | ||
BENCHMARK(bm<uint16_t, 3056, 7>); | ||
|
||
BENCHMARK(bm<uint8_t, 1011, 11>); | ||
BENCHMARK(bm<uint16_t, 1011, 11>); | ||
|
||
BENCHMARK_MAIN(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters