diff options
author | Kenneth Heafield <kheafiel@amazon.com> | 2020-03-05 18:41:54 +0300 |
---|---|---|
committer | Kenneth Heafield <kheafiel@amazon.com> | 2020-03-05 18:41:54 +0300 |
commit | 3e972719347b5469ec4ebe11b14e8f3cf55aa060 (patch) | |
tree | 22e2998bb262fa5742a874911cf58365ff49d5d7 | |
parent | c9da73d69fe1a208e8e8953dbd0c3170dda51120 (diff) |
Make multiply_sat_test compile on older compilers
-rw-r--r-- | test/kernels/multiply_sat_test.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/kernels/multiply_sat_test.cc b/test/kernels/multiply_sat_test.cc index 87fc09a..0e86c0e 100644 --- a/test/kernels/multiply_sat_test.cc +++ b/test/kernels/multiply_sat_test.cc @@ -21,13 +21,13 @@ void kernel_multiply_sat_test() { std::iota(input1.begin(), input1.end(), -int(VECTOR_LENGTH / 2)); std::iota(input2.begin(), input2.end(), -int(VECTOR_LENGTH / 3)); - for (std::size_t shift = 0; shift <= 2 * 8 * sizeof(Type_); ++shift) { - *output.template as<vec_t>() = kernels::multiply_sat<Type_>(*input1.template as<vec_t>(), *input2.template as<vec_t>(), shift); - for (std::size_t i = 0; i < output.size(); ++i) { - auto ref = (int64_t(input1[i]) * input2[i]) >> shift; - auto ref_sat = Type_(std::min<int64_t>(std::numeric_limits<Type_>::max(), std::max<int64_t>(std::numeric_limits<Type_>::min(), ref))); - CHECK(output[i] == ref_sat); - } + // TODO: try all shifts. The shift must be an immediate. + std::size_t shift = 1; + *output.template as<vec_t>() = kernels::multiply_sat<Type_>(*input1.template as<vec_t>(), *input2.template as<vec_t>(), shift); + for (std::size_t i = 0; i < output.size(); ++i) { + auto ref = (int64_t(input1[i]) * input2[i]) >> shift; + auto ref_sat = Type_(std::min<int64_t>(std::numeric_limits<Type_>::max(), std::max<int64_t>(std::numeric_limits<Type_>::min(), ref))); + CHECK(output[i] == ref_sat); } } |