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