Latest source and some binaries can be found at:

  http://www.geocities.com/g_w_reynolds/gcwsieve/

I use these commands to make binaries for distribution:

  x86-64 Linux:  make ARCH=x86-64 CC="gcc -V3.4"
  x86 Linux:     make ARCH=x86 CC="gcc -V3.4"
  x86 Windows:   make ARCH=x86 CC="i586-mingw32msvc-gcc"

To report bugs, email me (Geoff): g_w_reynolds at yahoo.co.nz.


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; PFGW.

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.
 -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.
 -e --elapsed-time     Use elapsed instead of CPU time for status line reports.
 -l --L1-cache SIZE    Assume L1 data cache is SIZE Kb.
 -L --L2-cache SIZE    Assume L2 cache is SIZE Kb.
 -z --idle             Run at idle priority. (Default).
 -Z --no-idle          Don't adjust priority.
 -v --verbose          Print some extra messages. -vv prints more.
 -h --help             Print this help.

Some of the following additional options may also be available:
    --sse2             Use SSE2 vector optimisations. (Default if supported).
    --no-sse2          Don't use SSE2 vector optimisations.
    --intel            Process 4 terms in parallel. (Default for Intel CPUs).
    --amd              Process 6 terms in parallel. (Default for AMD CPUs).
    --prefetch         Force use of software prefetch.
    --no-prefetch      Prevent use of software prefetch.


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.


ABC FILE
========

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


Old format (MultiSieve compatible)
----------------------------------

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

B and C must be constant for all terms, and N1,N2,... must be in strictly
increasing order. 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


New format
----------

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

N1,N2,... must be in strictly increasing order. 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.

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
