diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-10-16 13:54:38 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2017-11-21 20:01:23 +0000 |
commit | b8e352ad378ce4ef7a517971533b02ec9c3768cb (patch) | |
tree | 1edc11dddc8784285c0ee1914e7f33d2569e6d7e /tests/auto/corelib | |
parent | 0ac2dca977ecc4020f51af57908a2640d00bcd9e (diff) |
Add functions for fast bulk conversion of qfloat16
Both ARM and x86 can convert fp16 much faster in bulk than one at a
time. This also enables hardware accelerated conversion on x86, when
F16C isn't unconditionally available at compile time.
This code is implemented in C to ensure that there's no leakage of
inline symbols from the .obj file that was compiled by Visual Studio
with AVX support. Unfortunately, simd.prf uses $(CXX) instead of $(CC)
for all its sources, which means the file gets interpreted as C++ by
g++, clang++ and icpc. Those compilers at least don't leak any symbols.
Done-with: Thiago Macieira <thiago.macieira@intel.com>
Change-Id: I9d26d99e83392861fb09564e0e8e8d76cd8483b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp | 38 | ||||
-rw-r--r-- | tests/auto/corelib/global/qglobal/qglobal.c | 6 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 9bd87e3f21..d2902f4944 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -46,6 +46,8 @@ private slots: void promotionTests(); void arithOps_data(); void arithOps(); + void floatToFloat16(); + void floatFromFloat16(); }; void tst_qfloat16::fuzzyCompare_data() @@ -305,5 +307,41 @@ void tst_qfloat16::arithOps() QVERIFY(qFuzzyCompare(r4,1.f/val2)); } +void tst_qfloat16::floatToFloat16() +{ + float in[63]; + qfloat16 out[63]; + qfloat16 expected[63]; + + for (int i = 0; i < 63; ++i) + in[i] = i * (1/13.f); + + for (int i = 0; i < 63; ++i) + expected[i] = qfloat16(in[i]); + + qFloatToFloat16(out, in, 63); + + for (int i = 0; i < 63; ++i) + QVERIFY(qFuzzyCompare(out[i], expected[i])); +} + +void tst_qfloat16::floatFromFloat16() +{ + qfloat16 in[35]; + float out[35]; + float expected[35]; + + for (int i = 0; i < 35; ++i) + in[i] = qfloat16(i * (17.f / 3)); + + for (int i = 0; i < 35; ++i) + expected[i] = float(in[i]); + + qFloatFromFloat16(out, in, 35); + + for (int i = 0; i < 35; ++i) + QCOMPARE(out[i], expected[i]); +} + QTEST_APPLESS_MAIN(tst_qfloat16) #include "tst_qfloat16.moc" diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index 6a6f53dfe0..bf2943a63c 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -71,6 +71,12 @@ void tst_GlobalTypes() qreal qr; Q_UNUSED(qr); + + qssize_t qs; + qptrdiff qp; + qintptr qip; + quintptr qup; + Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(qup); } /* Qt version */ |