diff options
author | Kenneth Heafield <github@kheafield.com> | 2020-04-04 19:49:10 +0300 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2020-04-04 19:49:10 +0300 |
commit | 8fb1582b6d63d7df5f9d7b488199868d9093ff84 (patch) | |
tree | 85b081171f8e44103e0a3f444d1e93e9f5093265 | |
parent | c35e3d2281ae50af675c8a323726620f9e23332b (diff) |
More thoroughly test reduction code
-rw-r--r-- | test/tile_test.inl | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/test/tile_test.inl b/test/tile_test.inl index c612ace..7e23a81 100644 --- a/test/tile_test.inl +++ b/test/tile_test.inl @@ -67,21 +67,24 @@ struct Pack32Test { std::mt19937 gen; std::uniform_int_distribution<int32_t> dist(std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::max()); int32_t reference[ArrayLen]; - memset(reference, 0, sizeof(reference)); - for (Index i = 0; i < Valid; ++i) { - int32_t temp[kPack]; - for (std::size_t j = 0; j < kPack; ++j) { - temp[j] = dist(gen); - reference[i] += temp[j]; + // Do 20 different loops of random numbers. + for (Index attempt = 0; attempt < 20; ++attempt) { + memset(reference, 0, sizeof(reference)); + for (Index i = 0; i < Valid; ++i) { + int32_t temp[kPack]; + for (std::size_t j = 0; j < kPack; ++j) { + temp[j] = dist(gen); + reference[i] += temp[j]; + } + memcpy(®s[i], temp, sizeof(Register)); + } + // Decay type for template. + Register *indirect = regs; + Pack32<Valid, Sum32Op>(indirect); + const int32_t *test = reinterpret_cast<const int32_t*>(regs); + for (Index i = 0; i < Valid; ++i) { + CHECK(test[i] == reference[i]); } - memcpy(®s[i], temp, sizeof(Register)); - } - // Decay type for template. - Register *indirect = regs; - Pack32<Valid, Sum32Op>(indirect); - const int32_t *test = reinterpret_cast<const int32_t*>(regs); - for (Index i = 0; i < Valid; ++i) { - CHECK(test[i] == reference[i]); } } }; |