| 1 | //===-- MemorySizeDistributions ---------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // Memory functions operate on buffers of certain sizes. This file provides |
| 10 | // probability distributions observed at runtime for a set of applications. |
| 11 | // These distributions are used to benchmark and compare memory functions |
| 12 | // implementations. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef LLVM_LIBC_BENCHMARKS_MEMORYSIZEDISTRIBUTIONS_H |
| 17 | #define LLVM_LIBC_BENCHMARKS_MEMORYSIZEDISTRIBUTIONS_H |
| 18 | |
| 19 | #include <llvm/ADT/ArrayRef.h> |
| 20 | #include <llvm/ADT/StringRef.h> |
| 21 | |
| 22 | namespace llvm { |
| 23 | namespace libc_benchmarks { |
| 24 | |
| 25 | /// A simple POD exposing caracteristics of a memory function size |
| 26 | /// distributions. The underlying data is immutable. |
| 27 | struct MemorySizeDistribution { |
| 28 | StringRef Name; // The name of the distribution. |
| 29 | ArrayRef<double> Probabilities; // Size indexed array of probabilities. |
| 30 | }; |
| 31 | |
| 32 | /// Returns a list of memmove size distributions. |
| 33 | ArrayRef<MemorySizeDistribution> getMemmoveSizeDistributions(); |
| 34 | |
| 35 | /// Returns a list of memcpy size distributions. |
| 36 | ArrayRef<MemorySizeDistribution> getMemcpySizeDistributions(); |
| 37 | |
| 38 | /// Returns a list of memset size distributions. |
| 39 | ArrayRef<MemorySizeDistribution> getMemsetSizeDistributions(); |
| 40 | |
| 41 | /// Returns a list of memcmp size distributions. |
| 42 | ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions(); |
| 43 | |
| 44 | /// Returns the first MemorySizeDistribution from Distributions with the |
| 45 | /// specified Name. |
| 46 | MemorySizeDistribution |
| 47 | getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions, |
| 48 | StringRef Name); |
| 49 | |
| 50 | } // namespace libc_benchmarks |
| 51 | } // namespace llvm |
| 52 | |
| 53 | #endif // LLVM_LIBC_BENCHMARKS_MEMORYSIZEDISTRIBUTIONS_H |
| 54 | |