1c400e01cSGuillaume Chatelet #include "MemorySizeDistributions.h"
2c400e01cSGuillaume Chatelet
3d3c70d9fSGuillaume Chatelet #include "llvm/Support/ErrorHandling.h"
4d3c70d9fSGuillaume Chatelet #include "llvm/Support/raw_ostream.h"
5d3c70d9fSGuillaume Chatelet
6c400e01cSGuillaume Chatelet namespace llvm {
7c400e01cSGuillaume Chatelet namespace libc_benchmarks {
8c400e01cSGuillaume Chatelet
9*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleA[] = {
10*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleA.csv"
11*13744e3dSGuillaume Chatelet };
12*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleB[] = {
13*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleB.csv"
14*13744e3dSGuillaume Chatelet };
15*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleD[] = {
16*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleD.csv"
17*13744e3dSGuillaume Chatelet };
18*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleQ[] = {
19*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleQ.csv"
20*13744e3dSGuillaume Chatelet };
21*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleL[] = {
22*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleL.csv"
23*13744e3dSGuillaume Chatelet };
24*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleM[] = {
25*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleM.csv"
26*13744e3dSGuillaume Chatelet };
27*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleS[] = {
28*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleS.csv"
29*13744e3dSGuillaume Chatelet };
30*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleW[] = {
31*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleW.csv"
32*13744e3dSGuillaume Chatelet };
33*13744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleU[] = {
34*13744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleU.csv"
35*13744e3dSGuillaume Chatelet };
368724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleA[] = {
378724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleA.csv"
388724a7ecSGuillaume Chatelet };
398724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleB[] = {
408724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleB.csv"
418724a7ecSGuillaume Chatelet };
428724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleD[] = {
438724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleD.csv"
448724a7ecSGuillaume Chatelet };
458724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleQ[] = {
468724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleQ.csv"
478724a7ecSGuillaume Chatelet };
488724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleL[] = {
498724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleL.csv"
508724a7ecSGuillaume Chatelet };
518724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleM[] = {
528724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleM.csv"
538724a7ecSGuillaume Chatelet };
548724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleS[] = {
558724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleS.csv"
568724a7ecSGuillaume Chatelet };
578724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleW[] = {
588724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleW.csv"
598724a7ecSGuillaume Chatelet };
608724a7ecSGuillaume Chatelet static constexpr double MemcmpGoogleU[] = {
618724a7ecSGuillaume Chatelet #include "distributions/MemcmpGoogleU.csv"
628724a7ecSGuillaume Chatelet };
638724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleA[] = {
648724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleA.csv"
658724a7ecSGuillaume Chatelet };
668724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleB[] = {
678724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleB.csv"
688724a7ecSGuillaume Chatelet };
69*13744e3dSGuillaume Chatelet static constexpr double MemcpyGoogleD[] = {
70*13744e3dSGuillaume Chatelet #include "distributions/MemcpyGoogleD.csv"
71*13744e3dSGuillaume Chatelet };
728724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleQ[] = {
738724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleQ.csv"
748724a7ecSGuillaume Chatelet };
758724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleL[] = {
768724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleL.csv"
778724a7ecSGuillaume Chatelet };
788724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleM[] = {
798724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleM.csv"
808724a7ecSGuillaume Chatelet };
818724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleS[] = {
828724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleS.csv"
838724a7ecSGuillaume Chatelet };
848724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleW[] = {
858724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleW.csv"
868724a7ecSGuillaume Chatelet };
878724a7ecSGuillaume Chatelet static constexpr double MemcpyGoogleU[] = {
888724a7ecSGuillaume Chatelet #include "distributions/MemcpyGoogleU.csv"
898724a7ecSGuillaume Chatelet };
908724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleA[] = {
918724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleA.csv"
928724a7ecSGuillaume Chatelet };
938724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleB[] = {
948724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleB.csv"
958724a7ecSGuillaume Chatelet };
968724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleD[] = {
978724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleD.csv"
988724a7ecSGuillaume Chatelet };
998724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleQ[] = {
1008724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleQ.csv"
1018724a7ecSGuillaume Chatelet };
1028724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleL[] = {
1038724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleL.csv"
1048724a7ecSGuillaume Chatelet };
1058724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleM[] = {
1068724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleM.csv"
1078724a7ecSGuillaume Chatelet };
1088724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleS[] = {
1098724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleS.csv"
1108724a7ecSGuillaume Chatelet };
1118724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleW[] = {
1128724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleW.csv"
1138724a7ecSGuillaume Chatelet };
1148724a7ecSGuillaume Chatelet static constexpr double MemsetGoogleU[] = {
1158724a7ecSGuillaume Chatelet #include "distributions/MemsetGoogleU.csv"
1168724a7ecSGuillaume Chatelet };
1178724a7ecSGuillaume Chatelet static constexpr double Uniform384To4096[] = {
1188724a7ecSGuillaume Chatelet #include "distributions/Uniform384To4096.csv"
1198724a7ecSGuillaume Chatelet };
120c400e01cSGuillaume Chatelet
getMemmoveSizeDistributions()121*13744e3dSGuillaume Chatelet ArrayRef<MemorySizeDistribution> getMemmoveSizeDistributions() {
122*13744e3dSGuillaume Chatelet static constexpr MemorySizeDistribution kDistributions[] = {
123*13744e3dSGuillaume Chatelet {"memmove Google A", MemmoveGoogleA},
124*13744e3dSGuillaume Chatelet {"memmove Google B", MemmoveGoogleB},
125*13744e3dSGuillaume Chatelet {"memmove Google D", MemmoveGoogleD},
126*13744e3dSGuillaume Chatelet {"memmove Google L", MemmoveGoogleL},
127*13744e3dSGuillaume Chatelet {"memmove Google M", MemmoveGoogleM},
128*13744e3dSGuillaume Chatelet {"memmove Google Q", MemmoveGoogleQ},
129*13744e3dSGuillaume Chatelet {"memmove Google S", MemmoveGoogleS},
130*13744e3dSGuillaume Chatelet {"memmove Google U", MemmoveGoogleU},
131*13744e3dSGuillaume Chatelet {"memmove Google W", MemmoveGoogleW},
132*13744e3dSGuillaume Chatelet {"uniform 384 to 4096", Uniform384To4096},
133*13744e3dSGuillaume Chatelet };
134*13744e3dSGuillaume Chatelet return kDistributions;
135*13744e3dSGuillaume Chatelet }
136*13744e3dSGuillaume Chatelet
getMemcpySizeDistributions()137d899f997SGuillaume Chatelet ArrayRef<MemorySizeDistribution> getMemcpySizeDistributions() {
138c400e01cSGuillaume Chatelet static constexpr MemorySizeDistribution kDistributions[] = {
1398724a7ecSGuillaume Chatelet {"memcpy Google A", MemcpyGoogleA},
1408724a7ecSGuillaume Chatelet {"memcpy Google B", MemcpyGoogleB},
1418724a7ecSGuillaume Chatelet {"memcpy Google D", MemcpyGoogleD},
1428724a7ecSGuillaume Chatelet {"memcpy Google L", MemcpyGoogleL},
1438724a7ecSGuillaume Chatelet {"memcpy Google M", MemcpyGoogleM},
1448724a7ecSGuillaume Chatelet {"memcpy Google Q", MemcpyGoogleQ},
1458724a7ecSGuillaume Chatelet {"memcpy Google S", MemcpyGoogleS},
1468724a7ecSGuillaume Chatelet {"memcpy Google U", MemcpyGoogleU},
1478724a7ecSGuillaume Chatelet {"memcpy Google W", MemcpyGoogleW},
1488724a7ecSGuillaume Chatelet {"uniform 384 to 4096", Uniform384To4096},
149c400e01cSGuillaume Chatelet };
150c400e01cSGuillaume Chatelet return kDistributions;
151c400e01cSGuillaume Chatelet }
152c400e01cSGuillaume Chatelet
getMemsetSizeDistributions()153d899f997SGuillaume Chatelet ArrayRef<MemorySizeDistribution> getMemsetSizeDistributions() {
154c400e01cSGuillaume Chatelet static constexpr MemorySizeDistribution kDistributions[] = {
1558724a7ecSGuillaume Chatelet {"memset Google A", MemsetGoogleA},
1568724a7ecSGuillaume Chatelet {"memset Google B", MemsetGoogleB},
1578724a7ecSGuillaume Chatelet {"memset Google D", MemsetGoogleD},
1588724a7ecSGuillaume Chatelet {"memset Google L", MemsetGoogleL},
1598724a7ecSGuillaume Chatelet {"memset Google M", MemsetGoogleM},
1608724a7ecSGuillaume Chatelet {"memset Google Q", MemsetGoogleQ},
1618724a7ecSGuillaume Chatelet {"memset Google S", MemsetGoogleS},
1628724a7ecSGuillaume Chatelet {"memset Google U", MemsetGoogleU},
1638724a7ecSGuillaume Chatelet {"memset Google W", MemsetGoogleW},
1648724a7ecSGuillaume Chatelet {"uniform 384 to 4096", Uniform384To4096},
165c400e01cSGuillaume Chatelet };
166c400e01cSGuillaume Chatelet return kDistributions;
167c400e01cSGuillaume Chatelet }
168c400e01cSGuillaume Chatelet
getMemcmpSizeDistributions()169d899f997SGuillaume Chatelet ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() {
170c400e01cSGuillaume Chatelet static constexpr MemorySizeDistribution kDistributions[] = {
1718724a7ecSGuillaume Chatelet {"memcmp Google A", MemcmpGoogleA},
1728724a7ecSGuillaume Chatelet {"memcmp Google B", MemcmpGoogleB},
1738724a7ecSGuillaume Chatelet {"memcmp Google D", MemcmpGoogleD},
1748724a7ecSGuillaume Chatelet {"memcmp Google L", MemcmpGoogleL},
1758724a7ecSGuillaume Chatelet {"memcmp Google M", MemcmpGoogleM},
1768724a7ecSGuillaume Chatelet {"memcmp Google Q", MemcmpGoogleQ},
1778724a7ecSGuillaume Chatelet {"memcmp Google S", MemcmpGoogleS},
1788724a7ecSGuillaume Chatelet {"memcmp Google U", MemcmpGoogleU},
1798724a7ecSGuillaume Chatelet {"memcmp Google W", MemcmpGoogleW},
1808724a7ecSGuillaume Chatelet {"uniform 384 to 4096", Uniform384To4096},
181c400e01cSGuillaume Chatelet };
182c400e01cSGuillaume Chatelet return kDistributions;
183c400e01cSGuillaume Chatelet }
184d3c70d9fSGuillaume Chatelet
185d3c70d9fSGuillaume Chatelet MemorySizeDistribution
getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,StringRef Name)186d3c70d9fSGuillaume Chatelet getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
187d3c70d9fSGuillaume Chatelet StringRef Name) {
188d3c70d9fSGuillaume Chatelet size_t Index = 0;
189d3c70d9fSGuillaume Chatelet for (const auto &MSD : Distributions) {
190d3c70d9fSGuillaume Chatelet if (MSD.Name == Name)
191d3c70d9fSGuillaume Chatelet return MSD;
192d3c70d9fSGuillaume Chatelet ++Index;
193d3c70d9fSGuillaume Chatelet }
194d3c70d9fSGuillaume Chatelet std::string Message;
195d3c70d9fSGuillaume Chatelet raw_string_ostream Stream(Message);
196d3c70d9fSGuillaume Chatelet Stream << "Unknown MemorySizeDistribution '" << Name
197d3c70d9fSGuillaume Chatelet << "', available distributions:\n";
198d3c70d9fSGuillaume Chatelet for (const auto &MSD : Distributions)
199d3c70d9fSGuillaume Chatelet Stream << "'" << MSD.Name << "'\n";
200d3c70d9fSGuillaume Chatelet report_fatal_error(Stream.str());
201d3c70d9fSGuillaume Chatelet }
202d3c70d9fSGuillaume Chatelet
203c400e01cSGuillaume Chatelet } // namespace libc_benchmarks
204c400e01cSGuillaume Chatelet } // namespace llvm
205