xref: /llvm-project/libc/benchmarks/MemorySizeDistributions.cpp (revision 081a80f2b56763422183542ad10b5a6b0814312e)
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 
913744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleA[] = {
1013744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleA.csv"
1113744e3dSGuillaume Chatelet };
1213744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleB[] = {
1313744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleB.csv"
1413744e3dSGuillaume Chatelet };
1513744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleD[] = {
1613744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleD.csv"
1713744e3dSGuillaume Chatelet };
1813744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleQ[] = {
1913744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleQ.csv"
2013744e3dSGuillaume Chatelet };
2113744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleL[] = {
2213744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleL.csv"
2313744e3dSGuillaume Chatelet };
2413744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleM[] = {
2513744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleM.csv"
2613744e3dSGuillaume Chatelet };
2713744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleS[] = {
2813744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleS.csv"
2913744e3dSGuillaume Chatelet };
3013744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleW[] = {
3113744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleW.csv"
3213744e3dSGuillaume Chatelet };
3313744e3dSGuillaume Chatelet static constexpr double MemmoveGoogleU[] = {
3413744e3dSGuillaume Chatelet #include "distributions/MemmoveGoogleU.csv"
3513744e3dSGuillaume 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 };
6913744e3dSGuillaume Chatelet static constexpr double MemcpyGoogleD[] = {
7013744e3dSGuillaume Chatelet #include "distributions/MemcpyGoogleD.csv"
7113744e3dSGuillaume 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 
12113744e3dSGuillaume Chatelet ArrayRef<MemorySizeDistribution> getMemmoveSizeDistributions() {
12213744e3dSGuillaume Chatelet   static constexpr MemorySizeDistribution kDistributions[] = {
12313744e3dSGuillaume Chatelet       {"memmove Google A", MemmoveGoogleA},
12413744e3dSGuillaume Chatelet       {"memmove Google B", MemmoveGoogleB},
12513744e3dSGuillaume Chatelet       {"memmove Google D", MemmoveGoogleD},
12613744e3dSGuillaume Chatelet       {"memmove Google L", MemmoveGoogleL},
12713744e3dSGuillaume Chatelet       {"memmove Google M", MemmoveGoogleM},
12813744e3dSGuillaume Chatelet       {"memmove Google Q", MemmoveGoogleQ},
12913744e3dSGuillaume Chatelet       {"memmove Google S", MemmoveGoogleS},
13013744e3dSGuillaume Chatelet       {"memmove Google U", MemmoveGoogleU},
13113744e3dSGuillaume Chatelet       {"memmove Google W", MemmoveGoogleW},
13213744e3dSGuillaume Chatelet       {"uniform 384 to 4096", Uniform384To4096},
13313744e3dSGuillaume Chatelet   };
13413744e3dSGuillaume Chatelet   return kDistributions;
13513744e3dSGuillaume Chatelet }
13613744e3dSGuillaume Chatelet 
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 
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 
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
186d3c70d9fSGuillaume Chatelet getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
187d3c70d9fSGuillaume Chatelet                      StringRef Name) {
188*081a80f2SDavid Peixotto   for (const auto &MSD : Distributions)
189d3c70d9fSGuillaume Chatelet     if (MSD.Name == Name)
190d3c70d9fSGuillaume Chatelet       return MSD;
191*081a80f2SDavid Peixotto 
192d3c70d9fSGuillaume Chatelet   std::string Message;
193d3c70d9fSGuillaume Chatelet   raw_string_ostream Stream(Message);
194d3c70d9fSGuillaume Chatelet   Stream << "Unknown MemorySizeDistribution '" << Name
195d3c70d9fSGuillaume Chatelet          << "', available distributions:\n";
196d3c70d9fSGuillaume Chatelet   for (const auto &MSD : Distributions)
197d3c70d9fSGuillaume Chatelet     Stream << "'" << MSD.Name << "'\n";
198c3d78a7aSYoungsuk Kim   report_fatal_error(Message);
199d3c70d9fSGuillaume Chatelet }
200d3c70d9fSGuillaume Chatelet 
201c400e01cSGuillaume Chatelet } // namespace libc_benchmarks
202c400e01cSGuillaume Chatelet } // namespace llvm
203