Re^3: Module for 128-bit integer math?
by syphilis (Archbishop) on Feb 06, 2011 at 12:07 UTC
|
... maybe I'll have to write it myself
I think so. I've not noticed anything geared to 128-bit hardware capabilities.
I'd encourage you to consider making it public - either as a module on CPAN, or just as a Cool Uses For Perl submission.
Cheers, Rob | [reply] |
Re^3: Module for 128-bit integer math?
by salva (Canon) on Feb 06, 2011 at 17:21 UTC
|
Or at least wrap one of the C libs that do it.
Have you found any 128bit math library in good shape? I have been googling for a while and all I have found is very rudimentary. Nothing complete or exploiting the 128bit abilities of modern processors.
gcc seems to have some basic support also, but the documentation about that feature is very poor and does not even state the processors where it is supported.
Well, the thing is that if you are able to find some good 128bits library, building a Math::Int128 module using Math::Int64 as a base should be pretty straight forward. Just point me to the library and I will do it!
BTW, I would also like to see a 256bits module... even if at that size, the performance would be pretty similar to that of a bigint library operating over integers of the same size.
| [reply] |
|
|
Have you found any 128bit math library in good shape?
No not yet. I assumed that they would exist, but so far all I've found is 128-bit FP and arbitrary precision integer:(
building a Math::Int128 module using Math::Int64 as a base
That was my thought also.
Just point me to the library and I will do it!
That's an offer I cannot pass up. Thank you.
From what I've seen so far, I'll end up having to write the C library myself.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
|
|
I have just uploaded Math::Int128 to CPAN (GitHub repository).
It has to be compiled with the development version of GCC for its 128bit integer support.
At this point, the module is completely experimental, has been only slightly tested (it has no tests, yet) and may contain lots of bugs, so, don't think about using it for anything serious!
| [reply] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re^3: Module for 128-bit integer math?
by Corion (Patriarch) on Feb 06, 2011 at 11:40 UTC
|
You could try to go down the interesting route of compiling a Perl with an IV size of 128 bit, but that'll likely make the XS libraries crash and burn as they likely suppose that sizeof(void *) == sizeof(int) == sizeof(IV). But it might be worth a try to just see whether Perl compiles and tests OK with an enlarged IV.
| [reply] [d/l] |
|
|
I don't think that would work because there are no 128-bit native C data types in the compiler.
The support is via the XMM registers, and they require special treatment.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
|
|
Hey, if there's a developer version of GCC that does handle 128-bit integers like salva mentions down below in 887024 then could this work? Or likely to be too experimental or still too many other problems?
Elda Taluta; Sarks Sark; Ark Arks
| [reply] |
|
|