Skip to content

Commit 8dce773

Browse files
committed
pc?ul: support -o<n> to test less before printing
Running with -o200, for example, gives up testing in tau_multi_run() at the point it would start QS for any number of more than 200 bits (about 60 decimal digits).
1 parent 195a523 commit 8dce773

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

coul.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ struct {
211211
} midp_recover;
212212
uint rough = 0; /* test roughness if tau >= rough */
213213
bool opt_print = 0; /* print candidates instead of fully testing them */
214+
uint opt_flake = 0; /* test less before printing candidates */
214215
/* If opt_alloc is true and opt_batch < 0, just show the forced-prime
215216
* allocation; if opt_alloc is true and opt_batch >= 0, just process
216217
* the specified batch_alloc.
@@ -1618,7 +1619,7 @@ void prep_presquare(void) {
16181619
}
16191620

16201621
void init_post(void) {
1621-
init_tau(rough);
1622+
init_tau(rough, opt_flake);
16221623
init_stats(k);
16231624
alloc_taum(k);
16241625
if (randseed != 1) {
@@ -4328,9 +4329,11 @@ int main(int argc, char **argv, char **envp) {
43284329
opt_alloc = 1;
43294330
else if (arg[1] == 'b')
43304331
set_batch(&arg[2]);
4331-
else if (arg[1] == 'o')
4332+
else if (arg[1] == 'o') {
43324333
opt_print = 1;
4333-
else if (arg[1] == 'c') {
4334+
if (arg[2])
4335+
opt_flake = strtoul(&arg[2], NULL, 10);
4336+
} else if (arg[1] == 'c') {
43344337
if (arg[2] == 'p')
43354338
check_prime = strtoul(&arg[3], NULL, 10);
43364339
else if (arg[2] == 'r')

coultau.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ static inline bool ct_trial(factor_state *fs) {
156156
/* MPUG declares this static, so we must copy it */
157157
static unsigned short primes_small[NPRIMES_SMALL];
158158

159-
void init_tmfbl(void);
159+
void init_tmfbl(uint flake);
160160
void done_tmfbl(void);
161-
void init_tau(uint rough) {
161+
void init_tau(uint rough, uint flake) {
162162
UV pn;
163163
test_rough = rough;
164164
PRIME_ITERATOR(iter);
@@ -170,7 +170,7 @@ void init_tau(uint rough) {
170170
mpz_init(tmf);
171171
mpz_init(tmf2);
172172
mpz_init(tmp_lim);
173-
init_tmfbl();
173+
init_tmfbl(flake);
174174
for (uint i = 0; i < SIMPQS_SIZE; ++i)
175175
mpz_init(simpqs_array[i]);
176176
}
@@ -896,16 +896,21 @@ ulong *tmfbl = NULL;
896896
uint tmfb_maxb;
897897
ulong tmfb_lim;
898898

899-
void init_tmfbl(void) {
899+
/* don't flake out for anything before QS */
900+
#define NO_FLAKE ((1 << 24) - 1)
901+
void init_tmfbl(uint flake) {
900902
tmfb_lim = tmfb[TMFB_MAX - 1].tmf_bits;
901903
tmfb_maxb = tmfb[TMFB_MAX - 2].maxlen;
904+
if (flake && tmfb_maxb > flake)
905+
tmfb_lim = tmfb_lim & NO_FLAKE;
906+
902907
tmfbl = (ulong *)malloc((tmfb_maxb + 1) * sizeof(ulong));
903908
uint i = 0;
904909
for (uint j = 0; j <= TMFB_MAX - 2; ++j) {
905910
uint lim = tmfb[j].maxlen;
906911
ulong bits = tmfb[j].tmf_bits;
907912
for (; i <= lim; ++i)
908-
tmfbl[i] = bits;
913+
tmfbl[i] = (flake && i > flake) ? (bits & NO_FLAKE) : bits;
909914
}
910915
}
911916

coultau.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ extern t_tm *taum;
5050

5151
typedef uint (*tau_failure_handler)(uint count, t_tm *taum);
5252

53-
extern void init_tau(uint test_rough);
53+
extern void init_tau(uint test_rough, uint flake);
5454
extern void done_tau(void);
5555
extern void fs_init(factor_state* fs);
5656
extern void fs_clear(factor_state* fs);

ftest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void fail(char *format, ...) {
3838
int main(int argc, char **argv) {
3939
_GMP_init();
4040
set_verbose_level(3);
41-
init_tau(0);
41+
init_tau(0, 0);
4242
alloc_taum(1);
4343
t0 = utime();
4444

sq12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void init(void) {
156156
mpz_init(Z(i));
157157
init_diag();
158158
init_time();
159-
init_tau(0);
159+
init_tau(0, 0);
160160
}
161161

162162
void ston(mpz_t targ, char *s) {

test_pell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mpz_t zlimit;
1414
mpz_t zx;
1515
mpz_t zy;
1616

17-
/* needed for coultau.c; but not used, since we init_tau(0) */
17+
/* needed for coultau.c; but not used, since we init_tau(0, 0) */
1818
#include "coul.h"
1919
t_divisors *divisors = NULL;
2020

@@ -62,7 +62,7 @@ int main(int argc, char **argv) {
6262
mpz_init(zx);
6363
mpz_init(zy);
6464
_GMP_init();
65-
init_tau(0);
65+
init_tau(0, 0);
6666
init_rootmod(1);
6767
init_pell();
6868
new_pell(zA, zD, in, zlimit);

0 commit comments

Comments
 (0)