-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
qsieve does not return for some numbers #2250
Comments
Do you have more examples of where it fails to return in a reasonable amount of time? I've not looked into it that much, but |
I did some tests from 25 digits to 65 digits in steps of 5 digits. It started occuring at 45 digits (when testing 1e5 numbers each). Is a C45 reasonable in your opinion? If so, I can surely find some more. Edit: I misunderstood. I will generate some more examples. |
FWIW, this example succeeds if I toggle the alternative Specifically, it works if one changes the
to various smaller values, eg I guess we could just do a big tuneup for qsieve where we test the new parameters very extensively for termination. Though it would be nice to understand why there is an issue with the larger sieve size too... |
Here is a list of composites that will get stuck in
When enabling
|
Can you generate these at various other bit sizes as well? |
Pinging @wbhart in case he has an idea how to fix this as robustly as possible. |
Fiddling with the tuning values is probably the only option here. Unfortunately at the small sizes, the sieve is a bit flakey. There's not a heap can be done about it. I tuned it as best I could, but it looks like I still didn't get it right. There's just not enough polynomials of the right size to factor the number comfortably, so there's always some tradeoff. |
I'm a bit surprised that making the sieve size smaller actually helps. That shows you just how marginal the behaviour is. |
A collection of composites in different sizes:
|
Hmm, I don't have an explanation for the failure at larger sizes. There should not be pressure on the number of available polynomials there. I have to wonder if something hasn't become corrupted at some point. I wish I had time to dig into it myself, but I absolutely don't. |
We should test these with some ancient versions of Flint to see if there has been a regression. |
Perhaps turn on some of the debugging code and see if you can narrow down why it is running out of polynomials, if that is what is going on. If you start with the larger numbers, that should be a clearer case, as there really ought to be enough. From memory, from 40 digits on, you shouldn't run into much of a problem. This whole implementation was meant to solve this problem, and in my testing it worked pretty well. But apparently I didn't test well enough. I mean, the quadratic sieve can fail, but it shouldn't do so much, if at all, in practice. |
Something I saw in |
It is possible that there gets something corrupted. When executing the example in OP with 1000000000000000000000000000000000000000420217, within I minute I got: munmap_chunk(): invalid pointer
Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
44 ./nptl/pthread_kill.c: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0 __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1 0x00007ffff70a9f1f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2 0x00007ffff705afb2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3 0x00007ffff7045472 in __GI_abort () at ./stdlib/abort.c:79
#4 0x00007ffff709e430 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff71b8459 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#5 0x00007ffff70b383a in malloc_printerr (str=str@entry=0x7ffff71babb8 "munmap_chunk(): invalid pointer") at ./malloc/malloc.c:5660
#6 0x00007ffff70b39fc in munmap_chunk (p=<optimized out>) at ./malloc/malloc.c:3054
#7 0x00007ffff70b7f68 in __GI___libc_free (mem=<optimized out>) at ./malloc/malloc.c:3375
#8 0x00007ffff7917bc8 in qsieve_poly_clear () from /usr/local/lib/libflint.so.20
#9 0x00007ffff7915104 in qsieve_factor () from /usr/local/lib/libflint.so.20
#10 0x0000555555555203 in main (argc=<optimized out>, argv=<optimized out>) at example.c:14 |
Running the above 1000000000000000000000000000000000000000420217 example with diff --git a/src/qsieve.h b/src/qsieve.h
index 68ab9cd52..680cc32be 100644
--- a/src/qsieve.h
+++ b/src/qsieve.h
@@ -27,7 +27,7 @@ extern "C" {
/* Windows systems may define `small` macro, which leads to conflicts */
#undef small
-#define QS_DEBUG 0 /* level of debug information printed, 0 = none */
+#define QS_DEBUG 64 + 128 /* level of debug information printed, 0 = none */
#define BITS_ADJUST 25 /* add to sieve entries to compensate approximations */ on top of b36927c (current
|
Regarding 1000000000000000000000000000000000000000420217, I found out that
|
qsieve_factor will not return for some numbers, e.g. 500000000000000000000000000000000000000017711.
Minimal example:
The example was compiled with
gcc -o example -Og -g example.c -Wall -pedantic -lflint
.I would expect qsieve to return at some point.
System:
configure
:--use-avx2
, on the 11th-gen Intel also--use-avx512
The text was updated successfully, but these errors were encountered: