-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Vectorize rotate
better
#5502
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
Merged
Merged
Vectorize rotate
better
#5502
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
664bb63
benchmark
AlexGuteniev 3d6a9b4
test coverage
AlexGuteniev 95ad7d1
vectorization
AlexGuteniev 7cdd924
Drop unnecessary `std::`.
StephanTLavavej 5f5bd0e
Add missing calling convention to `__std_rotate`.
StephanTLavavej 01d7359
Keep `actual` and `expected` in sync with less work.
StephanTLavavej f92550d
Cite GH 5506.
StephanTLavavej 0b7c678
upper_address => higher_address
StephanTLavavej 0590287
I see dead variables. They don't even know they're dead.
StephanTLavavej 6b6e37e
Sources should point to const.
StephanTLavavej bf77cd2
ranges coverage
AlexGuteniev 19b5aa2
integer class diffference coverage
AlexGuteniev d60725d
ranges benchmark
AlexGuteniev fcc41cc
more benchmark cases
AlexGuteniev ef3be12
ranges codepath
AlexGuteniev 55156e9
we want swappable
AlexGuteniev a7b6a6e
Properly detect element volatility.
StephanTLavavej 498b759
Use `_Is_trivially_ranges_swappable`...
StephanTLavavej 6a5c9f1
... so we can revert changes to ADL tests.
StephanTLavavej 501a0e4
C++20 should directly use `contiguous_iterator`.
StephanTLavavej 76d3b38
Test `_HAS_CXX20` positively.
StephanTLavavej d32b1b1
Merge branch 'main' into swirl
StephanTLavavej 085f273
Merge branch 'main' into swirl
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,58 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
#include <algorithm> | ||
#include <benchmark/benchmark.h> | ||
#include <cstdint> | ||
#include <vector> | ||
|
||
#include "skewed_allocator.hpp" | ||
#include "utility.hpp" | ||
|
||
using namespace std; | ||
|
||
enum class AlgType { Std, Rng }; | ||
|
||
template <class T, AlgType Alg> | ||
void bm_rotate(benchmark::State& state) { | ||
const auto size = static_cast<size_t>(state.range(0)); | ||
const auto n = static_cast<size_t>(state.range(1)); | ||
|
||
auto v = random_vector<T, not_highly_aligned_allocator>(size); | ||
benchmark::DoNotOptimize(v); | ||
|
||
for (auto _ : state) { | ||
if constexpr (Alg == AlgType::Std) { | ||
rotate(v.begin(), v.begin() + n, v.end()); | ||
} else { | ||
ranges::rotate(v, v.begin() + n); | ||
} | ||
benchmark::DoNotOptimize(v); | ||
} | ||
} | ||
|
||
void common_args(auto bm) { | ||
bm->Args({3333, 2242})->Args({3332, 1666})->Args({3333, 1111})->Args({3333, 501}); | ||
bm->Args({3333, 3300})->Args({3333, 12})->Args({3333, 5})->Args({3333, 1}); | ||
bm->Args({333, 101})->Args({123, 32})->Args({23, 7})->Args({12, 5})->Args({3, 2}); | ||
} | ||
|
||
struct color { | ||
uint16_t h; | ||
uint16_t s; | ||
uint16_t l; | ||
}; | ||
|
||
BENCHMARK(bm_rotate<uint8_t, AlgType::Std>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint8_t, AlgType::Rng>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint16_t, AlgType::Std>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint16_t, AlgType::Rng>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint32_t, AlgType::Std>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint32_t, AlgType::Rng>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint64_t, AlgType::Std>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<uint64_t, AlgType::Rng>)->Apply(common_args); | ||
|
||
BENCHMARK(bm_rotate<color, AlgType::Std>)->Apply(common_args); | ||
BENCHMARK(bm_rotate<color, AlgType::Rng>)->Apply(common_args); | ||
|
||
BENCHMARK_MAIN(); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.