-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #15654: PARI discriminant speed depends on stack size
This is weird and bad: {{{ sage: x = polygen(ZpFM(3,10)) sage: p = ((x-1)^50 + x)._pari_init_() sage: %time pari(p).poldisc() CPU times: user 52.73 s, sys: 0.00 s, total: 52.73 s Wall time: 52.82 s 2*3 + 3^4 + 2*3^6 + 3^7 + 2*3^8 + 2*3^9 + O(3^10) sage: pari.allocatemem(2<<20) PARI stack size set to 2097152 bytes sage: %time pari(p).poldisc() CPU times: user 0.08 s, sys: 0.00 s, total: 0.08 s Wall time: 0.08 s 2*3 + 3^4 + 2*3^6 + 3^7 + 2*3^8 + 2*3^9 + O(3^10) }}} '''Upstream''': [http://pari.math.u-bordeaux.fr/cgi- bin/bugreport.cgi?bug=1507] URL: http://trac.sagemath.org/15654 Reported by: jdemeyer Ticket author(s): Jeroen Demeyer Reviewer(s): David Roe
- Loading branch information
Showing
5 changed files
with
77 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.5.5.p1 | ||
2.5.5.p2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Binary files src/Olinux-x86_64/alglin1.o and b/Olinux-x86_64/alglin1.o differ | ||
Only in src/Olinux-x86_64: libpari-gmp.so.2.5.5 | ||
diff -ru src/src/basemath/alglin1.c b/src/basemath/alglin1.c | ||
--- src/src/basemath/alglin1.c 2014-01-09 15:43:35.847263581 +0100 | ||
+++ b/src/basemath/alglin1.c 2014-01-09 15:55:47.903649326 +0100 | ||
@@ -2412,6 +2412,7 @@ | ||
a = RgM_shallowcopy(a); | ||
for (i=1; i<nbco; i++) | ||
{ | ||
+ int garbage = 0; /* Only gerepile() once per loop iteration */ | ||
for(k=i; k<=nbco; k++) | ||
{ | ||
gcoeff(a,k,i) = modii(gcoeff(a,k,i), p); | ||
@@ -2435,7 +2436,7 @@ | ||
for (j=i+1; j<=nbco; j++) | ||
{ | ||
gcoeff(a,j,k) = Fp_sub(gcoeff(a,j,k), Fp_mul(m,gcoeff(a,j,i),p),p); | ||
- if (low_stack(lim, stack_lim(av,1))) | ||
+ if (low_stack(lim, stack_lim(av,1)) && (garbage++ == 0)) | ||
{ | ||
if(DEBUGMEM>1) pari_warn(warnmem,"det. col = %ld",i); | ||
gerepileall(av,2, &a,&x); | ||
@@ -2994,6 +2995,7 @@ | ||
a = RgM_shallowcopy(a); | ||
for (i=1; i<nbco; i++) | ||
{ | ||
+ int garbage = 0; /* Only gerepile() once per loop iteration */ | ||
k = pivot(a, data, i, NULL); | ||
if (k > nbco) return gerepilecopy(av, gcoeff(a,i,i)); | ||
if (k != i) | ||
@@ -3013,7 +3015,7 @@ | ||
for (j=i+1; j<=nbco; j++) | ||
{ | ||
gcoeff(a,j,k) = gsub(gcoeff(a,j,k), gmul(m,gcoeff(a,j,i))); | ||
- if (low_stack(lim, stack_lim(av,1))) | ||
+ if (low_stack(lim, stack_lim(av,1)) && (garbage++ == 0)) | ||
{ | ||
if(DEBUGMEM>1) pari_warn(warnmem,"det. col = %ld",i); | ||
gerepileall(av,2, &a,&x); | ||
@@ -3063,6 +3065,7 @@ | ||
{ | ||
GEN ci, ck, m; | ||
int diveuc = (gequal1(pprec)==0); | ||
+ int garbage = 0; /* Only gerepile() once per loop iteration */ | ||
|
||
p = gcoeff(a,i,i); | ||
if (gequal0(p)) | ||
@@ -3099,7 +3102,7 @@ | ||
GEN p1 = gsub(gmul(p,gel(ck,j)), gmul(m,gel(ci,j))); | ||
if (diveuc) p1 = mydiv(p1,pprec); | ||
gel(ck,j) = gerepileupto(av2, p1); | ||
- if (low_stack(lim,stack_lim(av,2))) | ||
+ if (low_stack(lim,stack_lim(av,2)) && (garbage++ == 0)) | ||
{ | ||
if(DEBUGMEM>1) pari_warn(warnmem,"det. col = %ld",i); | ||
gerepileall(av,2, &a,&pprec); |
Oops, something went wrong.