Index: unit_test/planar_test.cc |
diff --git a/unit_test/planar_test.cc b/unit_test/planar_test.cc |
index c017c26a3b3fea8745abae7e9eed91973a853016..be35b12b8c188ab6d3b3cabb1b947060d1c78c26 100644 |
--- a/unit_test/planar_test.cc |
+++ b/unit_test/planar_test.cc |
@@ -2130,15 +2130,48 @@ int TestHalfFloatPlane(int benchmark_width, int benchmark_height, |
return diff; |
} |
+#if defined(__arm__) |
+static void EnableFlushDenormalToZero(void) { |
+ uint32_t cw; |
+ __asm__ __volatile__ ( |
+ "vmrs %0, fpscr \n" |
+ "orr %0, %0, #0x1000000 \n" |
+ "vmsr fpscr, %0 \n" |
+ : "=r"(cw) :: "memory"); |
+} |
+#endif |
+ |
// 5 bit exponent with bias of 15 will underflow to a denormal if scale causes |
// exponent to be less than 0. 15 - log2(65536) = -1/ This shouldnt normally |
// happen since scale is 1/(1<<bits) where bits is 9, 10 or 12. |
-#define MAXHALFDIFF 0 |
+ |
+#define MAXHALFDENORMALDIFF 0 |
TEST_F(LibYUVPlanarTest, TestHalfFloatPlane_16bit_denormal) { |
+// 32 bit arm rounding on denormal is case is off by 1 compared to C. |
wangcheng
2016/11/05 00:25:02
remove "is" in the comment
fbarchard1
2016/11/07 17:43:51
Done.
|
+#if defined(__arm__) |
+ EnableFlushDenormalToZero(); |
+#endif |
int diff = TestHalfFloatPlane(benchmark_width_, benchmark_height_, |
benchmark_iterations_, |
disable_cpu_flags_, benchmark_cpu_info_, |
1.0f / 65536.0f, 65535); |
+ EXPECT_LE(diff, MAXHALFDENORMALDIFF); |
+} |
+ |
+#define MAXHALFDIFF 0 |
+TEST_F(LibYUVPlanarTest, TestHalfFloatPlane_16bit_One) { |
+ int diff = TestHalfFloatPlane(benchmark_width_, benchmark_height_, |
+ benchmark_iterations_, |
+ disable_cpu_flags_, benchmark_cpu_info_, |
+ 1.0f, 65535); |
+ EXPECT_LE(diff, MAXHALFDIFF); |
+} |
+ |
+TEST_F(LibYUVPlanarTest, TestHalfFloatPlane_16bit_Opt) { |
+ int diff = TestHalfFloatPlane(benchmark_width_, benchmark_height_, |
+ benchmark_iterations_, |
+ disable_cpu_flags_, benchmark_cpu_info_, |
+ 1.0f / 4096.0f, 65535); |
EXPECT_LE(diff, MAXHALFDIFF); |
} |