Add x86 optimization of rint functions and tests
Change-Id: I5e7696ff9bcb1efc2625100ef8565b68dca2326c
Signed-off-by: Jingwei Zhang <jingwei.zhang@intel.com>
diff --git a/tests/math_data_test.h b/tests/math_data_test.h
index 8aa2bf1..0aba701 100644
--- a/tests/math_data_test.h
+++ b/tests/math_data_test.h
@@ -30,6 +30,18 @@
T1 input;
};
+template <typename T1>
+struct data_long_1_t {
+ long expected;
+ T1 input;
+};
+
+template <typename T1>
+struct data_llong_1_t {
+ long long expected;
+ T1 input;
+};
+
template <typename RT, typename T1, typename T2>
struct data_1_2_t {
RT expected;
@@ -157,6 +169,28 @@
}
}
+// Runs through the array 'data' applying 'f' to each of the input values
+// and asserting that the result is within ULP ulps of the expected value.
+// For testing a (double) -> long int function like lrint(3).
+template <size_t ULP, typename T, size_t N>
+void DoMathDataTest(data_long_1_t<T> (&data)[N], long f(T)) {
+ fesetenv(FE_DFL_ENV);
+ for (size_t i = 0; i < N; ++i) {
+ EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
+ }
+}
+
+// Runs through the array 'data' applying 'f' to each of the input values
+// and asserting that the result is within ULP ulps of the expected value.
+// For testing a (double) -> long long int function like llrint(3).
+template <size_t ULP, typename T, size_t N>
+void DoMathDataTest(data_llong_1_t<T> (&data)[N], long long f(T)) {
+ fesetenv(FE_DFL_ENV);
+ for (size_t i = 0; i < N; ++i) {
+ EXPECT_EQ(data[i].expected, f(data[i].input)) << "Failed on element " << i;
+ }
+}
+
// Runs through the array 'data' applying 'f' to each of the pairs of input values
// and asserting that the result is within ULP ulps of the expected value.
// For testing a (double, double) -> double function like pow(3).