8
8
#include < type_traits>
9
9
#include < vector>
10
10
11
- #include < udt.hpp>
12
- #include < utility.hpp>
11
+ #include " skewed_allocator.hpp"
12
+ #include " udt.hpp"
13
+ #include " utility.hpp"
13
14
14
15
template <typename Contained>
15
16
void handwritten_loop (benchmark::State& state) {
16
17
const size_t r0 = static_cast <size_t >(state.range (0 ));
17
- const auto in_buffer = random_vector<Contained>(r0);
18
- std::vector<Contained> out_buffer (r0);
18
+ const auto in_buffer = random_vector<Contained, not_highly_aligned_allocator >(r0);
19
+ std::vector<Contained, not_highly_aligned_allocator<Contained> > out_buffer (r0);
19
20
for ([[maybe_unused]] auto _ : state) {
20
21
benchmark::DoNotOptimize (in_buffer.data ());
21
22
const Contained* in_ptr = in_buffer.data ();
@@ -32,8 +33,8 @@ void handwritten_loop(benchmark::State& state) {
32
33
template <typename Contained>
33
34
void handwritten_loop_n (benchmark::State& state) {
34
35
const size_t r0 = static_cast <size_t >(state.range (0 ));
35
- const auto in_buffer = random_vector<Contained>(r0);
36
- std::vector<Contained> out_buffer (r0);
36
+ const auto in_buffer = random_vector<Contained, not_highly_aligned_allocator >(r0);
37
+ std::vector<Contained, not_highly_aligned_allocator<Contained> > out_buffer (r0);
37
38
for ([[maybe_unused]] auto _ : state) {
38
39
benchmark::DoNotOptimize (in_buffer.data ());
39
40
const Contained* const in_ptr = in_buffer.data ();
@@ -50,8 +51,8 @@ template <typename Contained>
50
51
void memcpy_call (benchmark::State& state) {
51
52
static_assert (std::is_trivially_copyable_v<Contained>, " memcpy must only be called on trivially copyable types" );
52
53
const size_t r0 = static_cast <size_t >(state.range (0 ));
53
- const auto in_buffer = random_vector<Contained>(r0);
54
- std::vector<Contained> out_buffer (r0);
54
+ const auto in_buffer = random_vector<Contained, not_highly_aligned_allocator >(r0);
55
+ std::vector<Contained, not_highly_aligned_allocator<Contained> > out_buffer (r0);
55
56
for ([[maybe_unused]] auto _ : state) {
56
57
benchmark::DoNotOptimize (in_buffer.data ());
57
58
memcpy (out_buffer.data (), in_buffer.data (), r0 * sizeof (Contained));
@@ -62,8 +63,8 @@ void memcpy_call(benchmark::State& state) {
62
63
template <typename Contained>
63
64
void std_copy_call (benchmark::State& state) {
64
65
const size_t r0 = static_cast <size_t >(state.range (0 ));
65
- const auto in_buffer = random_vector<Contained>(r0);
66
- std::vector<Contained> out_buffer (r0);
66
+ const auto in_buffer = random_vector<Contained, not_highly_aligned_allocator >(r0);
67
+ std::vector<Contained, not_highly_aligned_allocator<Contained> > out_buffer (r0);
67
68
for ([[maybe_unused]] auto _ : state) {
68
69
benchmark::DoNotOptimize (in_buffer.data ());
69
70
std::copy (in_buffer.begin (), in_buffer.end (), out_buffer.begin ());
@@ -74,8 +75,8 @@ void std_copy_call(benchmark::State& state) {
74
75
template <typename Contained>
75
76
void std_copy_n_call (benchmark::State& state) {
76
77
const size_t r0 = static_cast <size_t >(state.range (0 ));
77
- const auto in_buffer = random_vector<Contained>(r0);
78
- std::vector<Contained> out_buffer (r0);
78
+ const auto in_buffer = random_vector<Contained, not_highly_aligned_allocator >(r0);
79
+ std::vector<Contained, not_highly_aligned_allocator<Contained> > out_buffer (r0);
79
80
for ([[maybe_unused]] auto _ : state) {
80
81
benchmark::DoNotOptimize (in_buffer.data ());
81
82
std::copy_n (in_buffer.begin (), r0, out_buffer.begin ());
0 commit comments