一个WIP任意精度算术库(GMP的替代品)
我正在积极开发一个任意精度算术库,使用C语言,旨在提供一个几乎与GNU的LibGMP一样快速的替代品,但采用MIT许可证。作为一名全日制大学生,独立完成这个项目有些繁琐,但进展缓慢而稳定。
<p>GitHub链接:https://github.com/EpsilonNought117/libapac</p>
我从GMP的公共API中获得了API和命名方案的灵感,但内部实现(据我所知)完全是我自己的。该库目前在Unix-like和Windows操作系统上使用运行时调度来支持x86-64 CPU的特定微架构版本的汇编函数,未来也计划支持ARM64。所有汇编例程都是我手动编写的(从写作风格上来看可能很明显),使用了MASM和GAS汇编器,并且有一些基于SIMD的例程是使用编译器内置函数编写的。
<p>截至目前,性能似乎与GMP在小到中型大整数上的表现相当(性能图见README)。我实现了一些算法,例如Karatsuba算法和分治法(平衡和不平衡)除法,未来还会根据需要实现更多算法。Brent和Zimmerman的《现代计算机算术》和Henry Warren Jr的《黑客的乐趣》这两本书对我帮助很大。</p>
<p>仍在大量开发中。</p>
我对任何反馈和批评都很感兴趣,欢迎提出任何问题。
查看原文
I am actively developing an arbitrary-precision arithmetic library in C with the aim to offer a nearly-as-fast alternative to GNU's LibGMP, but under the MIT License. The solo effort has been a bit tedious as a full-time college student, but there's slow and steady progress.<p>GitHub Link: https://github.com/EpsilonNought117/libapac<p>I have inspired my API and naming scheme from GMP's public API, but the internals are (to the best of my knowledge) completely my own. The library uses a runtime dispatch to micro-arch specific versions of assembly functions on x86-64 CPUs currently for Unix-like and Windows OS, with future support planned on ARM64 on both as well. I have handwritten all the assembly routines (probably obvious by the writing style) using MASM and GAS assemblers, with a few SIMD based routines written with compiler intrinsic functions.<p>The performance (so far) seems to be on par with GMP for small to medium-sized Big Integers (performance graphs in README). I have implemented a few algorithms such as the Karatsuba Algorithm and Divide-&-Conquer division (Balanced and Unbalanced) with more algorithms on the way as needed. The books "Modern Computer Arithmetic" by Brent and Zimmerman and "Hacker's Delight" by Henry Warren Jr have really helped a lot.<p>Still largely WIP.<p>Interested in any feedback and/or criticisms. Happy to answer any questions.