最快的128位整数库 [英] Fastest 128 bit integer library

查看:192
本文介绍了最快的128位整数库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个CPU沉重的数值计算应用程序。没有进入很多细节,那就是涉及到计算对大整数x某一函数f(x)的计算数学研究项目。

I am working on a CPU-heavy numerical computation app. Without going into many details, it's a computational math research project that involves computing a certain function f(x) for large integer x.

现在一切都用C ++实现在64位模式,采用原生的64位整数。限制我于x 2 ^ 64〜1.8 * 10 ^ 19。我想走得更远,要做到这一点,我需要的,做128位算术库。并且它必须是非常快的。具体地,整数除法应禁食。否则,我会坐在这里等待结果,直到感恩节。我宁愿不推倒重来。

Right now everything is implemented in C++ in x64 mode, using native 64-bit ints. That limits me to x<2^64~1.8*10^19. I want to go further, to do that, I need a library that does 128-bit arithmetic. And it has to be very fast. In particular, integer divisions should be fast. Otherwise I'll be sitting here waiting for the results till Thanksgiving. And I'd rather not reinvent the wheel.

我发现在维基百科〜20个大整数库列表,但其中大部分似乎对arbitrary- precision数字,这是矫枉过正我的任务进行有针对性的,而且我也不需要相关的额外费用那。

I found a list of ~20 big integer libraries on Wikipedia, but most of those seem to be targeted towards arbitrary-precision numbers, which is overkill for my task, and I don't need extra costs associated with that.

有谁知道什么库可以在128位的整数操作最快?

Does anyone know what library can operate on 128 bit integers fastest?

推荐答案

您没有提到你的平台/可移植性的需求。如果您愿意使用 GCC ,在64位平台上,他们有来为一个内建128位的类型免费, __ uint128_t __ int128_t 。也许其他平台也有类似的类型扩展。

You didn't mention your platform / portability requirements. If you are willing to use gcc or clang, on 64 bit platforms they have a builtin 128 bit types that come for free, __uint128_t and __int128_t. Maybe other platforms have similar type extensions.

在任何情况下,应该可以找到在 GCC对应的通用code的组装宽度的两个整数来源 N 合成宽度的整数 2N 。这可能会是一个很好的出发点,以实现这一目的的独立的库。

In any case it should be possible to find the corresponding generic code in the gcc sources that assembles two integers of width N to synthesize one integer of width 2N. This would probably be a good starting point to make a standalone library for that purpose.

这篇关于最快的128位整数库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆