Skip to content

ibethune/gcwsieve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Original source and some binaries can be found at:

  https://sites.google.com/site/geoffreywalterreynolds/programs/gcwsieve

Current version of the code is located at:

  https://github.com/ibethune/gcwsieve

and is maintained by Iain Bethune.  Bugs/comments/improvements should be notified through GitHub.

GCWSIEVE
========

This is a sieve for Generalised Cullen and Woodall numbers n*b^n+/-1, where
b is fixed. The algorithm was taken from a mersenneforum.org post by Harsh
Aggarwal. Modular arithmetic and Sieve of Eratosthenes code was taken from
srsieve, much of which was contributed by Mark Rodenkirch.

Given terms n*b^n+/-1, and factors P0 < p < P1, the following limits apply:
 0 < n < 2^32
 1 < b < 2^32
 b,n < P0 < P1 < 2^52 (2^51 for x86-64, 2^62 for x86, 2^63 for ppc64)
 The maximum number of terms in the sieve is 2^31-1 (2^28-1 for x86).

Note: This is not a stand-alone sieve. It requires an existing input file
in ABC format, and it can only find factors p > b,n for terms n*b^n+/-1.
Therefore you need to begin the sieve and remove all smaller factors with
another program, e.g. MultiSieve. (Or use the gcwsieve-smallp executables).

Also note: gcwsieve is optimised for the situation where the gaps between
successive n in terms n*b^n+/-1 are quite large or irregular, for example
when only prime n are being tested or when many terms have already been
sieved out. For the normal case where all n in a range are being tested
MultiSieve is probably faster, especially on non-SSE2 machines.


USAGE
=====

Usage: gcwsieve [OPTION ...]
 -p --pmin P0
 -P --pmax P1          Sieve for factors p in the range P0 <= p <= P1
 -i --input FILE       Read sieve from ABC format FILE (default `sieve.txt').
 -o --output FILE      Write sieve to ABC format FILE.
 -n --nmin N0
 -N --nmax N1          Restrict sieve to terms n*b^n+/-1 where N0 <= n <= N1.
 -b --base B           Restrict sieve to base B terms.
 -C --cullen           Restrict sieve to Cullen terms n*b^n+1.
 -W --woodall          Restrict sieve to Woodall terms n*b^n-1.
 -f --factors FILE     Append new factors to FILE (default `factors.txt').
 -w --work FILE        Read sieve ranges from FILE (default `work.txt').
 -c --checkpoint FILE  Write checkpoints to FILE (default `checkpoint.txt').
 -u --uid STR          Append -STR to base of default per-process file names.
 -s --save TIME        Save output/checkpoint every TIME minutes (default 60).
 -k --known FILE       Remove known factors in FILE before starting sieve.
 -d --dummy X          Add dummy terms to fill gaps > X between exponents.
 -m --multisieve       Write factors and ABC files in MultiSieve format.
 -R --report-primes    Report primes/sec instead of p/sec.
 -l --L1-cache SIZE    Assume L1 data cache is SIZE Kb.
 -L --L2-cache SIZE    Assume L2 cache is SIZE Kb.
 -z --lower-priority   Run at low priority. (-zz lower).
 -Z --raise-priority   Run at high priority. (-ZZ higher).
 -A --affinity N       Set affinity to CPU N.
 -q --quiet            Don't print found factors.
 -v --verbose          Print some extra messages. -vv prints more.
 -h --help             Print this help.

Some of the following options may also be available:
    --sse2             Use SSE2 vector optimisations. (Default if supported).
    --no-sse2          Don't use SSE2 vector optimisations.
    --prefetch         Force use of software prefetch.
    --no-prefetch      Prevent use of software prefetch.
 -t --threads NUM      Start NUM child threads. (Default 0).

These options are only available for the x86-64 executable:
    --intel            Process 4 terms in parallel. (Default for Intel CPUs).
    --amd              Process 6 terms in parallel. (Default for AMD CPUs).


Arguments to -p, -P, -n, -N can be given in 'e' notation, e.g. `-p 1e9'
instead of `-p 1000000000'.

If the sieve range is not specified by -p and -P then ranges will be read
from the file `work.txt' in the current directory. This file should contain
one pair A,B per line, sieving will be in the range A*10^9 <= p <= B*10^9.
When the current range finishes, the first line will be deleted and the next
range read from the file, until no more lines are left.

Periodic checkpoints will be written to the file `checkpoint.txt', and if
this file contains a valid checkpoint when gcwsieve starts it will use it to
resume sieving from where it was stopped.

If no command line arguments are given but `gcwsieve-command-line.txt'
exists in the current directory, then the command line will be as if the
first line of this file had been used to invoke gcwsieve. The full command
line must be given, not just the switches, e.g. `gcwsieve -v ...' rather
than just `-v ...'. This may be useful on some GUI machines where the
command shell and batch files have been disabled for security reasons.

If the switch `-u STR' is used then the default file names
`work.txt', `factors.txt', `checkpoint.txt', `gcwsieve.log' are changed to
`work-STR.txt', `factors-STR.txt', `checkpoint-STR.txt', `gcwsieve-STR.log'.
This allows multiple gcwsieve processes to be run from the same directory by
starting each process with a unique string STR. The file names specified by
the -w, -c and -f switches override the names assigned by the -u switch.

MultiSieve can create an ABC file containing terms with many different
bases. To continue sieving such a file with gcwsieve, use the -b switch to
sieve one base at a time. For example `gcwsieve -b 5 ...' will discard all
terms except those of the form b*5^n+/-1 as the input file is read.

The default output file written when the -o switch is used can be read by
PFGW and Phrot. To create an output file readable by LLR, add the -m switch.


ABC FILE
========

The input file for terms N1*B^N1+C1, N2*B^N2+C2, ... must be in one of the
following formats:


1. (MultiSieve/LLR compatible)
------------------------------

ABC $a*$b^$a$c // [...] <P0>
<N1> <B> <C1>
<N2> <B> <C2>
[...]

B must be constant for all terms. The // and everything following it are
optional. P0 will be used as the start of the sieve if the -p command line
switch is not supplied. This format will be used for the output file if the
--multisieve switch is given.

For example, a file for the terms 1500113*2^1500113+1, 1500353*2^1500353-1:

ABC $a*$b^$a$c // CW Sieved to: 40002769787
1500113 2 +1
1500353 2 -1


2. (Variable C)
---------------

ABC $a*<B>^$a$b // [...] <P0>
<N1> <C1>
<N2> <C2>
[...]

The // and everything following it are optional. P0 will be used as the
start of the sieve if the -p command line switch is not supplied. This
format will be used for the output file if the --multisieve switch is not
given and some terms have different C values.

For example, a file for the terms 1500113*2^1500113+1, 1500353*2^1500353-1:

ABC $a*2^$a$b // Sieved to: 40002769787
1500113 +1
1500353 -1


3. (Fixed C)
------------

ABC $a*<B>^$a<+/-C> // [...] <P0>
<N1>
<N2>
[...]

The // and everything following it are optional. P0 will be used as the
start of the sieve if the -p command line switch is not supplied. This
format will be used for the output file if the --multisieve switch is not
given and all terms have the same C value.

For example, a file for the terms 1500113*2^1500113+1, 1500353*2^1500353+1:

ABC $a*2^$a+1 // Sieved to: 40002769787
1500113
1500353

About

Sieving code for Generalised Cullen/Woodall Primes (original code from Geoffrey Reynolds)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published