1#include "MemorySizeDistributions.h"
2
3#include "llvm/Support/ErrorHandling.h"
4#include "llvm/Support/raw_ostream.h"
5
6namespace llvm {
7namespace libc_benchmarks {
8
9static constexpr double MemmoveGoogleA[] = {
10#include "distributions/MemmoveGoogleA.csv"
11};
12static constexpr double MemmoveGoogleB[] = {
13#include "distributions/MemmoveGoogleB.csv"
14};
15static constexpr double MemmoveGoogleD[] = {
16#include "distributions/MemmoveGoogleD.csv"
17};
18static constexpr double MemmoveGoogleQ[] = {
19#include "distributions/MemmoveGoogleQ.csv"
20};
21static constexpr double MemmoveGoogleL[] = {
22#include "distributions/MemmoveGoogleL.csv"
23};
24static constexpr double MemmoveGoogleM[] = {
25#include "distributions/MemmoveGoogleM.csv"
26};
27static constexpr double MemmoveGoogleS[] = {
28#include "distributions/MemmoveGoogleS.csv"
29};
30static constexpr double MemmoveGoogleW[] = {
31#include "distributions/MemmoveGoogleW.csv"
32};
33static constexpr double MemmoveGoogleU[] = {
34#include "distributions/MemmoveGoogleU.csv"
35};
36static constexpr double MemcmpGoogleA[] = {
37#include "distributions/MemcmpGoogleA.csv"
38};
39static constexpr double MemcmpGoogleB[] = {
40#include "distributions/MemcmpGoogleB.csv"
41};
42static constexpr double MemcmpGoogleD[] = {
43#include "distributions/MemcmpGoogleD.csv"
44};
45static constexpr double MemcmpGoogleQ[] = {
46#include "distributions/MemcmpGoogleQ.csv"
47};
48static constexpr double MemcmpGoogleL[] = {
49#include "distributions/MemcmpGoogleL.csv"
50};
51static constexpr double MemcmpGoogleM[] = {
52#include "distributions/MemcmpGoogleM.csv"
53};
54static constexpr double MemcmpGoogleS[] = {
55#include "distributions/MemcmpGoogleS.csv"
56};
57static constexpr double MemcmpGoogleW[] = {
58#include "distributions/MemcmpGoogleW.csv"
59};
60static constexpr double MemcmpGoogleU[] = {
61#include "distributions/MemcmpGoogleU.csv"
62};
63static constexpr double MemcpyGoogleA[] = {
64#include "distributions/MemcpyGoogleA.csv"
65};
66static constexpr double MemcpyGoogleB[] = {
67#include "distributions/MemcpyGoogleB.csv"
68};
69static constexpr double MemcpyGoogleD[] = {
70#include "distributions/MemcpyGoogleD.csv"
71};
72static constexpr double MemcpyGoogleQ[] = {
73#include "distributions/MemcpyGoogleQ.csv"
74};
75static constexpr double MemcpyGoogleL[] = {
76#include "distributions/MemcpyGoogleL.csv"
77};
78static constexpr double MemcpyGoogleM[] = {
79#include "distributions/MemcpyGoogleM.csv"
80};
81static constexpr double MemcpyGoogleS[] = {
82#include "distributions/MemcpyGoogleS.csv"
83};
84static constexpr double MemcpyGoogleW[] = {
85#include "distributions/MemcpyGoogleW.csv"
86};
87static constexpr double MemcpyGoogleU[] = {
88#include "distributions/MemcpyGoogleU.csv"
89};
90static constexpr double MemsetGoogleA[] = {
91#include "distributions/MemsetGoogleA.csv"
92};
93static constexpr double MemsetGoogleB[] = {
94#include "distributions/MemsetGoogleB.csv"
95};
96static constexpr double MemsetGoogleD[] = {
97#include "distributions/MemsetGoogleD.csv"
98};
99static constexpr double MemsetGoogleQ[] = {
100#include "distributions/MemsetGoogleQ.csv"
101};
102static constexpr double MemsetGoogleL[] = {
103#include "distributions/MemsetGoogleL.csv"
104};
105static constexpr double MemsetGoogleM[] = {
106#include "distributions/MemsetGoogleM.csv"
107};
108static constexpr double MemsetGoogleS[] = {
109#include "distributions/MemsetGoogleS.csv"
110};
111static constexpr double MemsetGoogleW[] = {
112#include "distributions/MemsetGoogleW.csv"
113};
114static constexpr double MemsetGoogleU[] = {
115#include "distributions/MemsetGoogleU.csv"
116};
117static constexpr double Uniform384To4096[] = {
118#include "distributions/Uniform384To4096.csv"
119};
120
121ArrayRef<MemorySizeDistribution> getMemmoveSizeDistributions() {
122 static constexpr MemorySizeDistribution kDistributions[] = {
123 {"memmove Google A", MemmoveGoogleA},
124 {"memmove Google B", MemmoveGoogleB},
125 {"memmove Google D", MemmoveGoogleD},
126 {"memmove Google L", MemmoveGoogleL},
127 {"memmove Google M", MemmoveGoogleM},
128 {"memmove Google Q", MemmoveGoogleQ},
129 {"memmove Google S", MemmoveGoogleS},
130 {"memmove Google U", MemmoveGoogleU},
131 {"memmove Google W", MemmoveGoogleW},
132 {"uniform 384 to 4096", Uniform384To4096},
133 };
134 return kDistributions;
135}
136
137ArrayRef<MemorySizeDistribution> getMemcpySizeDistributions() {
138 static constexpr MemorySizeDistribution kDistributions[] = {
139 {"memcpy Google A", MemcpyGoogleA},
140 {"memcpy Google B", MemcpyGoogleB},
141 {"memcpy Google D", MemcpyGoogleD},
142 {"memcpy Google L", MemcpyGoogleL},
143 {"memcpy Google M", MemcpyGoogleM},
144 {"memcpy Google Q", MemcpyGoogleQ},
145 {"memcpy Google S", MemcpyGoogleS},
146 {"memcpy Google U", MemcpyGoogleU},
147 {"memcpy Google W", MemcpyGoogleW},
148 {"uniform 384 to 4096", Uniform384To4096},
149 };
150 return kDistributions;
151}
152
153ArrayRef<MemorySizeDistribution> getMemsetSizeDistributions() {
154 static constexpr MemorySizeDistribution kDistributions[] = {
155 {"memset Google A", MemsetGoogleA},
156 {"memset Google B", MemsetGoogleB},
157 {"memset Google D", MemsetGoogleD},
158 {"memset Google L", MemsetGoogleL},
159 {"memset Google M", MemsetGoogleM},
160 {"memset Google Q", MemsetGoogleQ},
161 {"memset Google S", MemsetGoogleS},
162 {"memset Google U", MemsetGoogleU},
163 {"memset Google W", MemsetGoogleW},
164 {"uniform 384 to 4096", Uniform384To4096},
165 };
166 return kDistributions;
167}
168
169ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() {
170 static constexpr MemorySizeDistribution kDistributions[] = {
171 {"memcmp Google A", MemcmpGoogleA},
172 {"memcmp Google B", MemcmpGoogleB},
173 {"memcmp Google D", MemcmpGoogleD},
174 {"memcmp Google L", MemcmpGoogleL},
175 {"memcmp Google M", MemcmpGoogleM},
176 {"memcmp Google Q", MemcmpGoogleQ},
177 {"memcmp Google S", MemcmpGoogleS},
178 {"memcmp Google U", MemcmpGoogleU},
179 {"memcmp Google W", MemcmpGoogleW},
180 {"uniform 384 to 4096", Uniform384To4096},
181 };
182 return kDistributions;
183}
184
185MemorySizeDistribution
186getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
187 StringRef Name) {
188 size_t Index = 0;
189 for (const auto &MSD : Distributions) {
190 if (MSD.Name == Name)
191 return MSD;
192 ++Index;
193 }
194 std::string Message;
195 raw_string_ostream Stream(Message);
196 Stream << "Unknown MemorySizeDistribution '" << Name
197 << "', available distributions:\n";
198 for (const auto &MSD : Distributions)
199 Stream << "'" << MSD.Name << "'\n";
200 report_fatal_error(Stream.str());
201}
202
203} // namespace libc_benchmarks
204} // namespace llvm
205

source code of libc/benchmarks/MemorySizeDistributions.cpp