22#ifdef RANS_PARALLEL_STL
27#include <benchmark/benchmark.h>
32#ifdef ENABLE_VTUNE_PROFILER
73template <
typename source_T>
79 if (mSourceMessage.empty()) {
82 const double max = std::min(1ul << 27,
static_cast<size_t>(std::numeric_limits<source_T>::max()));
83 std::uniform_int_distribution<source_T> dist(
min,
max);
84 const size_t sourceSize = messageSize /
sizeof(
source_T) + 1;
85 mSourceMessage.resize(sourceSize);
86#ifdef RANS_PARALLEL_STL
87 std::generate(std::execution::par_unseq, mSourceMessage.begin(), mSourceMessage.end(), [&dist, &mt]() { return dist(mt); });
89 std::generate(mSourceMessage.begin(), mSourceMessage.end(), [&dist, &mt]() { return dist(mt); });
94 const auto&
get()
const {
return mSourceMessage; };
97 std::vector<source_T> mSourceMessage{};
104template <
class... Args>
108 auto args_tuple = std::make_tuple(std::move(args)...);
110 const auto&
inputData = std::get<0>(args_tuple).get();
112 using input_data_type = std::remove_cv_t<std::remove_reference_t<
decltype(
inputData)>>;
113 using source_type =
typename input_data_type::value_type;
120 const auto renormedHistogram =
renorm(histogram,
metrics, RenormingPolicy::Auto, 10);
126#ifdef ENABLE_VTUNE_PROFILER
130 decoder.process(encodeBuffer.encodeBufferEnd,
decodeBuffer.buffer.data(),
inputData.size(), encoder.getNStreams());
132#ifdef ENABLE_VTUNE_PROFILER
137 st.SkipWithError(
"Missmatch between encoded and decoded Message");
140 const auto& datasetProperties =
metrics.getDatasetProperties();
141 st.SetItemsProcessed(
static_cast<int64_t
>(
inputData.size()) *
static_cast<int64_t
>(
st.iterations()));
142 st.SetBytesProcessed(
static_cast<int64_t
>(
inputData.size()) *
sizeof(
source_type) *
static_cast<int64_t
>(
st.iterations()));
143 st.counters[
"AlphabetRangeBits"] = datasetProperties.alphabetRangeBits;
144 st.counters[
"nUsedAlphabetSymbols"] = datasetProperties.nUsedAlphabetSymbols;
145 st.counters[
"SymbolTablePrecision"] = renormedHistogram.getRenormingBits();
146 st.counters[
"Entropy"] = datasetProperties.entropy;
149 st.counters[
"CompressedSize"] = std::distance(encodeBuffer.buffer.data(), encodeBuffer.encodeBufferEnd) *
sizeof(
typename decltype(encoder)
::stream_type);
150 st.counters[
"Compression"] =
st.counters[
"SourceSize"] /
static_cast<double>(
st.counters[
"CompressedSize"]);
151 st.counters[
"LowerBound"] =
inputData.size() * (
static_cast<double>(
st.counters[
"Entropy"]) / 8);
152 st.counters[
"CompressionWRTEntropy"] =
st.counters[
"CompressedSize"] /
st.counters[
"LowerBound"];
std::vector< o2::mid::ColumnData > inputData
const SourceMessageProxyUniform< uint32_t > sourceMessageUniform32
void ransDecodeBenchmark(benchmark::State &st, Args &&... args)
constexpr size_t MessageSize
const SourceMessageProxyUniform< uint8_t > sourceMessageUniform8
BENCHMARK_CAPTURE(ransDecodeBenchmark, decode_uniform_8, sourceMessageUniform8)
const SourceMessageProxyUniform< uint16_t > sourceMessageUniform16
static constexpr decltype(auto) fromRenormed(const RenormedHistogramConcept< container_T > &renormed)
static constexpr decltype(auto) fromRenormed(const RenormedDenseHistogram< source_T > &renormed)
preprocessor defines to enable features based on CPU architecture
static factory classes for building histograms, encoders and decoders.
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
common functionality for rANS benchmarks.
public interface for building and renorming histograms from source data.
double_t computeExpectedCodewordLength(const DenseHistogram< source_T > &histogram, const RenormedDenseHistogram< source_T > &rescaledHistogram)
decltype(auto) renorm(histogram_T histogram, size_t newPrecision, RenormingPolicy renormingPolicy=RenormingPolicy::Auto, size_t lowProbabilityCutoffBits=0)
static decltype(auto) fromSamples(source_IT begin, source_IT end, typename std::iterator_traits< source_IT >::value_type min, typename std::iterator_traits< source_IT >::value_type max)
std::string decodeBuffer(int feeId, gsl::span< const std::byte > buffer)