Re^2: Module for 128-bit integer math?
by BrowserUk (Patriarch) on Feb 06, 2011 at 11:33 UTC
|
Thanks, but no. I'm trying to avoid the overhead of arbitrary precision.
My 64-bit processor has 128-bit math capabilities in hardware and I like to use them. I really thought I'd seen a module that did that, but maybe I'll have to write it myself. Or at least wrap one of the C libs that do it.
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] |
|
... 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] |
|
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] |
|
|
|
|
|
|
|
|
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] |
|
|