Platform independent math library

て烟熏妆下的殇ゞ 提交于 2019-12-04 15:26:36

Would something like: http://lipforge.ens-lyon.fr/www/crlibm/index.html be what you are searching for (this is a library whose aim is to be able to replace the standard math library of C99 -- so keep good enough performance in the normal cases -- while ensuring correctly rounded result according to IEEE 754 rounding modes) ?

crlibm is the correct tool for this. An earlier poster linked to it. Because it is correctly rounded, it will deliver bit-identical results on all platforms with IEEE-754 compliant hardware if compiled properly. It is much, much faster than MPFR.

You shouldn't need one. floor and ceil will be exact since their computation is straightforward.

What you are concerned with is rounding on the last bit for the transendentals like sin, cos, and exp. But these are native to the CPU microcode and can be done in high quality consistently regardless of library. However, the rounding does vary from chip architecture to architecture.

So, if exact answers for the transindentals is indeed your goal, you do need a portable library, and you also will be giving up huge efficiencies by doing so. You could use a portable library like MAPM which gives you not only consistent ULP results but as a side benefit lets you define arbirary precision.

You can check your math precision with tools like this one and this one.

You mention using SSE. If you're planning on only running on x86 chips, then what exactly are the inconsistencies you're expecting?

As for MPFR, don't worry - test it! By the way, if it's good enough to be included in GCC, it's probably good enough for you.

You want to use MPFR. That library has been around for years and has been ported to every platform under the sun and optimized by tons of people.

If MPFR isn't sufficient for your needs we're talking about full custom ASM implementations in which case it might be more efficient to consider implementing it in dedicated hardware.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!