Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 1 | #include "MemorySizeDistributions.h" |
| 2 | |
Guillaume Chatelet | d3c70d9 | 2021-07-28 14:52:29 +0000 | [diff] [blame] | 3 | #include "llvm/Support/ErrorHandling.h" |
| 4 | #include "llvm/Support/raw_ostream.h" |
| 5 | |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 6 | namespace llvm { |
| 7 | namespace libc_benchmarks { |
| 8 | |
Guillaume Chatelet | 13744e3 | 2021-11-17 09:22:05 +0000 | [diff] [blame] | 9 | static constexpr double MemmoveGoogleA[] = { |
| 10 | #include "distributions/MemmoveGoogleA.csv" |
| 11 | }; |
| 12 | static constexpr double MemmoveGoogleB[] = { |
| 13 | #include "distributions/MemmoveGoogleB.csv" |
| 14 | }; |
| 15 | static constexpr double MemmoveGoogleD[] = { |
| 16 | #include "distributions/MemmoveGoogleD.csv" |
| 17 | }; |
| 18 | static constexpr double MemmoveGoogleQ[] = { |
| 19 | #include "distributions/MemmoveGoogleQ.csv" |
| 20 | }; |
| 21 | static constexpr double MemmoveGoogleL[] = { |
| 22 | #include "distributions/MemmoveGoogleL.csv" |
| 23 | }; |
| 24 | static constexpr double MemmoveGoogleM[] = { |
| 25 | #include "distributions/MemmoveGoogleM.csv" |
| 26 | }; |
| 27 | static constexpr double MemmoveGoogleS[] = { |
| 28 | #include "distributions/MemmoveGoogleS.csv" |
| 29 | }; |
| 30 | static constexpr double MemmoveGoogleW[] = { |
| 31 | #include "distributions/MemmoveGoogleW.csv" |
| 32 | }; |
| 33 | static constexpr double MemmoveGoogleU[] = { |
| 34 | #include "distributions/MemmoveGoogleU.csv" |
| 35 | }; |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 36 | static constexpr double MemcmpGoogleA[] = { |
| 37 | #include "distributions/MemcmpGoogleA.csv" |
| 38 | }; |
| 39 | static constexpr double MemcmpGoogleB[] = { |
| 40 | #include "distributions/MemcmpGoogleB.csv" |
| 41 | }; |
| 42 | static constexpr double MemcmpGoogleD[] = { |
| 43 | #include "distributions/MemcmpGoogleD.csv" |
| 44 | }; |
| 45 | static constexpr double MemcmpGoogleQ[] = { |
| 46 | #include "distributions/MemcmpGoogleQ.csv" |
| 47 | }; |
| 48 | static constexpr double MemcmpGoogleL[] = { |
| 49 | #include "distributions/MemcmpGoogleL.csv" |
| 50 | }; |
| 51 | static constexpr double MemcmpGoogleM[] = { |
| 52 | #include "distributions/MemcmpGoogleM.csv" |
| 53 | }; |
| 54 | static constexpr double MemcmpGoogleS[] = { |
| 55 | #include "distributions/MemcmpGoogleS.csv" |
| 56 | }; |
| 57 | static constexpr double MemcmpGoogleW[] = { |
| 58 | #include "distributions/MemcmpGoogleW.csv" |
| 59 | }; |
| 60 | static constexpr double MemcmpGoogleU[] = { |
| 61 | #include "distributions/MemcmpGoogleU.csv" |
| 62 | }; |
| 63 | static constexpr double MemcpyGoogleA[] = { |
| 64 | #include "distributions/MemcpyGoogleA.csv" |
| 65 | }; |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 66 | static constexpr double MemcpyGoogleB[] = { |
| 67 | #include "distributions/MemcpyGoogleB.csv" |
| 68 | }; |
Guillaume Chatelet | 13744e3 | 2021-11-17 09:22:05 +0000 | [diff] [blame] | 69 | static constexpr double MemcpyGoogleD[] = { |
| 70 | #include "distributions/MemcpyGoogleD.csv" |
| 71 | }; |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 72 | static constexpr double MemcpyGoogleQ[] = { |
| 73 | #include "distributions/MemcpyGoogleQ.csv" |
| 74 | }; |
| 75 | static constexpr double MemcpyGoogleL[] = { |
| 76 | #include "distributions/MemcpyGoogleL.csv" |
| 77 | }; |
| 78 | static constexpr double MemcpyGoogleM[] = { |
| 79 | #include "distributions/MemcpyGoogleM.csv" |
| 80 | }; |
| 81 | static constexpr double MemcpyGoogleS[] = { |
| 82 | #include "distributions/MemcpyGoogleS.csv" |
| 83 | }; |
| 84 | static constexpr double MemcpyGoogleW[] = { |
| 85 | #include "distributions/MemcpyGoogleW.csv" |
| 86 | }; |
| 87 | static constexpr double MemcpyGoogleU[] = { |
| 88 | #include "distributions/MemcpyGoogleU.csv" |
| 89 | }; |
| 90 | static constexpr double MemsetGoogleA[] = { |
| 91 | #include "distributions/MemsetGoogleA.csv" |
| 92 | }; |
| 93 | static constexpr double MemsetGoogleB[] = { |
| 94 | #include "distributions/MemsetGoogleB.csv" |
| 95 | }; |
| 96 | static constexpr double MemsetGoogleD[] = { |
| 97 | #include "distributions/MemsetGoogleD.csv" |
| 98 | }; |
| 99 | static constexpr double MemsetGoogleQ[] = { |
| 100 | #include "distributions/MemsetGoogleQ.csv" |
| 101 | }; |
| 102 | static constexpr double MemsetGoogleL[] = { |
| 103 | #include "distributions/MemsetGoogleL.csv" |
| 104 | }; |
| 105 | static constexpr double MemsetGoogleM[] = { |
| 106 | #include "distributions/MemsetGoogleM.csv" |
| 107 | }; |
| 108 | static constexpr double MemsetGoogleS[] = { |
| 109 | #include "distributions/MemsetGoogleS.csv" |
| 110 | }; |
| 111 | static constexpr double MemsetGoogleW[] = { |
| 112 | #include "distributions/MemsetGoogleW.csv" |
| 113 | }; |
| 114 | static constexpr double MemsetGoogleU[] = { |
| 115 | #include "distributions/MemsetGoogleU.csv" |
| 116 | }; |
| 117 | static constexpr double Uniform384To4096[] = { |
| 118 | #include "distributions/Uniform384To4096.csv" |
| 119 | }; |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 120 | |
Guillaume Chatelet | 13744e3 | 2021-11-17 09:22:05 +0000 | [diff] [blame] | 121 | ArrayRef<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 | |
Guillaume Chatelet | d899f99 | 2020-11-25 14:23:31 +0000 | [diff] [blame] | 137 | ArrayRef<MemorySizeDistribution> getMemcpySizeDistributions() { |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 138 | static constexpr MemorySizeDistribution kDistributions[] = { |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 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}, |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 149 | }; |
| 150 | return kDistributions; |
| 151 | } |
| 152 | |
Guillaume Chatelet | d899f99 | 2020-11-25 14:23:31 +0000 | [diff] [blame] | 153 | ArrayRef<MemorySizeDistribution> getMemsetSizeDistributions() { |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 154 | static constexpr MemorySizeDistribution kDistributions[] = { |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 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}, |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 165 | }; |
| 166 | return kDistributions; |
| 167 | } |
| 168 | |
Guillaume Chatelet | d899f99 | 2020-11-25 14:23:31 +0000 | [diff] [blame] | 169 | ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() { |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 170 | static constexpr MemorySizeDistribution kDistributions[] = { |
Guillaume Chatelet | 8724a7e | 2021-07-13 09:59:11 +0000 | [diff] [blame] | 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}, |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 181 | }; |
| 182 | return kDistributions; |
| 183 | } |
Guillaume Chatelet | d3c70d9 | 2021-07-28 14:52:29 +0000 | [diff] [blame] | 184 | |
| 185 | MemorySizeDistribution |
| 186 | getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions, |
| 187 | StringRef Name) { |
David Peixotto | 081a80f | 2024-11-14 11:10:11 -0800 | [diff] [blame] | 188 | for (const auto &MSD : Distributions) |
Guillaume Chatelet | d3c70d9 | 2021-07-28 14:52:29 +0000 | [diff] [blame] | 189 | if (MSD.Name == Name) |
| 190 | return MSD; |
David Peixotto | 081a80f | 2024-11-14 11:10:11 -0800 | [diff] [blame] | 191 | |
Guillaume Chatelet | d3c70d9 | 2021-07-28 14:52:29 +0000 | [diff] [blame] | 192 | std::string Message; |
| 193 | raw_string_ostream Stream(Message); |
| 194 | Stream << "Unknown MemorySizeDistribution '" << Name |
| 195 | << "', available distributions:\n"; |
| 196 | for (const auto &MSD : Distributions) |
| 197 | Stream << "'" << MSD.Name << "'\n"; |
Youngsuk Kim | c3d78a7 | 2024-09-17 10:24:05 -0500 | [diff] [blame] | 198 | report_fatal_error(Message); |
Guillaume Chatelet | d3c70d9 | 2021-07-28 14:52:29 +0000 | [diff] [blame] | 199 | } |
| 200 | |
Guillaume Chatelet | c400e01 | 2020-10-15 08:01:26 +0000 | [diff] [blame] | 201 | } // namespace libc_benchmarks |
| 202 | } // namespace llvm |