From a766ca87bfb1129a8cf4f8a428121caf60726de4 Mon Sep 17 00:00:00 2001 From: mtklein Date: Tue, 26 Jan 2016 07:40:30 -0800 Subject: de-proc sk_float_rsqrt This is the first of many little baby steps to have us stop runtime-detecting NEON. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1616013003 CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot Committed: https://skia.googlesource.com/skia/+/efcc125acd2d71eb077caf6db65fdd6b9eb1dc0d Review URL: https://codereview.chromium.org/1616013003 --- tests/MathTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests/MathTest.cpp') diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index 24e46f3097..de7ad1db78 100644 --- a/tests/MathTest.cpp +++ b/tests/MathTest.cpp @@ -382,14 +382,15 @@ static void unittest_half(skiatest::Reporter* reporter) { } -static void test_rsqrt(skiatest::Reporter* reporter) { +template +static void test_rsqrt(skiatest::Reporter* reporter, RSqrtFn rsqrt) { const float maxRelativeError = 6.50196699e-4f; // test close to 0 up to 1 float input = 0.000001f; for (int i = 0; i < 1000; ++i) { float exact = 1.0f/sk_float_sqrt(input); - float estimate = sk_float_rsqrt(input); + float estimate = rsqrt(input); float relativeError = sk_float_abs(exact - estimate)/exact; REPORTER_ASSERT(reporter, relativeError <= maxRelativeError); input += 0.001f; @@ -399,7 +400,7 @@ static void test_rsqrt(skiatest::Reporter* reporter) { input = 1.0f; for (int i = 0; i < 1000; ++i) { float exact = 1.0f/sk_float_sqrt(input); - float estimate = sk_float_rsqrt(input); + float estimate = rsqrt(input); float relativeError = sk_float_abs(exact - estimate)/exact; REPORTER_ASSERT(reporter, relativeError <= maxRelativeError); input += 0.01f; @@ -409,7 +410,7 @@ static void test_rsqrt(skiatest::Reporter* reporter) { input = 1000000.0f; for (int i = 0; i < 100; ++i) { float exact = 1.0f/sk_float_sqrt(input); - float estimate = sk_float_rsqrt(input); + float estimate = rsqrt(input); float relativeError = sk_float_abs(exact - estimate)/exact; REPORTER_ASSERT(reporter, relativeError <= maxRelativeError); input += 754326.f; @@ -555,7 +556,8 @@ DEF_TEST(Math, reporter) { unittest_fastfloat(reporter); unittest_isfinite(reporter); unittest_half(reporter); - test_rsqrt(reporter); + test_rsqrt(reporter, sk_float_rsqrt); + test_rsqrt(reporter, sk_float_rsqrt_portable); for (i = 0; i < 10000; i++) { SkFixed numer = rand.nextS(); -- cgit v1.2.3