diff options
author | Kenneth Heafield <github@kheafield.com> | 2018-06-24 16:45:16 +0300 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2018-06-24 16:45:16 +0300 |
commit | 4b5fd12cc5ce5489ce6effc186561ae212bd5075 (patch) | |
tree | 1a95f195f0c1a50d2dc44456d31a3c5414c4c082 /benchmark.cc | |
parent | 07a9d52920758488414d4d192e03343ad72b88e2 (diff) |
Don't segfault on CPUs without everything
Diffstat (limited to 'benchmark.cc')
-rw-r--r-- | benchmark.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/benchmark.cc b/benchmark.cc index 7e66c5b..ce177c3 100644 --- a/benchmark.cc +++ b/benchmark.cc @@ -71,7 +71,7 @@ struct BackendStats { std::vector<std::vector<uint64_t> > avx512_16bit; }; -void Summarize(std::vector<uint64_t> &stats) { +void Summarize(const std::vector<uint64_t> &stats) { double avg = 0.0; for (std::vector<uint64_t>::const_iterator i = stats.begin(); i != stats.end(); ++i) { avg += *i; @@ -86,10 +86,10 @@ void Summarize(std::vector<uint64_t> &stats) { std::cout << std::setw(8) << *std::min_element(stats.begin(), stats.end()) << '\t' << std::setw(8) << (uint64_t)avg << '\t' << std::setw(8) << (uint64_t)s; } -template <class Backend> void Print(std::vector<uint64_t> &stats) { +template <class Backend> void Print(const std::vector<std::vector<uint64_t> > &stats, int index) { if (stats.empty()) return; std::cout << Backend::kName << '\t'; - Summarize(stats); + Summarize(stats[index]); std::cout << '\n'; } @@ -140,13 +140,13 @@ int main(int argc, char ** argv) { for (std::size_t i = 0; i < sizeof(matrices) / sizeof(RandomMatrices); ++i) { std::cout << matrices[i].A_rows << '\t' << matrices[i].width << '\t' << matrices[i].B_cols << '\n'; - Print<SSSE3_8bit>(stats.ssse3_8bit[i]); - Print<AVX2_8bit>(stats.avx2_8bit[i]); - Print<AVX512_8bit>(stats.avx512_8bit[i]); + Print<SSSE3_8bit>(stats.ssse3_8bit, i); + Print<AVX2_8bit>(stats.avx2_8bit, i); + Print<AVX512_8bit>(stats.avx512_8bit, i); - Print<SSE2_16bit>(stats.sse2_16bit[i]); - Print<AVX2_16bit>(stats.avx2_16bit[i]); - Print<AVX512_16bit>(stats.avx512_16bit[i]); + Print<SSE2_16bit>(stats.sse2_16bit, i); + Print<AVX2_16bit>(stats.avx2_16bit, i); + Print<AVX512_16bit>(stats.avx512_16bit, i); } return 0; } |