| 1 | #include "MemorySizeDistributions.h" |
| 2 | |
| 3 | #include "llvm/Support/ErrorHandling.h" |
| 4 | #include "llvm/Support/raw_ostream.h" |
| 5 | |
| 6 | namespace llvm { |
| 7 | namespace libc_benchmarks { |
| 8 | |
| 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 | }; |
| 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 | }; |
| 66 | static constexpr double MemcpyGoogleB[] = { |
| 67 | #include "distributions/MemcpyGoogleB.csv" |
| 68 | }; |
| 69 | static constexpr double MemcpyGoogleD[] = { |
| 70 | #include "distributions/MemcpyGoogleD.csv" |
| 71 | }; |
| 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 | }; |
| 120 | |
| 121 | ArrayRef<MemorySizeDistribution> getMemmoveSizeDistributions() { |
| 122 | static constexpr MemorySizeDistribution kDistributions[] = { |
| 123 | {.Name: "memmove Google A" , .Probabilities: MemmoveGoogleA}, |
| 124 | {.Name: "memmove Google B" , .Probabilities: MemmoveGoogleB}, |
| 125 | {.Name: "memmove Google D" , .Probabilities: MemmoveGoogleD}, |
| 126 | {.Name: "memmove Google L" , .Probabilities: MemmoveGoogleL}, |
| 127 | {.Name: "memmove Google M" , .Probabilities: MemmoveGoogleM}, |
| 128 | {.Name: "memmove Google Q" , .Probabilities: MemmoveGoogleQ}, |
| 129 | {.Name: "memmove Google S" , .Probabilities: MemmoveGoogleS}, |
| 130 | {.Name: "memmove Google U" , .Probabilities: MemmoveGoogleU}, |
| 131 | {.Name: "memmove Google W" , .Probabilities: MemmoveGoogleW}, |
| 132 | {.Name: "uniform 384 to 4096" , .Probabilities: Uniform384To4096}, |
| 133 | }; |
| 134 | return kDistributions; |
| 135 | } |
| 136 | |
| 137 | ArrayRef<MemorySizeDistribution> getMemcpySizeDistributions() { |
| 138 | static constexpr MemorySizeDistribution kDistributions[] = { |
| 139 | {.Name: "memcpy Google A" , .Probabilities: MemcpyGoogleA}, |
| 140 | {.Name: "memcpy Google B" , .Probabilities: MemcpyGoogleB}, |
| 141 | {.Name: "memcpy Google D" , .Probabilities: MemcpyGoogleD}, |
| 142 | {.Name: "memcpy Google L" , .Probabilities: MemcpyGoogleL}, |
| 143 | {.Name: "memcpy Google M" , .Probabilities: MemcpyGoogleM}, |
| 144 | {.Name: "memcpy Google Q" , .Probabilities: MemcpyGoogleQ}, |
| 145 | {.Name: "memcpy Google S" , .Probabilities: MemcpyGoogleS}, |
| 146 | {.Name: "memcpy Google U" , .Probabilities: MemcpyGoogleU}, |
| 147 | {.Name: "memcpy Google W" , .Probabilities: MemcpyGoogleW}, |
| 148 | {.Name: "uniform 384 to 4096" , .Probabilities: Uniform384To4096}, |
| 149 | }; |
| 150 | return kDistributions; |
| 151 | } |
| 152 | |
| 153 | ArrayRef<MemorySizeDistribution> getMemsetSizeDistributions() { |
| 154 | static constexpr MemorySizeDistribution kDistributions[] = { |
| 155 | {.Name: "memset Google A" , .Probabilities: MemsetGoogleA}, |
| 156 | {.Name: "memset Google B" , .Probabilities: MemsetGoogleB}, |
| 157 | {.Name: "memset Google D" , .Probabilities: MemsetGoogleD}, |
| 158 | {.Name: "memset Google L" , .Probabilities: MemsetGoogleL}, |
| 159 | {.Name: "memset Google M" , .Probabilities: MemsetGoogleM}, |
| 160 | {.Name: "memset Google Q" , .Probabilities: MemsetGoogleQ}, |
| 161 | {.Name: "memset Google S" , .Probabilities: MemsetGoogleS}, |
| 162 | {.Name: "memset Google U" , .Probabilities: MemsetGoogleU}, |
| 163 | {.Name: "memset Google W" , .Probabilities: MemsetGoogleW}, |
| 164 | {.Name: "uniform 384 to 4096" , .Probabilities: Uniform384To4096}, |
| 165 | }; |
| 166 | return kDistributions; |
| 167 | } |
| 168 | |
| 169 | ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() { |
| 170 | static constexpr MemorySizeDistribution kDistributions[] = { |
| 171 | {.Name: "memcmp Google A" , .Probabilities: MemcmpGoogleA}, |
| 172 | {.Name: "memcmp Google B" , .Probabilities: MemcmpGoogleB}, |
| 173 | {.Name: "memcmp Google D" , .Probabilities: MemcmpGoogleD}, |
| 174 | {.Name: "memcmp Google L" , .Probabilities: MemcmpGoogleL}, |
| 175 | {.Name: "memcmp Google M" , .Probabilities: MemcmpGoogleM}, |
| 176 | {.Name: "memcmp Google Q" , .Probabilities: MemcmpGoogleQ}, |
| 177 | {.Name: "memcmp Google S" , .Probabilities: MemcmpGoogleS}, |
| 178 | {.Name: "memcmp Google U" , .Probabilities: MemcmpGoogleU}, |
| 179 | {.Name: "memcmp Google W" , .Probabilities: MemcmpGoogleW}, |
| 180 | {.Name: "uniform 384 to 4096" , .Probabilities: Uniform384To4096}, |
| 181 | }; |
| 182 | return kDistributions; |
| 183 | } |
| 184 | |
| 185 | MemorySizeDistribution |
| 186 | getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions, |
| 187 | StringRef Name) { |
| 188 | for (const auto &MSD : Distributions) |
| 189 | if (MSD.Name == Name) |
| 190 | return MSD; |
| 191 | |
| 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" ; |
| 198 | report_fatal_error(reason: Message); |
| 199 | } |
| 200 | |
| 201 | } // namespace libc_benchmarks |
| 202 | } // namespace llvm |
| 203 | |