Qfplib-M3: a free, fast and accurate ARM Cortex-M3 floating-point library
Quinapalus Home :: Things Technical :: Qfplib-M3: a free, fast and accurate ARM Cortex-M3 floating-point library
IntroductionQfplib-M3 is a library of IEEE 754 single-precision floating-point arithmetic routines for microcontrollers based on the ARM Cortex-M3 core (ARMv7-M architecture). It will also run on Cortex-M4 microcontrollers but is not optimised for these devices. Unlike Qfplib-M0, the optimisation goals for Qfplib-M3 are speed and accuracy, while keeping code size within reasonable bounds. Qfplib-M3 provides correctly rounded (to nearest, even-on-tie) addition, subtraction, multiplication, division and square root operations, and sine, cosine, tangent, arctangent, logarithm and exponential functions that give a very high degree of accuracy. LicenceQfplib-M3 is open source, licensed under version 2 of the GNU GPL. Use at your own risk. Qfplib-M3 is not licensed under the LGPL. Roughly speaking, this means that if you wish to use it in conjunction with non-GPL code you will require an alternative licence: please enquire using the e-mail address on the home page. Code sizeThe complete set of functions in Qfplib-M3 occupies a little under 12 kbyte of program memory. In general code is not shared between the functions, so the footprint can be reduced significantly if not all functions are used: if using the GNU linker, supply the --gc-sections option. Qfplib-M3 does not depend on any other libraries. Stack and static memory usageQfplib-M3 uses no stack and no static storage. No initialisation is required. The code is fully ROMable and is thread-safe. Speed and accuracyThe following table compares cycle counts for Qfplib-M3 against other libraries. Qfplib-M3 timing results are approximate average values over the ranges of argument values shown and include a calling overhead of 3 cycles. They were measured using an LPC1763 microcontroller executing from (single-cycle) RAM. In the following table, ‘ulp’ means ‘unit in last place’. Errors are measured relative to the correctly-rounded result.
Note that unlike Qfplib-M3, none of the alternative libraries appears to offer IEEE 754 compliance with regard to rounding. Results for the Micro Digital ‘GoFast’, Keil and IAR libraries are inferred from the timings given here and here. Those pages have not been updated for a few years: I would welcome any more up-to-date benchmark figures. Note however, that (for example) the end-user licence for the Keil MDK includes the clause ‘you shall treat any and all benchmarking data relating to the Software [...] which are indicative of its performance, efficacy, reliability or quality, as confidential information and you shall not disclose such information to any third party without the express written permission of ARM’. It is not clear whether such a clause is enforceable, but it nevertheless could be viewed as an indication of ARM’s confidence in the ‘performance, efficacy, reliability or quality’ of their software. Accuracy analysis of scientific functions
Care has been taken to ensure Qfplib-M3 maintains results accurate to 1 ulp in pathological cases, such as sin x where x is near a multiple of π, and cos x and tan x where x is near an odd multiple of π/2. It even correctly evaluates sin(16367173·2^{73}). I would be interested to learn of any applications that require such accuracy other than the testing of floating-point libraries or the evaluation of π to many digits, noble pursuits though those both are. TestingEach unary function has been tested against the standard GNU floating-point library supplied with GCC for x86 processors exhaustively on non-exceptional arguments, plus on tens of millions of random exceptional cases. In exceptional cases the unary functions return bit-identical results to the GNU library; qfp_fsqrt returns bit-identical results in all cases. Each binary function has been tested against the GNU x86 library on over a billion cases, exceptional and non-exceptional, random and contrived. For qfp_fatan2 bit-identical results are returned in all exceptional cases; for all other binary functions, bit-identical results are returned in all cases. Implementation of the IEEE 754 standardQfplib correctly treats signed zeros, denormals, infinities and NaNs according to the IEEE 754 standard. The results of the addition, subtraction, multiplication, division and square root operations are correctly rounded (to nearest, even-on-tie). Other rounding modes and traps are not supported. Other functionsYou may also be interested in the qfp_fcmp, qfp_float2int, qfp_float2fix, qfp_int2float, qfp_fix2float, qfp_float2uint, qfp_float2ufix, qfp_uint2float, qfp_ufix2float, qfp_float2str and qfp_str2float functions provided as part of Qfplib-M0 library. DownloadThis page most recently updated Fri 26 Jul 08:32:49 BST 2019 |
Word Matcher
Nouveau:
Qat en français
New: Offline SOWPODS checker; Free, fast, and accurate ARM Cortex-M3 floating-point library
Qxw is a free (GPL) crossword construction program.
New! Release 20190722 for both Linux and Windows. Non-Roman alphabets, batch mode, multiplex lights,
answer treatments, circular and hex grids, jumbled entries, lots more besides.
More...
My book, ‘Practical Signal Processing’, is published by
Cambridge University Press.
You can order it directly from them, or via
amazon.co.uk or
amazon.com. Paperback
edition now also available.
Browse before you buy at
Google Books.
Wydanie polskie.
If you find this site useful or diverting, please consider a donation to
NASS (a UK registered
charity), to KickAS
(in the US), or to a similar body in your own
country.
Copyright ©2004–2019.
All trademarks used are hereby acknowledged. |