aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Float16Test.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2016-07-14 12:03:04 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-14 12:03:04 -0700
commit64bbad360f30930befafee1bdefe4ad89f130dac (patch)
tree5e97d31dc9a0075de95cc2389427cb9138df466b /tests/Float16Test.cpp
parent3296bee70d074bb8094b3229dbe12fa016657e90 (diff)
Revert of Expand _01 half<->float limitation to _finite. Simplify. (patchset #7 id:120001 of https://codereview.chromium.org/2145663003/ )
Reason for revert: Unit tests fail on Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Fast Original issue's description: > Expand _01 half<->float limitation to _finite. Simplify. > > It's become clear we need to sometimes deal with values <0 or >1. > I'm not yet convinced we care about NaN or +-inf. > > We had some fairly clever tricks and optimizations here for NEON > and SSE. I've thrown them out in favor of a single implementation. > If we find the specializations mattered, we can certainly figure out > how to extend them to this new range/domain. > > This happens to add a vectorized float -> half for ARMv7, which was > missing from the _01 version. (The SSE strategy was not portable to > platforms that flush denorm floats to zero.) > > I've tested the full float range for FloatToHalf on my desktop and a 5x. > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2145663003 > CQ_INCLUDE_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot;master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot,Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-Fast-Trybot > > Committed: https://skia.googlesource.com/skia/+/3296bee70d074bb8094b3229dbe12fa016657e90 TBR=msarett@google.com,mtklein@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review-Url: https://codereview.chromium.org/2151023003
Diffstat (limited to 'tests/Float16Test.cpp')
-rw-r--r--tests/Float16Test.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/Float16Test.cpp b/tests/Float16Test.cpp
index 2091652522..cc5efedae6 100644
--- a/tests/Float16Test.cpp
+++ b/tests/Float16Test.cpp
@@ -61,26 +61,26 @@ static uint32_t u(float f) {
return x;
}
-DEF_TEST(HalfToFloat_finite, r) {
- for (uint32_t h = 0; h <= 0xffff; h++) {
+DEF_TEST(HalfToFloat_01, r) {
+ for (uint16_t h = 0; h < 0x8000; h++) {
float f = SkHalfToFloat(h);
- if (isfinite(f)) {
- float got = SkHalfToFloat_finite(h)[0];
+ if (f >= 0 && f <= 1) {
+ float got = SkHalfToFloat_01(h)[0];
if (got != f) {
SkDebugf("0x%04x -> 0x%08x (%g), want 0x%08x (%g)\n",
h,
u(got), got,
u(f), f);
}
- REPORTER_ASSERT(r, SkHalfToFloat_finite(h)[0] == f);
- REPORTER_ASSERT(r, SkFloatToHalf_finite(SkHalfToFloat_finite(h)) == h);
+ REPORTER_ASSERT(r, SkHalfToFloat_01(h)[0] == f);
+ REPORTER_ASSERT(r, SkFloatToHalf_01(SkHalfToFloat_01(h)) == h);
}
}
}
-DEF_TEST(FloatToHalf_finite, r) {
+DEF_TEST(FloatToHalf_01, r) {
#if 0
- for (uint64_t bits = 0; bits <= 0xffffffff; bits++) {
+ for (uint32_t bits = 0; bits < 0x80000000; bits++) {
#else
SkRandom rand;
for (int i = 0; i < 1000000; i++) {
@@ -88,14 +88,14 @@ DEF_TEST(FloatToHalf_finite, r) {
#endif
float f;
memcpy(&f, &bits, 4);
- if (isfinite(f) && isfinite(SkHalfToFloat(SkFloatToHalf(f)))) {
- uint16_t h1 = (uint16_t)SkFloatToHalf_finite(Sk4f(f,0,0,0)),
+ if (f >= 0 && f <= 1) {
+ uint16_t h1 = (uint16_t)SkFloatToHalf_01(Sk4f(f,0,0,0)),
h2 = SkFloatToHalf(f);
bool ok = (h1 == h2 || h1 == h2-1);
REPORTER_ASSERT(r, ok);
if (!ok) {
- SkDebugf("%08x (%g) -> %04x, want %04x (%g)\n",
- bits, f, h1, h2, SkHalfToFloat(h2));
+ SkDebugf("%08x (%d) -> %04x (%d), want %04x (%d)\n",
+ bits, bits>>23, h1, h1>>10, h2, h2>>10);
break;
}
}