| 71 | |
| 72 | template <typename Int> |
| 73 | void BM_Unpack(benchmark::State& state, bool aligned, UnpackFunc<Int> unpack, bool skip, |
| 74 | std::string skip_msg) { |
| 75 | if (skip) { |
| 76 | state.SkipWithMessage(skip_msg); |
| 77 | } |
| 78 | |
| 79 | const auto bit_width = static_cast<int32_t>(state.range(0)); |
| 80 | const auto num_values = static_cast<int32_t>(state.range(1)); |
| 81 | |
| 82 | // Assume std::vector allocation is likely be aligned for greater than a byte. |
| 83 | // So we allocate more values than necessary and skip to the next byte with the |
| 84 | // desired (non) alignment to test the proper condition. |
| 85 | constexpr int32_t kExtraValues = sizeof(Int) * 8; |
| 86 | const auto packed = GenerateRandomPackedValues(num_values + kExtraValues, bit_width); |
| 87 | const uint8_t* packed_ptr = |
| 88 | GetNextAlignedByte(packed.data(), sizeof(Int)) + (aligned ? 0 : 1); |
| 89 | |
| 90 | auto unpacked = std::make_unique<Int[]>(num_values); |
| 91 | |
| 92 | const ::arrow::internal::UnpackOptions opts{ |
| 93 | .batch_size = num_values, |
| 94 | .bit_width = bit_width, |
| 95 | .bit_offset = 0, |
| 96 | .max_read_bytes = -1, |
| 97 | }; |
| 98 | |
| 99 | for (auto _ : state) { |
| 100 | unpack(packed_ptr, unpacked.get(), opts); |
| 101 | benchmark::ClobberMemory(); |
| 102 | } |
| 103 | state.SetItemsProcessed(num_values * state.iterations()); |
| 104 | } |
| 105 | |
| 106 | // Currently, the minimum unpack SIMD kernel size is 32 and the RLE-bit-packing encoder |
| 107 | // will not emit runs larger than 512 (though other implementation might), so we biased |
nothing calls this directly
no test coverage detected