| 2971 | |
| 2972 | template <typename kernel_type_> |
| 2973 | static void spread_memory(bm::State &state, kernel_type_ kernel, std::size_t align = sizeof(spread_data_t)) { |
| 2974 | std::size_t const size = static_cast<std::size_t>(state.range(0)); |
| 2975 | aligned_array<spread_index_t> indices(size, align); |
| 2976 | aligned_array<spread_data_t> first(size, align); |
| 2977 | aligned_array<spread_data_t> second(size, align); |
| 2978 | |
| 2979 | std::iota(indices.begin(), indices.begin() + size, 0); |
| 2980 | std::random_device random_device; |
| 2981 | std::mt19937 generator(random_device()); |
| 2982 | std::shuffle(indices.begin(), indices.begin() + size, generator); |
| 2983 | |
| 2984 | for (auto _ : state) kernel(first.begin(), indices.begin(), second.begin(), size); |
| 2985 | } |
| 2986 | |
| 2987 | BENCHMARK_CAPTURE(spread_memory, gather_scalar, spread_gather_scalar) |
| 2988 | ->Range(1 << 10, 1 << 20) |