summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qfloat16.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.14' into 5.15Ulf Hermann2019-12-031-0/+1
|\ | | | | | | | | | | | | Conflicts: src/corelib/serialization/qcborvalue.cpp Change-Id: I675a3029955c96e81a33ed9d98b72b55b6784b52
| * Silence intel compiler warning about float comparisonOlivier Goffart2019-11-281-0/+1
| | | | | | | | | | | | | | | | Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add support for a signaling NaN in qfloat16Edward Welbourne2019-11-061-1/+9
| | | | | | | | | | | | | | | | There was a comment saying what value does the job, so might as well put it to work. Change-Id: I47f1a8ce7ce889580f71aa784ccbcc227ebe0b23 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add qfloat16::copySign() since we can't overload std::copysign()Edward Welbourne2019-11-061-0/+3
|/ | | | | Change-Id: Idfaf841b3eb3538f076ae4f0de2d7d029e1588fe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Correct handling of -qfloat16(0)Edward Welbourne2019-10-031-2/+2
| | | | | | | | It is finite and normal; it classifies as a zero; and it should not be > qfloat16(0). Added tests to match. Change-Id: I7874fb54f622b4cdf28b0894050ad3e75cf5d77c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-05-151-0/+4
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qfloat16.cpp src/corelib/global/qfloat16.h src/plugins/platforms/windows/qwindowswindow.cpp Change-Id: I0938aaa6a9771f55e48c95ed29f6f5291431b947
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-121-0/+4
| |\ | | | | | | | | | Change-Id: I0c00ffe0eabebc919f22d6faa4bf958b288e8fd9
| | * Work around VS2015/17 bitset + qfloat16.h compiler bugKeith Kyzivat2019-05-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][Global] Added the QT_NO_FLOAT16_OPERATORS macro in order to work around a Microsoft <= VS2017 compiler bug that is exposed when using std::bitset along with any Qt header that includes <qfloat16.h>. This is fixed in MSVC 2019[1], but the workaround is needed for earlier versions. In this case, cl.exe fails with C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\bitset(270): error C2666: 'operator /': 10 overloads have similar conversions C:\Qt\5.12.0\msvc2017_64\include\QtCore/qsize.h(364): note: could be 'const QSizeF operator /(const QSizeF &,qreal)' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qsize.h(194): note: or 'const QSize operator /(const QSize &,qreal)' c:\qt\5.12.0\msvc2017_64\include\qtcore\qmargins.h(427): note: or 'QMarginsF operator /(const QMarginsF &,qreal)' c:\qt\5.12.0\msvc2017_64\include\qtcore\qmargins.h(213): note: or 'QMargins operator /(const QMargins &,qreal)' c:\qt\5.12.0\msvc2017_64\include\qtcore\qmargins.h(207): note: or 'QMargins operator /(const QMargins &,int)' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(205): note: or 'double operator /(int,qfloat16) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(205): note: or 'double operator /(qfloat16,int) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(195): note: or 'float operator /(float,qfloat16) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(195): note: or 'float operator /(qfloat16,float) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(194): note: or 'double operator /(double,qfloat16) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(194): note: or 'double operator /(qfloat16,double) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(193): note: or 'long double operator /(long double,qfloat16) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(193): note: or 'long double operator /(qfloat16,long double) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qfloat16.h(176): note: or 'qfloat16 operator /(qfloat16,qfloat16) noexcept' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qpoint.h(402): note: or 'const QPointF operator /(const QPointF &,qreal)' C:\Qt\5.12.0\msvc2017_64\include\QtCore/qpoint.h(206): note: or 'const QPoint operator /(const QPoint &,qreal)' C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\bitset(270): note: or 'built-in C++ operator/(::size_t, )' C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\bitset(270): note: while trying to match the argument list '(::size_t, )' C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\bitset(266): note: while compiling class template member function 'std::bitset<8> &std::bitset<8>::set(::size_t,bool)' C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.10.25017\include\bitset(39): note: see reference to function template instantiation 'std::bitset<8> &std::bitset<8>::set(::size_t,bool)' being compiled ..\Qt5.12.0-C2666\main.cpp(7): note: see reference to class template instantiation 'std::bitset<8>' being compiled Invoke this workaround by defining the macro QT_NO_FLOAT16_OPERATORS in user code prior to the inclusion of Qt includes in a translation unit. Arithmetic operators from qfloat16 will then not be present in that compilation unit. [1] https://developercommunity.visualstudio.com/content/problem/406329/compiler-error-c2666-when-using-stdbitset-and-cust.html Task-number: QTBUG-72073 Change-Id: I58f8400bf933ad781d4213731695e20e0c482166 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Implement qFpClassify(qfloat16)Edward Welbourne2019-04-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This extends support for qfloat16 sufficiently for the things testlib needs in order to treat it as a first-class citizen. Extended tests for qfloat to check qFpClassify() on it. Change-Id: I906292afaf51cd9c94ba384ff5aaa855edd56da1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Implement std::numeric_limits<qfloat16>Edward Welbourne2019-04-241-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This shall make it more nearly a first-class numeric type; in particular, I need some of these for testlib's comparing and formatting of float16 to handle NaNs and infinities sensibly. Change-Id: Ic894dd0eb3e05653cd7645ab496463e7a884dff8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Replace Q_DECL_NOEXCEPT with noexcept in corelibAllan Sandfeld Jensen2019-04-031-41/+41
| | | | | | | | | | | | | | | | | | | | | In preparation of Qt6 move away from pre-C++11 macros. Change-Id: I44126693c20c18eca5620caab4f7e746218e0ce3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Simplify finite/NaN testing for qfloat16Edward Welbourne2019-03-261-4/+10
|/ / | | | | | | | | | | | | | | | | Doing endian-dependent selection of bytes of the value was a clumsy surrogate for just accessing the intenal quint16 shifted suitably. Change-Id: Icfd9d1d18f69eb94b041b8d32275df606c14c2b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-01-041-0/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also blacklist tst_QRawFont::unsupportedWritingSystem() and tst_QGlyphRun::mixedScripts() on windows for now. Conflicts: qmake/generators/makefile.cpp src/corelib/itemmodels/qstringlistmodel.cpp src/platformsupport/fontdatabases/windows/qwindowsfontengine_p.h tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp tests/auto/gui/text/qglyphrun/BLACKLIST tests/auto/gui/text/qrawfont/BLACKLIST Task-number: QTBUG-72836 Change-Id: I10fea1493f0ae1a5708e1e48d0a4d7d6b76258b9
| * Fix qfloat16 methods definition without declaration when using Q_QDOCAntonio Larrosa2018-12-211-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes qtdoc failing to build on i586 because of an assertion in libclang since Q_QDOC is defined and thus the declaration of the qfloat16(float) constructor and operator float() are removed, thus their definitions should be removed too, which is what this patch does. Fixes: QTBUG-72725 Done-with: Michal Srb <msrb@suse.com> Change-Id: I6424873425d46345e09f411f9ce88f2520825da4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
* | doc: Fix all clang parse errors in QtBase during PCH buildMartin Smith2018-11-051-2/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This update eliminates ALL parsing errors when clang parses the Qt headers to build the precompiled header qdoc needs. These errors are often cases where an old use of Q_QDOC no longer works because clang sees the enclosed fake declarations as erroneous. In a few cases, clang reported errors because two dummy function declartations under the Q_CLANG_QDOC guard were indistinguishable, so one of them was removed, and the documentation was patched accordingly. Using the macro Q_DECLARE_INTERFACE(...) causes clang to report errors because the class parametewr is abstract. These uses of the macro are not needed, so they are removed with #ifndef Q_CLANG_QDOC. Some declarations of default GL types that had been provided for qdoc were no longer needed, so they are removed. Now there are some member function signatures in QDBusPendingReply and QDBusPendingCall that have very long template clauses and qualifiers in their signatures. These unwieldy signatures will be unnecessary in the documentation and will look bad there, but for now they are correct. The ultimate solution will be to add a metacommand to qdoc, something like \simplify-signature to tell qdoc to generate the documentation for these member functions without the long template caluses and qualifiers. Change-Id: I012cf17a544fbba2ebc71002f31bdc865119bb8e Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Martin Smith <martin.smith@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLars Knoll2018-01-021-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
* | Merge remote-tracking branch 'origin/5.10' into devLiang Qi2017-11-301-3/+12
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/thread/qsemaphore.cpp tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Id35b535e88df63fdfe4007ea92ed4a39c4b6d707
| * Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-11-231-3/+12
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstandardpaths_win.cpp src/plugins/platforms/ios/qioswindow.mm src/plugins/platforms/ios/quiview.mm tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: I5deb0a0176a454a9c566e924d074ba60ce04f0bc
| | * Fix the build when AVX2 is enabled but __F16C__ isn't definedThiago Macieira2017-11-221-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If -mavx2 is used, __AVX2__ is defined, which enables the F16C code after commit 280e321e52fd4e86545f3f0d4bd4e047786a897e, but that was wrong since we aren't allowed to use the F16C intrinsics with either Clang or GCC (we can only do that with GCC 4.9 and Clang 4.8, and only with an __attribute__ decoration). With ICC and MSVC, we are allowed to use the intrinsics, but the #include was missing. [ChangeLog][QtCore] Fixed a compilation issue with qfloat16 if AVX2 support is enabled in the compiler. Since all processors that support AVX2 also support F16C, for GCC and Clang it is recommended to either add -mf16c to your build or to use the corresponding -march= switch. Task-number: QTBUG-64529 Change-Id: I84e363d735b443cb9beefffd14b8ac1fd4baa978 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | | Merge "Merge remote-tracking branch 'origin/5.10' into dev" into ↵Thiago Macieira2017-11-301-1/+1
|\| | | | | | | | | | | refs/staging/dev
| * | qfloat16(float) constructor: explicit cast on aarch64 to avoid warningShawn Rutledge2017-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning was global/qfloat16.h: In constructor ‘qfloat16::qfloat16(float)’: global/qfloat16.h:124:18: error: conversion to ‘__fp16’ from ‘float’ may alter its value [-Werror=float-conversion] __fp16 f16 = f; ^ cc1plus: all warnings being treated as errors The warning was added by fb5976038162d93d60c7f76376bbb4df38e83ba9. Change-Id: I489348c4d5d672bfa5d4db99c837696a2a69a27e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Add functions for fast bulk conversion of qfloat16Allan Sandfeld Jensen2017-11-211-0/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* / Fix GCC -Wfloat-conversion warnings (available since GCC 4.9)Thiago Macieira2017-10-291-1/+2
|/ | | | | | | | | | | This warning used to be part of -Wconversion, but that generates too more noise than we're willing to fix now (like conversion from qint64 to int). The float conversion does trigger for conversion from double to float, as shown in all the QVectorND uses of float, but more importantly, it triggers on passing floats to ints. Change-Id: I69f37f9304f24709a823fffd14e69cfd33f75988 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Android: Fix warning for __fp16BogDan Vatra2017-08-171-1/+1
| | | | | Change-Id: I65cd64dfc0ed357555e8b5276109303377a67e0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Eliminate ambiguous casts involving qfloat16Glen Mabey2017-05-071-12/+0
| | | | | | | | | | | | The operator double() and operator long double() members of qfloat16 are causing cast ambiguities. This removes them, leaving only operator float() which seems to be adequate. Also, additional arithmetic operator tests were added which without this removal fail to compile. Change-Id: Id52a101b318fd754969b3de13c1e528d0aac2387 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move Q_REQUIRED_RESULT to its correct positionThiago Macieira2017-04-201-8/+8
| | | | | | | | | | | That's before the return type or static, inline, constexpr or such keywords (if any). Perl Script: s/^(\s+)(.*) Q_REQUIRED_RESULT(;)?(\s*\/\/.*)?$/\1Q_REQUIRED_RESULT \2\3\4/ Change-Id: I7814054a102a407d876ffffd14b6a16182f159e2 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* qfloat16: Fix GCC warning about use of old-style castThiago Macieira2017-04-151-0/+1
| | | | | | | | | _mm_cvtps_ph is usually defined as a macro: qfloat16.h:122:37: error: use of old-style cast [-Werror=old-style-cast] Change-Id: Icd0e0d4b27cb4e5eb892fffd14b516ec47826c0c Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Fix detection of F16C for the Intel compiler (again) and Visual StudioThiago Macieira2017-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Neither the Intel compiler nor Visual C++ have a dedicated switch to enable F16C support, like GCC and Clang do. So we used the AVX switch for that in commit 8241d51f7049d48912ce25fbd49ef4d22c58e340, as it was the closest, lowest denominator. That was incorrect and insufficient. The Intel compiler silently miscompiles the intrinsics with -xAVX, making calls to out-of-line functions like _mm_cvtps_ph, which don't exist. So we actually have to use AVX2 support to generate correct code. That might be a problem later, since Ivy Bridge supports F16C but not AVX2. Visual C++ is able to generate F16C code with just -arch:AVX. Either way, since there's no dedicated command-line switch, there's also no dedicated preprocessor macro. We're using __AVX2__ for both compilers, as that's a sufficient condition to indicate a processor that supports F16C. Change-Id: I27b55fdf514247549455fffd14b205b8d8b86da7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* f16c: Use the packed intrinsics instead of scalar onesThiago Macieira2017-04-061-2/+6
| | | | | | | | | MSVC, Apple's Clang and Clang prior to 3.9 do not recognize _cvtss_sh and _cvtsh_ss. So expand the operation to use directly the packed intrinsics. Change-Id: I27b55fdf514247549455fffd14b2046fd638593d Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qfloat16: suppress warning caused by Clang macro we usedThiago Macieira2017-04-021-0/+3
| | | | | | | | | | | | | Clang implements the _cvtss_sh intrinsic by way of a macro, which uses a C99 extension and that's not allowed in C++ mode: float16.h:119:11: error: compound literals are a C99-specific feature [-Werror,-Wc99-extensions] /usr/bin/../lib64/clang/3.9.1/include/f16cintrin.h:76:55: note: expanded from macro '_cvtss_sh' Reported at https://bugs.llvm.org/show_bug.cgi?id=32491. Change-Id: I27b55fdf514247549455fffd14b170df75dd4e1f Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Suppress -Wfloat-equal when defining float16 equality operatorsUlf Hermann2017-03-131-0/+6
| | | | | Change-Id: Ie30fa13eb5f8eb44f0c9c21e9483c8aba40cec02 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Use native support for fp16 where availableAllan Sandfeld Jensen2017-02-161-0/+19
| | | | | | | | | | Use F16C or ARM FP16 if available at compile time. Configure check added because older clang compilers have F16C defines and flags but not all the intrinsics. Change-Id: I71f358b8fd003e70ab8fcf35097414591e485112 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't include qfloat.h in the QtCore master includeThiago Macieira2017-02-091-0/+1
| | | | | | | | | | | We have observed that MSVC 2013 gets lost with the overloads that this header adds, causing compilation bugs. This is believed to be a compiler bug, but it's not something we can work around. Task-number: QTBUG-58555 Change-Id: I536c32a88bff44dab37afffd14a1bad1d31dc16d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Glen Mabey <Glen.Mabey@swri.org>
* New qfloat16 classGlen Mabey2017-01-311-0/+225
This constitutes a fairly complete submission of an entirely new floating point type which conforms to IEEE 754 as a 16-bit storage class. Conversion between qfloat16 and float is currently performed through a sequence of lookup tables. Global-level functions qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and qIsNull() each with a qfloat16 parameter have been included for completeness. [ChangeLog][QtCore] Added new qfloat16 class. Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>