arithmetic without limitations
Emmanuel Thomé
Emmanuel.Thome at normalesup.org
Thu Jan 14 17:02:10 CET 2010
Hi,
The GMP pages quotes ``arithmetic without limitations''.
Yet, there seems to be a limitation to 1 gigabyte integers.
(it's gmp-5.0.0, on a 64-bit machine).
tiramisu /tmp $ cat a.c
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
int main() {
mp_limb_t * a;
mp_limb_t * c;
a = malloc((1 << 27) * sizeof(mp_limb_t));
c = malloc((1 << 28) * sizeof(mp_limb_t));
printf("start mul\n");
mpn_sqr(c, a, 1 << 27);
free(a);
free(c);
return 0;
}
tiramisu /tmp $ gcc a.c -lgmp
tiramisu /tmp $ gdb ./a.out
GNU gdb (GDB) Fedora (7.0.1-19.fc12)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/a.out...(no debugging symbols found)...done.
(gdb) r
Starting program: /tmp/a.out
start mul
Program received signal SIGSEGV, Segmentation fault.
0x0000003562429bdb in __gmpn_fft_best_k () from /usr/lib64/libgmp.so.3
Missing separate debuginfos, use: debuginfo-install glibc-2.11.1-1.x86_64
The problem is that the 27 bits provided for in the struct nk fields are
not enough.
Cheers.
Emmanuel (and Paul and Pierrick).
More information about the gmp-bugs
mailing list