|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| ci/ | H | 16-Sep-2021 | - | 1,487 | 963 |
| config/ | H | 16-Sep-2021 | - | 3,400 | 2,860 |
| dev_docs/ | H | 03-May-2022 | - | 6,012 | 5,778 |
| filter/ | H | 03-May-2022 | - | 15,633 | 11,754 |
| gf2x/ | H | 07-May-2022 | - | 97,155 | 74,890 |
| linalg/ | H | 03-May-2022 | - | 243,758 | 184,935 |
| misc/ | H | 03-May-2022 | - | 8,481 | 6,802 |
| parameters/ | H | 16-Sep-2021 | - | 7,622 | 5,872 |
| polyselect/ | H | 03-May-2022 | - | 27,523 | 20,579 |
| scripts/ | H | 03-May-2022 | - | 20,906 | 16,673 |
| sieve/ | H | 03-May-2022 | - | 56,894 | 39,822 |
| sqrt/ | H | 03-May-2022 | - | 7,172 | 5,383 |
| tests/ | H | 03-May-2022 | - | 53,240 | 42,781 |
| utils/ | H | 03-May-2022 | - | 71,747 | 53,031 |
| .gitlab-ci.yml | H A D | 16-Sep-2021 | 9.3 KiB | 341 | 309 |
| .gitmodules | H A D | 16-Sep-2021 | 92 | 4 | 3 |
| .mailmap | H A D | 16-Sep-2021 | 2.5 KiB | 30 | 29 |
| AUTHORS | H A D | 16-Sep-2021 | 1.4 KiB | 53 | 46 |
| COPYING | H A D | 16-Sep-2021 | 25.8 KiB | 505 | 418 |
| Makefile | H A D | 16-Sep-2021 | 683 | 12 | 8 |
| NEWS | H A D | 16-Sep-2021 | 9 KiB | 169 | 154 |
| README | H A D | 16-Sep-2021 | 26.1 KiB | 614 | 483 |
| README.Python | H A D | 16-Sep-2021 | 3.1 KiB | 76 | 54 |
| README.dlp | H A D | 16-Sep-2021 | 5.7 KiB | 122 | 96 |
| README.md | H A D | 16-Sep-2021 | 26.1 KiB | 614 | 483 |
| README.msieve | H A D | 16-Sep-2021 | 4.4 KiB | 121 | 83 |
| README.nonlinear | H A D | 16-Sep-2021 | 1.1 KiB | 33 | 24 |
| Toolchain-MinGW64.cmake | H A D | 16-Sep-2021 | 754 | 20 | 16 |
| cado-nfs-client.py | H A D | 03-May-2022 | 89.5 KiB | 2,270 | 1,629 |
| cado-nfs.py | H A D | 03-May-2022 | 9.4 KiB | 244 | 163 |
| cado-nfs.supp | H A D | 16-Sep-2021 | 5.2 KiB | 235 | 224 |
| cado.h | H A D | 03-May-2022 | 6.3 KiB | 165 | 52 |
| cado_config_h.in | H A D | 16-Sep-2021 | 5.7 KiB | 194 | 148 |
| cado_mpi_config_h.in | H A D | 16-Sep-2021 | 565 | 18 | 12 |
| files.dist | H A D | 16-Sep-2021 | 46.5 KiB | 1,687 | 1,686 |
| files.nodist | H A D | 16-Sep-2021 | 4.3 KiB | 151 | 150 |
| files.unknown | H A D | 16-Sep-2021 | 421 | 7 | 6 |
| local.sh.example | H A D | 16-Sep-2021 | 9 KiB | 267 | 247 |
| macros.h | H A D | 16-Sep-2021 | 13.7 KiB | 458 | 320 |
| portability.h | H A D | 16-Sep-2021 | 12.5 KiB | 471 | 307 |
| typecast.h | H A D | 16-Sep-2021 | 27.9 KiB | 1,652 | 1,480 |
README
1
2The main page of the Cado-NFS source code is
3[https://gitlab.inria.fr/cado-nfs/cado-nfs](https://gitlab.inria.fr/cado-nfs/cado-nfs).
4If you're accessing the cado-nfs source from a different link, it may be
5an outdated fork.
6
7[![pipeline status](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/pipeline.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/pipelines?ref=master)
8[![coverage report](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/coverage.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/jobs/artifacts/master/file/coverage/index.html?job=merge+coverage+tests)
9[![coverity scan](https://scan.coverity.com/projects/23184/badge.svg)](https://scan.coverity.com/projects/cado-nfs)
10
11Quick install:
12==============
13
14in most cases the following should work to factor the number 903...693
15using all cores on the local machine
16
171. `make`
182. `./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693`
19
20More details follow.
21
22Important note: For a larger factorization (distributed on several
23machines), the command line to be used is a priori more involved. Please
24refer to [`scripts/cadofactor/README.md`](scripts/cadofactor/README.md).
25Documented example parameter files are in
26[`parameters/factor/params.c90`](parameters/factor/params.c90) and
27[`scripts/cadofactor/parameters*`](scripts/cadofactor/).
28
29Supported platforms
30===================
31
32The primary development platform is `x86_64` linux with gcc 5 or newer,
33the most common processor being Intel core2-like or more recent.
34
35Other architectures are checked regularly, and should work. Please refer
36to the gitlab-ci page for the list of regularly tested platforms, and their
37current status. The overall pipeline status for the master branch is
38[![pipeline
39status](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/pipeline.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/pipelines?ref=master),
40and details can be obtained by clicking on the badges. Note however that
41a failing pipeline might mean that a bug affects only one platform in
42particular, or could be caused by one runner encountering difficulties.
43Such things do happen.
44
45Since we use gitlab-ci pipelines, the authoritative source as to what
46gets tested on a routine basis is of course the [`.gitlab-ci.yml`
47file](.gitlab-ci.yml). In plain english, the configurations that we test,
48or that we at least used to test at some point, are as follows.
49Anything beyond the set of regularly tested machines perhaps works,
50perhaps does not.
51
52 * The primary development platform is `x86_64` Debian GNU/Linux, latest
53 version, with gcc. If it doesn't work, we have a problem.
54
55 * A few recent versions of Debian or Fedora are also tested. CentOS
56 distributions (or derivatives) that have been EOL'd for some time, or
57 are deemed to be shortly because they have vastly out-of-date
58 software, are not tested.
59
60 * `x86_64` with icc 14, 15, 16, 17, and 18 did work once, but are not checked
61 regularly (cado-nfs uses C++11, which is not available with icc <=
62 14). Compilation with icc 19 has undergone more testing. Routine
63 checks use the ICC version that is provided by Intel's
64 [`intel/oneapi-hpckit:latest` docker
65 image](https://hub.docker.com/r/intel/oneapi-hpckit).
66
67 * Mac OS X is used for CI routine compilation checks, using the
68 default compiler from XCode. All version from 10.5 onwards were part
69 of the CI routine checks at some point in time, and worked
70 successfully. However we do not commit to continued support for old
71 versions. As of cado-nfs 2.3.0, Mac OS X 10.8+ should work. As of
72 cado-nfs 3.0.0, we expect that Mac OS X 10.12+ should work.
73
74 * Windows used to be partly supported, but this has been abandoned for
75 some time now (see a longer note
76 [there](#using-cado-nfs-under-windows) at the end of this file).
77
78Those machines, compared to the base install, are equipped with the
79necessary dependencies (see below). The console outputs for the different
80builds contain information related to the compiler versions being used.
81
82
83Required software tools
84=======================
85
86 * [GMP](http://gmplib.org/), version 5 or newer: usually installed in
87 most Linux distributions (on some Linux distributions you need to
88 install the `libgmp*-dev` or `gmp-devel` package that includes
89 `gmp.h`. It is often not installed by default). Note: make sure to
90 configure GMP with `--enable-shared` so that a shared library is
91 installed (`libgmp.so` under Linux) otherwise CADO-NFS might not
92 compile.
93 * As of `cado-nfs-3.0.0`, a C/C++ compiler and C/C++ standard library that
94 conform to the C99 and C++11 standards are required. (cado-nfs-2.3.0
95 only needed C99 and C++98). The dependency on C++11 is now
96 substantial enough that an "almost conformant" compiler is not
97 guaranteed to work. The minimal required versions for various
98 compilers are as follows. Not all old compiler versions are part of
99 our routine checks, so that a break for an old compiler is possible.
100 The only thing that we're quite certain of is that versions _older_
101 than below are a no-go.
102 * GCC: the minimal required version is >= 5
103 * LLVM Clang: the minimal required version is >= 4.0.0
104 * Apple Clang: the minimal required version is >= 6.0.0
105 * Intel ICC: the minimal required version is >= 14
106 * GNU make and CMake (`cmake 3.4` or later) for building (CMake is
107 installed on the fly if missing. This feature requires an Internet
108 connection.)
109 * Support for POSIX threads.
110 * The main `cado-nfs.py` script uses a lot of unix tools: Python, Python3,
111 `ssh`, `rsync`, `gzip` to mention but a few.
112 * On MacOS X, the cado-nfs client script needs an alternative to the
113 system-provided curl binary, which it doesn't like. The simplest way
114 to deal with this issue is to install the wget downloader (e.g. via
115 homebrew).
116 * For a large computation, MySQL is recommended.
117
118Optionally, cado-nfs can use the following additional software.
119
120* Support for OpenMP (at least version 3.0)
121* Support for MPI (see [`local.sh.example`](local.sh.example) and [`linalg/bwc/README`](linalg/bwc/README))
122* Support for hwloc (see [`parameters/misc/cpubinding.conf`](parameters/misc/cpubinding.conf))
123* Support for GMP-ECM. Define the environment variable GMPECM if it is
124 installed in a non-standard place.
125* A system [`fmt`](https://fmt.dev/) is used is found, otherwise a
126 snapshot is embedded in the cado-nfs code anyway.
127
128Configure
129=========
130
131Normally you have nothing to do to configure cado-nfs.
132
133However if your site needs tweaks, set such tweaks using environment variables,
134or via the shell script local.sh ; you may start with
135
136```
137cp local.sh.example local.sh
138```
139
140Edit according to your local settings and your taste: local.sh.example
141gives documentation on the recognized environment variables and their effect.
142
143Note that tweaks in local.sh are global (relevant to all sub-directories
144of the cado-nfs tree, not to a particular directory).
145
146As a rule of thumb, whenever you happen to modify the `local.sh` script, it
147is advised to trigger re-configuration of the build system, by the
148special command `make cmake`. Another way to achieve the same goal is
149to remove the build tree, which is below `build/` (normally named as the
150hostname of the current machine): `make tidy` should do it.
151Then, of course, you must recompile with `make`, since `make cmake`
152is just the equivalent of `./configure` in a classical build system.
153
154Optional (alternative): configure using cmake directly
155======================================================
156
157cado-nfs includes a top-level `Makefile` which builds the binary objects in
158a special build directory which is below `build/` (normally named as the
159hostname of the current machine). This way, parallel builds for different
160machines may coexist in one shared directory. This is sort of a magic
161`out-of-source` build.
162
163Another way to do `out-of-source` build is to create a separate build
164directory and build from there, by calling cmake directly for the
165configuration. This proceeds as follows:
166
167```
168mkdir /some/build/directory
169cd /some/build/directory
170cmake /path/to/cado-nfs/source/tree
171```
172
173Note however that in this case, the `local.sh` file found in the source
174tree is not read (but you may elect to do so before calling cmake).
175
176Compile:
177========
178
179```
180make
181```
182
183Install:
184========
185
186The relevance of the `make install` step depends on the platform.
187Cado-nfs binaries link to shared libraries, and some do so dynamically.
188For this to work, we rely on some control logic by cmake and cooperation
189with the operating system's dynamic linker.
190
191* if `make` is directly called from the source directory `$SRCDIR`,
192 then `make install` installs all programs and binaries in `$SRCDIR/installed`.
193
194* otherwise programs and binaries will be installed in
195 `/usr/local/share/cado-nfs-x.y.z`, and this default installation prefix
196 can be changed by one of the following commands:
197
198```
199cmake .../cado-nfs -DCMAKE_INSTALL_PREFIX=/tmp/install
200export PREFIX=/tmp/install ; cmake .../cado-nfs
201```
202
203There are several ways to call cado-nfs scripts (e.g., `cado-nfs.py`).
204Here we assume that `$SRCDIR` is the source directory, that `$BUILDDIR`
205is the build tree for the local machine (typically `$SRCDIR/$(hostname)`),
206and that `$PREFIX` is the installation prefix (see above). We refer to
207these different ways, and later discuss how they work on different
208systems (which is mostly impacted by the shared library mechanism).
209
210* `$SRCDIR/cado-nfs.py`
211 This deduces `$BUILDDIR` from the machine hostname, and amounts to
212 calling binaries from there. Parameter files are obtained from
213 $SRCDIR/parameters/
214
215* `$PREFIX/bin/cado-nfs.py`
216 This calls binaries from `$PREFIX/bin`, and loads parameter files from
217 `$PREFIX/share/cado-nfs-x.y.z/`
218
219* `$BUILDDIR/cado-nfs.py`
220 This is not supported. Might work, might not. You've been warned.
221
222Linux, BSD: the first two choices above should work ok.
223MacOS X:
224 For any invocation to work, the `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH`
225 variable must be set up properly. The easiest method is to do make
226 install, and include in these environment variables the directory
227 `$PREFIX/lib/cado-nfs-x.y.z`.
228
229Run a factorization on the current machine:
230===========================================
231
232```
233./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 -t 2
234```
235
236where the option `-t 2` tells how many cores (via threads) to use on the
237current machine (for polynomial selection, sieving, linear algebra, among
238others). It is possible to set `-t all` (which, in fact, is the default)
239to use all threads on the current machine.
240
241CADO-NFS is optimized only for numbers above 85 digits, and no support will
242be provided for numbers of less than 60 digits (for very large numbers,
243no support is promised). Note that it is a good idea to remove small prime
244factors using special-purpose algorithms such as trial division, P-1, P+1,
245or ECM, and use CADO-NFS only for the remaining composite factor.
246
247Parts of the Number Field Sieve computation are massively distributed. In
248this mode, client scripts (namely, `cado-nfs-client.py`) are run on many
249nodes, connect to a central server, and run programs according to which
250computations need to be done. The programs (for the polynomial selection
251and sieving steps) can run multithreaded. It is better to have them
252run with a capped number of threads (say, 2), and run several clients per
253node. By default, programs in this step are limited to 2 threads. When
254running the computation on the local machine, the number of clients is
255set so that the number of cores specified by `-t` are kept busy.
256
257Run a larger factorization on several machines:
258===============================================
259
260CADO-NFS has several ways of operation, which can be roughly split into
261three modes as follows.
262
263 * For small computations, or for tests where it is important to have a
264 single command line, the strategy
265 [above](#run-a-factorization-on-the-current-machine) works. The
266 `cado-nfs.py` script can arrange so that the binaries for all steps of
267 the computation are run on the current machine, or possibly on other
268 machines, via SSH. Some of the documentation here is specific to this
269 mode of operation (see in particular
270 [there](#check-that-your-network-configuration-is-correct) or
271 [there](#check-that-your-ssh-configuration-is-correct)). If you get it
272 right, you may manage to run factorizations as follows. However be
273 aware that this mode of operation is fragile, and we advise not to use
274 it beyond trivial testing.
275
276 ```
277 ./cado-nfs.py 353493749731236273014678071260920590602836471854359705356610427214806564110716801866803409 slaves.hostnames=hostname1,hostname2,hostname3 --slaves 4 --client-threads 2
278 ```
279
280 This starts 4 clients per host on the hosts `hostname1`, `hostname2`,
281 and `hostname3`, and each client uses two cpus (threads). For
282 hostnames that are not `localhost`, ssh is used to connect to the host
283 and start a client there. To configure ssh, see the [next
284 section](#check-that-your-ssh-configuration-is-correct). For tasks
285 that use the local machine only (not massively distributed tasks), the
286 number of threads used is the one given by `-t` (which defaults to all
287 threads on the local machine).
288
289 * For larger computations where work distribution is an important point
290 (distribution on several machines, possibly with different parameters
291 for different machines), it is considerably more flexible to let the
292 server be _just_ a server, and start clients separately, that will be
293 used to offload the distributed tasks (polynomial selection and
294 relation collection). Clients can come and go. The server has plenty
295 of timeout provisions to deal with such events.
296
297 This is called the `--server` mode (see
298 [`scripts/cadofactor/README.md`](scripts/cadofactor/README.md) and
299 [`scripts/cadofactor/parameters`](scripts/cadofactor/parameters)).
300 See also [this thread](https://lists.gforge.inria.fr/pipermail/cado-nfs-discuss/2020-March/001168.html) on the old `cado-nfs-discuss` list (it's been [replaced](#contact-links)). If you want to use cado-nfs even to a little extent, we recomment that you familiarize with this mode of operation.
301
302 * For much larger computations, the `cado-nfs.py` is only of moderate
303 use. The individual cado-nfs binaries and internal scripts are the
304 most flexible entry points, and should be used in order to adapt to
305 the specificities of the platform being used (e.g. to deal with
306 various requirements such as memory for filtering, interconnect for
307 linear algebra, and so on).
308
309Check that your network configuration is correct:
310=================================================
311
312In case you run a factorization on the local machine, the clients should be able
313to connect to the server. Under Linux, CADO-NFS uses 'localhost' to identify the
314server, thus you should have the following line in your /etc/hosts file:
315
316```
317127.0.0.1 localhost
318```
319
320Check that your SSH configuration is correct:
321=============================================
322
323The master script (unless in `--server` mode) uses SSH to connect to
324available computing resources. In order to avoid the script asking your
325password or passphrase, you must have public-key authentication and an
326agent.
327
328The SSH keys are usually installed in the files `~/.ssh/id_rsa` and
329`~/.ssh/id_rsa.pub`; if you don't have them yet, you can create them with the
330`ssh-keygen` command. See the man page `ssh-keygen(1)` for details. The private
331key should be protected with a passphrase, which you can enter when you
332create the keys. Normally ssh will ask for the key's passphrase when you log
333on to a machine, but this can be avoided by using ssh-agent, see the man
334page `ssh-agent(1)`, and providing the passphrase to the agent with `ssh-add`.
335Public-key authenticaton together with an ssh-agent will allow `cadofactor`
336to use ssh to run commands on slave machines automatically.
337
338Most of the recent Linux distributions will run an `ssh-agent` for you. But
339if this is not the case with your distribution, or if you are running
340`cado-nfs.py` inside a `screen` in order to logout from your desktop, you
341will need to run the `ssh-agent` by hand. As a short recipe, you can type:
342```
343eval `ssh-agent`
344ssh-add
345```
346
347You should also copy your public key, i.e., the contents of the file
348`~/.ssh/id_rsa.pub`, into `$HOME/.ssh/authorized_keys` on the slave machines, to
349allow logging in with public-key authentication.
350
351Also, since localhost has an IP and key that varies, you should have
352those 3 lines in your `$HOME/.ssh/config`:
353
354```
355Host localhost
356 StrictHostKeyChecking no
357 UserKnownHostsFile /dev/null
358```
359
360If everything is correctly configured, when you type
361
362ssh localhost
363
364you should end up with a new shell on your machine, without having to
365type any password/passphrase.
366
367
368Restarting an interrupted factorization:
369========================================
370
371If you have started a factorization with the `cado-nfs.py` script, and it was
372interrupted (for example because of a power failure) you can restart in
373any of these two ways:
374
375 * with the same `cado-nfs.py` command line if a work directory was
376 explicitly provided on the command line:
377
378 ```
379 $ cado-nfs.py ... workdir=/path/to/workdir
380 ```
381
382 * with a single argument as in:
383
384 ```
385 $ cado-nfs.py [[work directory]]/XXX.parameters_snapshot.YYY
386 ```
387
388 where `[[work directory]]` is the directory which has been chosen
389 automatically, `XXX` is the "name" of the running factorisation, and `YYY`
390 is the largest possible integer value for which such a file exists.
391
392Factoring with SNFS:
393====================
394
395It is possible to take advantage of the special form of an integer and
396use the Special Number Field Sieve. See
397[`parameters/factor/parameters.F9`](parameters/factor/parameters.F9)
398for that:
399
400```
401$ cado-nfs.py parameters/factor/parameters.F9 slaves.hostnames=localhost
402```
403
404Note in particular that you can force the special-q to be on the rational
405side if this is more appropriate for your number, with
406`tasks.sieve.sqside=0` on the `cado-nfs.py` command line or in the
407parameter file (assuming side 0 is the rational side).
408
409The default square root algorithm does not work in some very rare cases
410that could possibly occur with SNFS polynomials (a degree 4 polynomial
411with Galois group $Z/2 \times Z/2$ is the only reasonable example, next
412case is for degree 8). The CRT approach is a workaround. See
413[`sqrt/crtaglsqrt.c`](sqrt/crtaglsqrt.c) .
414
415Big factorization (200 digits and more):
416========================================
417
418By default, to decrease memory usage, it is assumed that less than $2^32$
419(~ four billion) relations or ideals are needed and that the ideals will
420be less than $2^32$ (i.e., the `lpb0` and `lpb1` parameters are less or
421equal to 32). In the case of factorizations of numbers of 200 digits and
422more, these assumptions may not hold. In this case, you have to set some
423variables in your `local.sh` script (see Configure section above for more
424information on `local.sh` and section on big factorizations in
425`local.sh.example`).
426
427Factoring with two non-linear polynomials:
428==========================================
429
430You can find a bit of information on this topic in the development
431version, in the GIT repository (see file
432[`README.nonlinear`](README.nonlinear)).
433
434Importing polynomials or relations:
435===================================
436
437If you have already computed a good polynomial and/or relations, you can
438tell CADO-NFS to use them, see
439[`scripts/cadofactor/README.md`](scripts/cadofactor/README.md).
440
441Using CADO-NFS under Windows:
442=============================
443
444Portability of CADO-NFS on Windows was not an initial goal of that project,
445however we give here some hints that might help people wanting to use CADO-NFS
446under Windows. We hope that the following information can be useful to
447some extent, but the general message is that you're on your own.
448
449* Cado-NFS uses the POSIX interface all over the place, which means that
450 in one form of the other, you need to have the corresponding
451 functionality. If you don't, you're out of luck. (e.g., cado-nfs cannot
452 build as a "pure" visual studio project.)
453
454* if you only need the siever to run on Windows, then you only need to compile
455 the `las` program on Windows.
456
457* [Cygwin](http://www.cygwin.com/) provides a Unix-like environment,
458 where compilation should be easy. However the binary requires a
459 `cygwin.dll` file. We have been told of problems with shared libraries,
460 which the following seems to address:
461 ```
462 PATH="installed/lib/cado-nfs-x.y.z:$PATH" ./cado-nfs.py [...]
463 ```
464
465* if you want a binary without any dependency, you might try
466 [MinGW](http://www.mingw.org/). The INSTALL file from GNU MPFR contains
467 detailed instructions on how to compile MPFR under Windows. Those
468 instructions should work for CADO-NFS too. See
469 [`dev_docs/howto-MinGW.txt`](dev_docs/howto-MinGW.txt).
470
471* you might try to use MPIR (<http://mpir.org/>) instead of GMP. MPIR
472 is a fork of GMP, which claims to be more portable under Windows.
473 Alternatively, Windows ports of GMP shouldn't be too hard to find.
474
475* you might succeed in compiling the cado-nfs binaries with a
476 cross-compiler for Windows (which does not waive the runtime
477 requirements for `cado-nfs.py`, notably on unix-like utilities). See
478 [`dev_docs/README.cross`](dev_docs/README.cross) in the source code
479 repository for information on how to cross-compile.
480
481Examples of basic usage:
482========================
483
484* Run a full factorization on the local machine, using all available
485 cores:
486
487```
488./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693
489```
490
491* Run a full factorization on the local machine, using all available
492 cores, but with a slightly modified set of default parameters.
493
494 The difficulty here is that when `cado-nfs.py` uses a parameter file
495 supplied on the command line, it does not automatically insert into the
496 parameter set the options that are necessary for running jobs.
497 Therefore, we need to add these options:
498
499```
500./cado-nfs.py --parameters ./parameters/factor/params.c60 90377629292003121684002147101760858109247336549001090677693 slaves.hostnames=localhost slaves.nrclients=2
501```
502
503* Run a full factorization on the local machine, using 8 threads for the
504 server (this includes the linear algebra), and 4 jobs of 2 threads
505 each for the polynomial selection and the sieving:
506
507```
508./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 --slaves 4 --client-threads 2 --server-threads 8
509```
510
511* Run a factorization in the given directory, interrupt it (with Ctrl-C,
512 or whatever unexpected event), and resume the computation:
513
514```
515./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 workdir=/tmp/myfacto
516[Ctrl-C]
517./cado-nfs.py /tmp/myfacto/c60.parameters_snapshot.0
518```
519
520* Run a server on `machine1`, and a slave on `machine2`, disabling ssl:
521
522```
523machine1$ ./cado-nfs.py --server 90377629292003121684002147101760858109247336549001090677693 server.port=4242 server.ssl=no server.whitelist=machine2
524machine2$ ./cado-nfs-client.py --server=http://machine1:4242 --bindir=...
525```
526
527Note: if you are on an insecure network, you'll have to activate ssl, and
528then pass the appropriate sha1 certificate to the client (the server
529prints the appropriate command-line to be copy-pasted on `machine2`).
530
531* Run a factorization on `machine1`, and have it start automatically a
532 slave on `machine2` via SSH:
533
534```
535./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693
536slaves.hostnames=machine1,machine2
537```
538
539Note that, in that case, you have to specify `machine1` as well in the list
540of `hostnames` if you want it to contribute to the polynomial selection and
541the sieving.
542
543
544Stopping the factorization during a specific step:
545==================================================
546It is possible to stop the factorization:
547
548```
549./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 tasks.xxxx.run=false
550```
551
552This command works with: xxxx = polyselect, sieve, filter, linalg
553
554
555Known problems:
556===============
557
558(some of these problems refer to versions or operating systems that are
559no longer supported by cado-nfs anyway)
560
561* when running the square root step in multi-thread mode (tasks.sqrt.threads=2
562 or larger) with GMP <= 6.0, you might encounter an issue due to a "buglet"
563 in GMP (<https://gmplib.org/list-archives/gmp-bugs/2015-March/003607.html>).
564 Workaround: use tasks.sqrt.threads=1 or GMP >= 6.1.0.
565* GCC 4.1.2 is known to miscompile CADO-NFS (see
566 <http://cado-nfs.gforge.inria.fr/bug.php?14490>),
567 GCC 4.2.0, 4.2.1 and 4.2.2 are also affected.
568* under NetBSD 5.1 amd64, Pthreads in the linear algebra step seem not to
569 work, please use `-t 1` option in `cado-nfs.py` or `tasks.linalg.threads=1x1`.
570* under AIX, if GMP is compiled in 64-bit mode, you should set the
571 environment variable `OBJECT_MODE`, for example:
572 export `OBJECT_MODE=64`
573* if you encounter the error "Exceeded maximum number of failed workunits,
574 maxfailed=100", you can restart the factorization with
575 `tasks.maxfailed=200`. But it would be wise, first, to try to
576 understand _why_ workunits are failing. This should not appear. It
577 might be that all your workunits are timing out, because your `adrange`
578 and `qrange` parameters are too large. Or it's a bug in cado-nfs, and
579 then it should definitely be reported.
580
581
582Contact, links:
583===============
584
585The website of the project is hosted at:
586 <http://cado-nfs.gforge.inria.fr/>
587
588You can get the latest development version with:
589```
590git clone https://gitlab.inria.fr/cado-nfs/cado-nfs.git
591```
592or
593```
594git clone git@gitlab.inria.fr:cado-nfs/cado-nfs.git
595```
596(use the latter if you have an account on Inria gitlab, and commit access
597to cado-nfs)
598
599There is now a unique mailing-list associated to Cado-nfs
600[cado-nfs@inria.fr](https://sympa.inria.fr/sympa/info/cado-nfs). Please
601do not use the old `cado-nfs-discuss` mailing list, the infrastructure
602that hosts this mailing list is set for removal in 2021.
603
604If you find a bug, if you have a problem compiling cado-nfs, if you want to
605factor a large number and seek for advice for tuning the parameters, then
606the cado-nfs-discuss list is the right place to ask.
607
608On the <https://gitlab.inria.fr/cado-nfs/cado-nfs> web page you can also
609find the cado-nfs bug tracker (a.k.a project issues). The bug tracker is
610an important piece of the cado-nfs development cycle. Submitting bugs
611and merge requests there is welcome (you need an Inria gitlab account),
612although if you are unsure, it might be better to speak up on the
613cado-nfs-discuss mailing list first.
614
README.Python
1This file describes some problems that can occur with the cado-nfs.py
2script in relation to various distributions' Python installations.
3
4
51. Python 3
6
7Python 3, version 3.3 or greater, is required for cado-nfs.py. If you
8do not wish to use cado-nfs.py, maybe because you plan to run all
9commands by hand, you can disable the Python check in CMake by setting
10NO_PYTHON_CHECK to any non-empty string in local.sh. See local.sh.example
11for a template.
12
13Some operating systems don't have a Python 3 interpreter installed by
14default. The safest bet is to install a distribution-supplied package
15for Python 3. If no such package is available, you can download the
16Python source code, compile and and install it by yourself. For a good
17introduction to installing Python from source, see
18https://www.digitalocean.com/community/articles/how-to-set-up-python-2-7-6-and-3-3-3-on-centos-6-4
19
20
212. Sqlite 3
22
23The Python cado-nfs.py script requires sqlite3. Unfortunately, not all
24distributions install the Python sqlite3 module by default.
25
26In fact, two things are required: the binary sqlite3 library, and the Python
27module called "sqlite3" which provides a Python interface to the sqlite3
28library.
29
30The binary sqlite3 library is installed by default on most systems, but it
31is worthwhile to check that it is. Use your distribution's package manager,
32and look for a package called "sqlite", "sqlite3", or "libsqlite3", which
33should contain a file "libsqlite3.so.*"
34
35The Python sqlite3 module unfortunately is not installed by default by some
36distributions, known culprits include Gentoo.
37
38Gentoo:
39For Gentoo, the Python 3 package by default does not include the sqlite3
40module. This link to a forum post briefly describes the situation:
41<http://forums.gentoo.org/viewtopic-t-876737-start-0.html>
42The sqlite3 module can be included in the Python installation by adding
43the sqlite USE flag to /etc/portage/make.conf as shown in this example:
44
45# These are the USE flags that were used in addition to what is provided by the
46# profile used for building.
47USE="bindist mmx sse sse2 sqlite"
48
49and then running
50emerge --deep --newuse world
51
52
53If you compile Python 3 yourself from source code, be aware that the sqlite3
54development package with the header files for the sqlite3 library must be
55installed on the system; without them, the Python 3 build will seem to
56succeed but will not include the sqlite3 interface. When compiling Python 3,
57be sure that the "make" output does NOT include a warning of the form:
58
59The necessary bits to build these optional modules were not found:
60_sqlite3
61
62
633. SSL
64
65The workunit server and clients use SSL for communication to prevent an
66attacker on the same network from injecting text into workunits which could
67be used to execute arbitrary commands on the client machines. Generating a
68server certificate requires that OpenSSL is installed on the computer
69running the server.
70
714. MySQL
72
73If you wish to use MySQL you first need to install the Python MySQL connector library available at
74https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-py3_2.1.3-1ubuntu14.04_all.deb
75You then pass the -mysql flag to ./cado-nfs.py
76
README.dlp
1Using CADO-NFS for DLP in large characteristic fields.
2------------------------------------------------------
3
4**** Basic usage: DLP in GF(p)
5
6The cado-nfs.py script can be used to compute discrete logarithms in a
7prime field GF(p). For example, to compute the discrete logarithm in GF(p)
8modulo the factor 101538509534246169632617439 of p-1 of the target
992800609832959449330691138186 with p=191907783019725260605646959711:
10
11$ ./cado-nfs.py -dlp -ell 101538509534246169632617439 target=92800609832959449330691138186 191907783019725260605646959711
12
13In principle, just typing
14 ./cado-nfs.py -dlp -ell <ell> target=<target> <p>
15should compute the discrete logarithm of <target> modulo <ell> in
16GF(<p>). Right now, there are parameters only for primes p of around 30,
1760, 100 or 155 digits (to be checked in params_dl/ subdirectory). If no
18target is given, then the output is a file containing the virtual
19logarithms of all the factor base elements.
20
21More flexibility is possible. An example of parameter file is given in
22parameters/dlp/param.p60. Compared to parameter files for integer
23factorization, the main difference is that the lines related
24to characters and sqrt disappear and that there is an additional block of
25parameters related to individual logarithms.
26
27After the computation is finished, it is possible to run again the
28cado-nfs.py script, with a different target: only the last step will be
29run. For ensuring that the precomputed data is really used, copy-paste
30the command-line indicated in the output of the first computation that
31contains "If you want to compute a new target…", and set the new target at the
32end.
33
34Important note: the logarithms are given in an arbitrary (unknown) base.
35If you want to define them with respect to a specific generator g, then
36you'll have to compute the logarithm of g and then divide all the logs by
37this value. See https://lists.gforge.inria.fr/pipermail/cado-nfs-discuss/2018-November/000939.html and
38https://lists.gforge.inria.fr/pipermail/cado-nfs-discuss/2018-November/000942.html.
39
40**** Using Joux-Lercier polynomial selection
41
42By default, the same polynomial selection algorithm as for factoring is
43used. In some (many ?) cases, it can be much better to use Joux-Lercier's
44polynomial selection as implemented in polyselect/dlpolyselect. In order
45to use it, it is necessary to add the parameter
46 jlpoly = true
47and to give the additional parameters:
48 tasks.polyselect.degree = 3
49 tasks.polyselect.bound = 5
50 tasks.polyselect.modm = 5
51
52Here, polynomial.degree is the degree of the polynomial with small
53coefficients. The other one will have degree one less. Therefore, on this
54example, this is a selection for degrees (3,2). The polynomial.bound
55and the polynomial.modm parameters are passed directly to dlpolyselect.
56The search is parallelized with the client/server mechanism as for the
57classical polynomial selection. Each task does one value "modr" between 0
58and modm-1 (again, this is dlpolyselect terminology). The number of tried
59polynomials is roughly (2*bound+1)^(degree+1), thus here 14641 (the larger
60the better, but then polynomial selection will last longer).
61
62For instance, the 30-digit example above can be done with JL polynomial
63selection with the following command-line:
64
65$ ./cado-nfs.py -dlp -ell 101538509534246169632617439 191907783019725260605646959711 jlpoly=true tasks.polyselect.bound=5 tasks.polyselect.modm=7 tasks.polyselect.degree=3 tasks.reconstructlog.checkdlp=false
66
67In that case, the individual logarithm phase implementation is based on
68GMP-ECM, so this is available only if this library is installed and
69detected by the configuration script (see local.sh.example for indicating
70non-standard locations).
71
72Note that tasks.reconstructlog.checkdlp=false is there to disable some
73consistency checks that can not be made in JL mode.
74
75This is still experimental, but parameters optimized for the JL
76polynomial selection can be found in parameters/dlp/Joux-Lercier/ .
77Copying
78 parameters/dlp/Joux-Lercier/params.p30
79to
80 parameters/dlp/params.p30
81will automatically activate the JL polynomial selection (but will crash
82if GMP-ECM failed to be detected at compile time) for primes of this
83size. For instance,
84
85$ ./cado-nfs.py -dlp -ell 101538509534246169632617439 target=92800609832959449330691138186 191907783019725260605646959711
86
87should then work and compute the log of the given target using JL.
88
89
90**** Using non-linear polynomials
91
92Just like for factorization, it is possible to use two non-linear
93polynomials for DLP. Apart from Joux-Lercier polynomial selection (see above),
94the user must provide the polynomial file. Also, the current descent script
95will not work.
96
97See README.nonlinear for an example of importing a polynomial file with 2
98non-linear polynomials.
99
100An important issue is that since the descent is not yet functional
101for this case, the script has no way to check the results if there is no
102linear polynomial. A good idea is to set
103 tasks.reconstructlog.partial = false
104so that many consistency checks are performed while using all the
105relations that were deleted during the filter.
106
107**** Discrete logarithms in GF(p^k) for small k
108
109The algorithm works "mutatis mutandis" for discrete logarithm computations
110in GF(p^k). The only difference is that the two polynomials must have a
111common irreducible factor of degree k over GF(p). Polynomial selection
112for this case is not yet included, so you must build them by yourself,
113based on constructions available in the literature, and import it as
114indicated in scripts/cadofactor/README. Also the individual
115logarithm has to be implemented for that case.
116
117For DLP in GF(p^2), things are sligthly more integrated:
118 ./cado-nfs.py <p> -dlp -ell <ell> -gfpext 2
119should work for p = 7 mod 8, provided that a parameter file is available
120for the size of p (at the time of writing this doc, only p of 20 decimal
121digits is supported).
122
README.md
1
2The main page of the Cado-NFS source code is
3[https://gitlab.inria.fr/cado-nfs/cado-nfs](https://gitlab.inria.fr/cado-nfs/cado-nfs).
4If you're accessing the cado-nfs source from a different link, it may be
5an outdated fork.
6
7[![pipeline status](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/pipeline.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/pipelines?ref=master)
8[![coverage report](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/coverage.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/jobs/artifacts/master/file/coverage/index.html?job=merge+coverage+tests)
9[![coverity scan](https://scan.coverity.com/projects/23184/badge.svg)](https://scan.coverity.com/projects/cado-nfs)
10
11Quick install:
12==============
13
14in most cases the following should work to factor the number 903...693
15using all cores on the local machine
16
171. `make`
182. `./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693`
19
20More details follow.
21
22Important note: For a larger factorization (distributed on several
23machines), the command line to be used is a priori more involved. Please
24refer to [`scripts/cadofactor/README.md`](scripts/cadofactor/README.md).
25Documented example parameter files are in
26[`parameters/factor/params.c90`](parameters/factor/params.c90) and
27[`scripts/cadofactor/parameters*`](scripts/cadofactor/).
28
29Supported platforms
30===================
31
32The primary development platform is `x86_64` linux with gcc 5 or newer,
33the most common processor being Intel core2-like or more recent.
34
35Other architectures are checked regularly, and should work. Please refer
36to the gitlab-ci page for the list of regularly tested platforms, and their
37current status. The overall pipeline status for the master branch is
38[![pipeline
39status](https://gitlab.inria.fr/cado-nfs/cado-nfs/badges/master/pipeline.svg)](https://gitlab.inria.fr/cado-nfs/cado-nfs/-/pipelines?ref=master),
40and details can be obtained by clicking on the badges. Note however that
41a failing pipeline might mean that a bug affects only one platform in
42particular, or could be caused by one runner encountering difficulties.
43Such things do happen.
44
45Since we use gitlab-ci pipelines, the authoritative source as to what
46gets tested on a routine basis is of course the [`.gitlab-ci.yml`
47file](.gitlab-ci.yml). In plain english, the configurations that we test,
48or that we at least used to test at some point, are as follows.
49Anything beyond the set of regularly tested machines perhaps works,
50perhaps does not.
51
52 * The primary development platform is `x86_64` Debian GNU/Linux, latest
53 version, with gcc. If it doesn't work, we have a problem.
54
55 * A few recent versions of Debian or Fedora are also tested. CentOS
56 distributions (or derivatives) that have been EOL'd for some time, or
57 are deemed to be shortly because they have vastly out-of-date
58 software, are not tested.
59
60 * `x86_64` with icc 14, 15, 16, 17, and 18 did work once, but are not checked
61 regularly (cado-nfs uses C++11, which is not available with icc <=
62 14). Compilation with icc 19 has undergone more testing. Routine
63 checks use the ICC version that is provided by Intel's
64 [`intel/oneapi-hpckit:latest` docker
65 image](https://hub.docker.com/r/intel/oneapi-hpckit).
66
67 * Mac OS X is used for CI routine compilation checks, using the
68 default compiler from XCode. All version from 10.5 onwards were part
69 of the CI routine checks at some point in time, and worked
70 successfully. However we do not commit to continued support for old
71 versions. As of cado-nfs 2.3.0, Mac OS X 10.8+ should work. As of
72 cado-nfs 3.0.0, we expect that Mac OS X 10.12+ should work.
73
74 * Windows used to be partly supported, but this has been abandoned for
75 some time now (see a longer note
76 [there](#using-cado-nfs-under-windows) at the end of this file).
77
78Those machines, compared to the base install, are equipped with the
79necessary dependencies (see below). The console outputs for the different
80builds contain information related to the compiler versions being used.
81
82
83Required software tools
84=======================
85
86 * [GMP](http://gmplib.org/), version 5 or newer: usually installed in
87 most Linux distributions (on some Linux distributions you need to
88 install the `libgmp*-dev` or `gmp-devel` package that includes
89 `gmp.h`. It is often not installed by default). Note: make sure to
90 configure GMP with `--enable-shared` so that a shared library is
91 installed (`libgmp.so` under Linux) otherwise CADO-NFS might not
92 compile.
93 * As of `cado-nfs-3.0.0`, a C/C++ compiler and C/C++ standard library that
94 conform to the C99 and C++11 standards are required. (cado-nfs-2.3.0
95 only needed C99 and C++98). The dependency on C++11 is now
96 substantial enough that an "almost conformant" compiler is not
97 guaranteed to work. The minimal required versions for various
98 compilers are as follows. Not all old compiler versions are part of
99 our routine checks, so that a break for an old compiler is possible.
100 The only thing that we're quite certain of is that versions _older_
101 than below are a no-go.
102 * GCC: the minimal required version is >= 5
103 * LLVM Clang: the minimal required version is >= 4.0.0
104 * Apple Clang: the minimal required version is >= 6.0.0
105 * Intel ICC: the minimal required version is >= 14
106 * GNU make and CMake (`cmake 3.4` or later) for building (CMake is
107 installed on the fly if missing. This feature requires an Internet
108 connection.)
109 * Support for POSIX threads.
110 * The main `cado-nfs.py` script uses a lot of unix tools: Python, Python3,
111 `ssh`, `rsync`, `gzip` to mention but a few.
112 * On MacOS X, the cado-nfs client script needs an alternative to the
113 system-provided curl binary, which it doesn't like. The simplest way
114 to deal with this issue is to install the wget downloader (e.g. via
115 homebrew).
116 * For a large computation, MySQL is recommended.
117
118Optionally, cado-nfs can use the following additional software.
119
120* Support for OpenMP (at least version 3.0)
121* Support for MPI (see [`local.sh.example`](local.sh.example) and [`linalg/bwc/README`](linalg/bwc/README))
122* Support for hwloc (see [`parameters/misc/cpubinding.conf`](parameters/misc/cpubinding.conf))
123* Support for GMP-ECM. Define the environment variable GMPECM if it is
124 installed in a non-standard place.
125* A system [`fmt`](https://fmt.dev/) is used is found, otherwise a
126 snapshot is embedded in the cado-nfs code anyway.
127
128Configure
129=========
130
131Normally you have nothing to do to configure cado-nfs.
132
133However if your site needs tweaks, set such tweaks using environment variables,
134or via the shell script local.sh ; you may start with
135
136```
137cp local.sh.example local.sh
138```
139
140Edit according to your local settings and your taste: local.sh.example
141gives documentation on the recognized environment variables and their effect.
142
143Note that tweaks in local.sh are global (relevant to all sub-directories
144of the cado-nfs tree, not to a particular directory).
145
146As a rule of thumb, whenever you happen to modify the `local.sh` script, it
147is advised to trigger re-configuration of the build system, by the
148special command `make cmake`. Another way to achieve the same goal is
149to remove the build tree, which is below `build/` (normally named as the
150hostname of the current machine): `make tidy` should do it.
151Then, of course, you must recompile with `make`, since `make cmake`
152is just the equivalent of `./configure` in a classical build system.
153
154Optional (alternative): configure using cmake directly
155======================================================
156
157cado-nfs includes a top-level `Makefile` which builds the binary objects in
158a special build directory which is below `build/` (normally named as the
159hostname of the current machine). This way, parallel builds for different
160machines may coexist in one shared directory. This is sort of a magic
161`out-of-source` build.
162
163Another way to do `out-of-source` build is to create a separate build
164directory and build from there, by calling cmake directly for the
165configuration. This proceeds as follows:
166
167```
168mkdir /some/build/directory
169cd /some/build/directory
170cmake /path/to/cado-nfs/source/tree
171```
172
173Note however that in this case, the `local.sh` file found in the source
174tree is not read (but you may elect to do so before calling cmake).
175
176Compile:
177========
178
179```
180make
181```
182
183Install:
184========
185
186The relevance of the `make install` step depends on the platform.
187Cado-nfs binaries link to shared libraries, and some do so dynamically.
188For this to work, we rely on some control logic by cmake and cooperation
189with the operating system's dynamic linker.
190
191* if `make` is directly called from the source directory `$SRCDIR`,
192 then `make install` installs all programs and binaries in `$SRCDIR/installed`.
193
194* otherwise programs and binaries will be installed in
195 `/usr/local/share/cado-nfs-x.y.z`, and this default installation prefix
196 can be changed by one of the following commands:
197
198```
199cmake .../cado-nfs -DCMAKE_INSTALL_PREFIX=/tmp/install
200export PREFIX=/tmp/install ; cmake .../cado-nfs
201```
202
203There are several ways to call cado-nfs scripts (e.g., `cado-nfs.py`).
204Here we assume that `$SRCDIR` is the source directory, that `$BUILDDIR`
205is the build tree for the local machine (typically `$SRCDIR/$(hostname)`),
206and that `$PREFIX` is the installation prefix (see above). We refer to
207these different ways, and later discuss how they work on different
208systems (which is mostly impacted by the shared library mechanism).
209
210* `$SRCDIR/cado-nfs.py`
211 This deduces `$BUILDDIR` from the machine hostname, and amounts to
212 calling binaries from there. Parameter files are obtained from
213 $SRCDIR/parameters/
214
215* `$PREFIX/bin/cado-nfs.py`
216 This calls binaries from `$PREFIX/bin`, and loads parameter files from
217 `$PREFIX/share/cado-nfs-x.y.z/`
218
219* `$BUILDDIR/cado-nfs.py`
220 This is not supported. Might work, might not. You've been warned.
221
222Linux, BSD: the first two choices above should work ok.
223MacOS X:
224 For any invocation to work, the `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH`
225 variable must be set up properly. The easiest method is to do make
226 install, and include in these environment variables the directory
227 `$PREFIX/lib/cado-nfs-x.y.z`.
228
229Run a factorization on the current machine:
230===========================================
231
232```
233./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 -t 2
234```
235
236where the option `-t 2` tells how many cores (via threads) to use on the
237current machine (for polynomial selection, sieving, linear algebra, among
238others). It is possible to set `-t all` (which, in fact, is the default)
239to use all threads on the current machine.
240
241CADO-NFS is optimized only for numbers above 85 digits, and no support will
242be provided for numbers of less than 60 digits (for very large numbers,
243no support is promised). Note that it is a good idea to remove small prime
244factors using special-purpose algorithms such as trial division, P-1, P+1,
245or ECM, and use CADO-NFS only for the remaining composite factor.
246
247Parts of the Number Field Sieve computation are massively distributed. In
248this mode, client scripts (namely, `cado-nfs-client.py`) are run on many
249nodes, connect to a central server, and run programs according to which
250computations need to be done. The programs (for the polynomial selection
251and sieving steps) can run multithreaded. It is better to have them
252run with a capped number of threads (say, 2), and run several clients per
253node. By default, programs in this step are limited to 2 threads. When
254running the computation on the local machine, the number of clients is
255set so that the number of cores specified by `-t` are kept busy.
256
257Run a larger factorization on several machines:
258===============================================
259
260CADO-NFS has several ways of operation, which can be roughly split into
261three modes as follows.
262
263 * For small computations, or for tests where it is important to have a
264 single command line, the strategy
265 [above](#run-a-factorization-on-the-current-machine) works. The
266 `cado-nfs.py` script can arrange so that the binaries for all steps of
267 the computation are run on the current machine, or possibly on other
268 machines, via SSH. Some of the documentation here is specific to this
269 mode of operation (see in particular
270 [there](#check-that-your-network-configuration-is-correct) or
271 [there](#check-that-your-ssh-configuration-is-correct)). If you get it
272 right, you may manage to run factorizations as follows. However be
273 aware that this mode of operation is fragile, and we advise not to use
274 it beyond trivial testing.
275
276 ```
277 ./cado-nfs.py 353493749731236273014678071260920590602836471854359705356610427214806564110716801866803409 slaves.hostnames=hostname1,hostname2,hostname3 --slaves 4 --client-threads 2
278 ```
279
280 This starts 4 clients per host on the hosts `hostname1`, `hostname2`,
281 and `hostname3`, and each client uses two cpus (threads). For
282 hostnames that are not `localhost`, ssh is used to connect to the host
283 and start a client there. To configure ssh, see the [next
284 section](#check-that-your-ssh-configuration-is-correct). For tasks
285 that use the local machine only (not massively distributed tasks), the
286 number of threads used is the one given by `-t` (which defaults to all
287 threads on the local machine).
288
289 * For larger computations where work distribution is an important point
290 (distribution on several machines, possibly with different parameters
291 for different machines), it is considerably more flexible to let the
292 server be _just_ a server, and start clients separately, that will be
293 used to offload the distributed tasks (polynomial selection and
294 relation collection). Clients can come and go. The server has plenty
295 of timeout provisions to deal with such events.
296
297 This is called the `--server` mode (see
298 [`scripts/cadofactor/README.md`](scripts/cadofactor/README.md) and
299 [`scripts/cadofactor/parameters`](scripts/cadofactor/parameters)).
300 See also [this thread](https://lists.gforge.inria.fr/pipermail/cado-nfs-discuss/2020-March/001168.html) on the old `cado-nfs-discuss` list (it's been [replaced](#contact-links)). If you want to use cado-nfs even to a little extent, we recomment that you familiarize with this mode of operation.
301
302 * For much larger computations, the `cado-nfs.py` is only of moderate
303 use. The individual cado-nfs binaries and internal scripts are the
304 most flexible entry points, and should be used in order to adapt to
305 the specificities of the platform being used (e.g. to deal with
306 various requirements such as memory for filtering, interconnect for
307 linear algebra, and so on).
308
309Check that your network configuration is correct:
310=================================================
311
312In case you run a factorization on the local machine, the clients should be able
313to connect to the server. Under Linux, CADO-NFS uses 'localhost' to identify the
314server, thus you should have the following line in your /etc/hosts file:
315
316```
317127.0.0.1 localhost
318```
319
320Check that your SSH configuration is correct:
321=============================================
322
323The master script (unless in `--server` mode) uses SSH to connect to
324available computing resources. In order to avoid the script asking your
325password or passphrase, you must have public-key authentication and an
326agent.
327
328The SSH keys are usually installed in the files `~/.ssh/id_rsa` and
329`~/.ssh/id_rsa.pub`; if you don't have them yet, you can create them with the
330`ssh-keygen` command. See the man page `ssh-keygen(1)` for details. The private
331key should be protected with a passphrase, which you can enter when you
332create the keys. Normally ssh will ask for the key's passphrase when you log
333on to a machine, but this can be avoided by using ssh-agent, see the man
334page `ssh-agent(1)`, and providing the passphrase to the agent with `ssh-add`.
335Public-key authenticaton together with an ssh-agent will allow `cadofactor`
336to use ssh to run commands on slave machines automatically.
337
338Most of the recent Linux distributions will run an `ssh-agent` for you. But
339if this is not the case with your distribution, or if you are running
340`cado-nfs.py` inside a `screen` in order to logout from your desktop, you
341will need to run the `ssh-agent` by hand. As a short recipe, you can type:
342```
343eval `ssh-agent`
344ssh-add
345```
346
347You should also copy your public key, i.e., the contents of the file
348`~/.ssh/id_rsa.pub`, into `$HOME/.ssh/authorized_keys` on the slave machines, to
349allow logging in with public-key authentication.
350
351Also, since localhost has an IP and key that varies, you should have
352those 3 lines in your `$HOME/.ssh/config`:
353
354```
355Host localhost
356 StrictHostKeyChecking no
357 UserKnownHostsFile /dev/null
358```
359
360If everything is correctly configured, when you type
361
362ssh localhost
363
364you should end up with a new shell on your machine, without having to
365type any password/passphrase.
366
367
368Restarting an interrupted factorization:
369========================================
370
371If you have started a factorization with the `cado-nfs.py` script, and it was
372interrupted (for example because of a power failure) you can restart in
373any of these two ways:
374
375 * with the same `cado-nfs.py` command line if a work directory was
376 explicitly provided on the command line:
377
378 ```
379 $ cado-nfs.py ... workdir=/path/to/workdir
380 ```
381
382 * with a single argument as in:
383
384 ```
385 $ cado-nfs.py [[work directory]]/XXX.parameters_snapshot.YYY
386 ```
387
388 where `[[work directory]]` is the directory which has been chosen
389 automatically, `XXX` is the "name" of the running factorisation, and `YYY`
390 is the largest possible integer value for which such a file exists.
391
392Factoring with SNFS:
393====================
394
395It is possible to take advantage of the special form of an integer and
396use the Special Number Field Sieve. See
397[`parameters/factor/parameters.F9`](parameters/factor/parameters.F9)
398for that:
399
400```
401$ cado-nfs.py parameters/factor/parameters.F9 slaves.hostnames=localhost
402```
403
404Note in particular that you can force the special-q to be on the rational
405side if this is more appropriate for your number, with
406`tasks.sieve.sqside=0` on the `cado-nfs.py` command line or in the
407parameter file (assuming side 0 is the rational side).
408
409The default square root algorithm does not work in some very rare cases
410that could possibly occur with SNFS polynomials (a degree 4 polynomial
411with Galois group $Z/2 \times Z/2$ is the only reasonable example, next
412case is for degree 8). The CRT approach is a workaround. See
413[`sqrt/crtaglsqrt.c`](sqrt/crtaglsqrt.c) .
414
415Big factorization (200 digits and more):
416========================================
417
418By default, to decrease memory usage, it is assumed that less than $2^32$
419(~ four billion) relations or ideals are needed and that the ideals will
420be less than $2^32$ (i.e., the `lpb0` and `lpb1` parameters are less or
421equal to 32). In the case of factorizations of numbers of 200 digits and
422more, these assumptions may not hold. In this case, you have to set some
423variables in your `local.sh` script (see Configure section above for more
424information on `local.sh` and section on big factorizations in
425`local.sh.example`).
426
427Factoring with two non-linear polynomials:
428==========================================
429
430You can find a bit of information on this topic in the development
431version, in the GIT repository (see file
432[`README.nonlinear`](README.nonlinear)).
433
434Importing polynomials or relations:
435===================================
436
437If you have already computed a good polynomial and/or relations, you can
438tell CADO-NFS to use them, see
439[`scripts/cadofactor/README.md`](scripts/cadofactor/README.md).
440
441Using CADO-NFS under Windows:
442=============================
443
444Portability of CADO-NFS on Windows was not an initial goal of that project,
445however we give here some hints that might help people wanting to use CADO-NFS
446under Windows. We hope that the following information can be useful to
447some extent, but the general message is that you're on your own.
448
449* Cado-NFS uses the POSIX interface all over the place, which means that
450 in one form of the other, you need to have the corresponding
451 functionality. If you don't, you're out of luck. (e.g., cado-nfs cannot
452 build as a "pure" visual studio project.)
453
454* if you only need the siever to run on Windows, then you only need to compile
455 the `las` program on Windows.
456
457* [Cygwin](http://www.cygwin.com/) provides a Unix-like environment,
458 where compilation should be easy. However the binary requires a
459 `cygwin.dll` file. We have been told of problems with shared libraries,
460 which the following seems to address:
461 ```
462 PATH="installed/lib/cado-nfs-x.y.z:$PATH" ./cado-nfs.py [...]
463 ```
464
465* if you want a binary without any dependency, you might try
466 [MinGW](http://www.mingw.org/). The INSTALL file from GNU MPFR contains
467 detailed instructions on how to compile MPFR under Windows. Those
468 instructions should work for CADO-NFS too. See
469 [`dev_docs/howto-MinGW.txt`](dev_docs/howto-MinGW.txt).
470
471* you might try to use MPIR (<http://mpir.org/>) instead of GMP. MPIR
472 is a fork of GMP, which claims to be more portable under Windows.
473 Alternatively, Windows ports of GMP shouldn't be too hard to find.
474
475* you might succeed in compiling the cado-nfs binaries with a
476 cross-compiler for Windows (which does not waive the runtime
477 requirements for `cado-nfs.py`, notably on unix-like utilities). See
478 [`dev_docs/README.cross`](dev_docs/README.cross) in the source code
479 repository for information on how to cross-compile.
480
481Examples of basic usage:
482========================
483
484* Run a full factorization on the local machine, using all available
485 cores:
486
487```
488./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693
489```
490
491* Run a full factorization on the local machine, using all available
492 cores, but with a slightly modified set of default parameters.
493
494 The difficulty here is that when `cado-nfs.py` uses a parameter file
495 supplied on the command line, it does not automatically insert into the
496 parameter set the options that are necessary for running jobs.
497 Therefore, we need to add these options:
498
499```
500./cado-nfs.py --parameters ./parameters/factor/params.c60 90377629292003121684002147101760858109247336549001090677693 slaves.hostnames=localhost slaves.nrclients=2
501```
502
503* Run a full factorization on the local machine, using 8 threads for the
504 server (this includes the linear algebra), and 4 jobs of 2 threads
505 each for the polynomial selection and the sieving:
506
507```
508./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 --slaves 4 --client-threads 2 --server-threads 8
509```
510
511* Run a factorization in the given directory, interrupt it (with Ctrl-C,
512 or whatever unexpected event), and resume the computation:
513
514```
515./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 workdir=/tmp/myfacto
516[Ctrl-C]
517./cado-nfs.py /tmp/myfacto/c60.parameters_snapshot.0
518```
519
520* Run a server on `machine1`, and a slave on `machine2`, disabling ssl:
521
522```
523machine1$ ./cado-nfs.py --server 90377629292003121684002147101760858109247336549001090677693 server.port=4242 server.ssl=no server.whitelist=machine2
524machine2$ ./cado-nfs-client.py --server=http://machine1:4242 --bindir=...
525```
526
527Note: if you are on an insecure network, you'll have to activate ssl, and
528then pass the appropriate sha1 certificate to the client (the server
529prints the appropriate command-line to be copy-pasted on `machine2`).
530
531* Run a factorization on `machine1`, and have it start automatically a
532 slave on `machine2` via SSH:
533
534```
535./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693
536slaves.hostnames=machine1,machine2
537```
538
539Note that, in that case, you have to specify `machine1` as well in the list
540of `hostnames` if you want it to contribute to the polynomial selection and
541the sieving.
542
543
544Stopping the factorization during a specific step:
545==================================================
546It is possible to stop the factorization:
547
548```
549./cado-nfs.py 90377629292003121684002147101760858109247336549001090677693 tasks.xxxx.run=false
550```
551
552This command works with: xxxx = polyselect, sieve, filter, linalg
553
554
555Known problems:
556===============
557
558(some of these problems refer to versions or operating systems that are
559no longer supported by cado-nfs anyway)
560
561* when running the square root step in multi-thread mode (tasks.sqrt.threads=2
562 or larger) with GMP <= 6.0, you might encounter an issue due to a "buglet"
563 in GMP (<https://gmplib.org/list-archives/gmp-bugs/2015-March/003607.html>).
564 Workaround: use tasks.sqrt.threads=1 or GMP >= 6.1.0.
565* GCC 4.1.2 is known to miscompile CADO-NFS (see
566 <http://cado-nfs.gforge.inria.fr/bug.php?14490>),
567 GCC 4.2.0, 4.2.1 and 4.2.2 are also affected.
568* under NetBSD 5.1 amd64, Pthreads in the linear algebra step seem not to
569 work, please use `-t 1` option in `cado-nfs.py` or `tasks.linalg.threads=1x1`.
570* under AIX, if GMP is compiled in 64-bit mode, you should set the
571 environment variable `OBJECT_MODE`, for example:
572 export `OBJECT_MODE=64`
573* if you encounter the error "Exceeded maximum number of failed workunits,
574 maxfailed=100", you can restart the factorization with
575 `tasks.maxfailed=200`. But it would be wise, first, to try to
576 understand _why_ workunits are failing. This should not appear. It
577 might be that all your workunits are timing out, because your `adrange`
578 and `qrange` parameters are too large. Or it's a bug in cado-nfs, and
579 then it should definitely be reported.
580
581
582Contact, links:
583===============
584
585The website of the project is hosted at:
586 <http://cado-nfs.gforge.inria.fr/>
587
588You can get the latest development version with:
589```
590git clone https://gitlab.inria.fr/cado-nfs/cado-nfs.git
591```
592or
593```
594git clone git@gitlab.inria.fr:cado-nfs/cado-nfs.git
595```
596(use the latter if you have an account on Inria gitlab, and commit access
597to cado-nfs)
598
599There is now a unique mailing-list associated to Cado-nfs
600[cado-nfs@inria.fr](https://sympa.inria.fr/sympa/info/cado-nfs). Please
601do not use the old `cado-nfs-discuss` mailing list, the infrastructure
602that hosts this mailing list is set for removal in 2021.
603
604If you find a bug, if you have a problem compiling cado-nfs, if you want to
605factor a large number and seek for advice for tuning the parameters, then
606the cado-nfs-discuss list is the right place to ask.
607
608On the <https://gitlab.inria.fr/cado-nfs/cado-nfs> web page you can also
609find the cado-nfs bug tracker (a.k.a project issues). The bug tracker is
610an important piece of the cado-nfs development cycle. Submitting bugs
611and merge requests there is welcome (you need an Inria gitlab account),
612although if you are unsure, it might be better to speak up on the
613cado-nfs-discuss mailing list first.
614
README.msieve
1Instructions on how to use CADO-NFS with msieve
2===============================================
3
4Summary:
5
6I) Using CADO-NFS with relations computed with msieve (or ggnfs)
7II) Using msieve filtering and linear algebra with relations in CADO format
8III) Using msieve linear algebra after CADO-NFS filtering
9
10==============================================================================
11
12I) Using CADO-NFS with relations computed with msieve (or ggnfs)
13
14The format of relations used by CADO-NFS is the same as the one used by ggnfs
15or msieve.
16
17IMPORTANT NOTE: free relations should not be included. To remove them,
18first do: $ egrep -v '^[0-9]+,0$' relations > relations_fixed
19
200) You need to work with a git checkout of CADO-NFS, as it contains
21 utility code that is not present in tarballs (see main README for the
22 git clone command line).
23
241) First, convert the polynomial from Msieve format to CADO format using:
25 $ make convert_poly
26 $ build/<hostname>/misc/convert_poly -if msieve < input.poly > output.poly
27
282) Since ggnfs doesn't print prime factors under 10000, and CADO-NFS requires
29 all prime factors, you will need to complete all relations files that are in
30 ggnfs or msieve format using:
31
32 $ build/<hostname>/misc/check_rels -complete rels.out.gz -poly <polyfile> file0 file1 ... filen
33 or
34 $ build/<hostname>/misc/check_rels -complete rels.out.gz -poly <polyfile> -filelsit <filelist>
35 where <filelist> is a name of a file containing the list of all
36 relations files
37
38 See check_rels -h for others options.
39
403) Create a parameter file for the Python script: in the scripts/cadofactor
41directory, see the files 'parameters' and 'README'. In the README file, read
42thoroughly the section on importing polynomial file and importing relations.
43You can also look in the 'params' directory for examples of parameter files
44depending on the size of the input.
45
464) run the cado-nfs.py script (where $CADO is the CADO-NFS directory):
47
48 $ $CADO/cado-nfs.py <parameterfile>
49
50If the parameter file is correctly configured, the script will skip the
51polyselect step and the sieving. It will run all the remaining step of the
52factorization until the factors are found.
53
54NB: If you only want to do the filtering step, add the following command-line
55arguments:
56
57 $ $CADO/cado-nfs.py <parameterfile> 'tasks.linalg.run = false' 'tasks.sqrt.run = false'
58
59==============================================================================
60
61II) Using msieve filtering and linear algebra with relations in CADO format
62
631) Create a file msieve.fb, which contains:
64
65 N <number to be factored>
66 R0 <coeff of x^0, rational side>
67 R1 <coeff of x^1, rational side>
68 A0 <coeff of x^0, algebraic side>
69 A1 <etc>
70 A2 <etc>
71 A3 <etc>
72 A4 <etc>
73 A5 <etc>
74
75 This can be done with:
76
77 $ ./convert_poly -of msieve < cxxx.poly > msieve.fb
78
792) create a file msieve.dat, which contains:
80
81 N <number to be factored>
82 <all the relations in GGNFS/CADO format>
83
84 (Do not include free relations, since the CADO-NFS format is not
85 recognized by msieve, and msieve includes them in the filtering.)
86
873) then run "msieve -nc -v <number to be factored>"
88 The msieve output goes into msieve.log.
89 You can add the "-t 4" option to use 4 threads.
90
91==============================================================================
92
93III) Using msieve linear algebra after CADO-NFS filtering
94
95[should work with CADO-NFS revision aca5658]
96
97up from msieve (svn) revision 891, msieve can read a cycle file produced by
98CADO-NFS. To use it, you will have to:
99
100- use CADO-NFS for the filtering. In what follows, let 'prefix' be
101 the prefix used for all the CADO filenames
102- use the CADO 'replay' binary with --for_msieve to produce
103 a file <prefix>.cyc
104- concatenate all the relation files specified by purge.log in
105 the order specified, and name the file <prefix> in the same
106 directory as all the other CADO intermediate files. If Msieve was
107 compiled with zlib support, the files do not have to be uncompressed
108- create a <prefix>.fb file with the polynomials in Msieve format
109- create worktodo.ini with a single line containing N
110- run Msieve LA with
111
112 -v -nf <prefix>.fb -s <prefix> -nc2 "cado_filter=1"
113
114The string at the end may get extra options depending on whether
115the LA has more tweaking, like using MPI. The .cyc file gets
116overwritten during the LA, so re-running the LA does not require
117cado_filter=1.
118
119
120
121
README.nonlinear
1This file explains how to factor a number with two non linear polynomials.
2This is currently experimental in CADO-NFS.
3
4Assume for example we want to factor the following 59-digit number:
5
6n = 71641520761751435455133616475667090434063332228247871795429
7
8with the two quadratics below (found by Thomas Prest using Montgomery's two
9quadratics method, see polyselect/twoquadratics.c):
10
11f = 215609964539787*x^2 + 75006949764904*x + 44337721223995
12g = -205964131819700*x^2 - 71651332635517*x + 1199051061668898
13skew = 1.29196058385
14m = 14849204829709953721577291784724593124898329527333780861554
15(m is the common root of f and g mod n.)
16
171) you first have to create a polynomial file, see for example the one in
18 tests/misc/c59_nonlinear.poly:
19
20$ cat tests/misc/c59_nonlinear.poly
21n: 71641520761751435455133616475667090434063332228247871795429
22skew: 1.29196058385
23c0: 44337721223995
24c1: 75006949764904
25c2: 215609964539787
26Y0: 1199051061668898
27Y1: -71651332635517
28Y2: -205964131819700
29
302) run cado-nfs.py with importing this polynomial:
31
32$ ./cado-nfs.py 71641520761751435455133616475667090434063332228247871795429 tasks.polyselect.import=tests/misc/c59_nonlinear.poly
33