mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   EdH (https://www.mersenneforum.org/forumdisplay.php?f=152)
-   -   How I Install ggnfs onto my Ubuntu Machines (https://www.mersenneforum.org/showthread.php?t=23081)

EdH 2018-02-22 03:31

How I Install ggnfs onto my Ubuntu Machines
 
2 Attachment(s)
(Note: I expect to keep the first post of each of these "How I Install..." threads up-to-date with the latest version. Please read the rest of each thread to see what may have led to the current set of instructions.)

This thread will explain the steps I use to install* ggnfs onto a computer which is already running Ubuntu. This procedure should work for other linux distributions as well but the only other one I've currently tested is Debain.

*In this instance "install" is referring to the acquiring and compilation of the ggnfs package only. The binaries will have to be called using their respective paths.

I will expect the user of these steps to be able to use the sudo command.

I will use a directory called Math for these installations. You may elect to replace "Math" with your own choice.

These instructions can be used as a reference only, if you want, but I will provide specifics that work for me. If you follow these steps as I provide them, you should end up with a working installation.

First, follow the procedures in:

[URL="http://www.mersenneforum.org/showthread.php?t=23079"] How I Install GMP on my Ubuntu Machines[/URL]
and
[URL="http://www.mersenneforum.org/showthread.php?t=23080"]How I Install GMP-ECM on my Ubuntu Machines[/URL]

or, install GMP and ECM from the repositories. If you use the repositories, check to see if ECM is called ecm or gmp-ecm. You can try:
[code]
which ecm
[/code]If it returns something like /usr/local/bin/ecm, then it is called ecm.

In the case of the ggnfs sievers, you don't need to perform the following step if you are planning to use the already available binaries referenced below. I would, however, create a folder named ggnfs within the Math folder and then a bin folder within the ggnfs folder, in which to place the binaries. If you do perform the next two steps, the folders will be created.

If you have already installed the following packages, you can skip the next two steps, although performing them wouldn't hurt anything.

Open a terminal and Enter:
[code]
sudo apt-get update
[/code]You should be prompted for your password. This prompt should only appear once for your terminal session, unless you leave it idle for a long time.

After the update completes and the user prompt reappears, type:
[code]
sudo apt-get install g++ m4 zlib1g-dev make p7zip
[/code]Accept the prompt.

(optional) Go to the following link:

[URL="https://github.com/radii/ggnfs"](optional) GPL Number Field Sieve implementation[/URL]

(optional) Click on Clone or download and choose Download ZIP. Move the ggnfs-master.zip file to your Math folder.

Go to the following link:

[URL="https://sites.google.com/site/bbuhrow/lasieve4_64.7z?attredirects=0"]Download B[SUP]2[/SUP] Sievers[/URL] [B]Note:[/B] This link is currently broken. Until it is working again, the file can be found attached to this post.

Download the attachment and place it in the Math folder.

If you have downloaded the ggnfs-master.zip file, at this point extract the folder into the Math folder and rename it to ggnfs.

Finally, for now, extract the lasieve4_64.7z files into the Math/ggnfs/bin folder.

Using the files window, select all six sievers that you extracted and right click on them. Choose Properties->Permissions and look for the "Allow executing files as program" checkbox. Click this until a checkmark is displayed. (It usually takes two clicks if doing all sievers at once.)

At this point, you should have a pretty good working version of the ggnfs package for all your sieving needs. However, if you want to get a little bit better, you can compile a set of sievers adjusted for your particular hardware. Here's what you do:

In a terminal move into the appropriate folder:
[code]
cd ~/Math/ggnfs/src/experimental/lasieve4_64
[/code]Apply the following patches to the appropriate files within the athlon64 folder:
[B]Note:[/B] The appropriate files with patches applied (and the example testPoly) are attached as a .tar.xz file.

[code]
Index: athlon64/mpqs_td.asm
===================================================================
--- athlon64/mpqs_td.asm (revision 441)
+++ athlon64/mpqs_td.asm (working copy)
@@ -290,7 +290,7 @@
mull %ecx
testl %edx,%edx
jnz tdloop
- cmpw $27,nr
+ cmpw $27,nrw
jnc gotonext
movl aux4d,%eax
movw aux5w,10(relptr,nr,2)
@@ -321,10 +321,10 @@
mull %ecx
testl %edx,%edx
jnz tdloopk
- cmpw $27,nr
+ cmpw $27,nrw
jnc gotonext
movl aux4d,%eax
- movw nr1,10(relptr,nr,2)
+ movw nr1w,10(relptr,nr,2)
incq nr
movl aux4d,qxd
jmp divloopk
@@ -354,7 +354,7 @@
testl %edx,%edx
jnz tdloopa
movl aux4d,%eax
- cmpw $27,nr
+ cmpw $27,nrw
jnc gotonext
addw nr1w,aux5w
movw aux5w,10(relptr,nr,2)
Index: athlon64/tdslinie.asm
===================================================================
--- athlon64/tdslinie.asm (revision 441)
+++ athlon64/tdslinie.asm (working copy)
@@ -10,6 +10,7 @@
define(sieve_ptr,%r8)dnl
define(sieve_ptr_ub,%r9)dnl
define(root,%r10)dnl
+define(rootw,%r10w)dnl
define(prime,%r11)dnl
define(prime32,%r11d)dnl
define(sv0,%al)dnl
@@ -115,7 +116,7 @@
tdslinie_next_j`'i:
')
cmpq aux_ptr,aux_ptr_ub
- movw root,root_src
+ movw rootw,root_src
leaq 8(aux_ptr),aux_ptr
ja tdslinie_fbi_loop
tdslinie_ende:
Index: athlon64/tdslinie1.asm
===================================================================
--- athlon64/tdslinie1.asm (revision 441)
+++ athlon64/tdslinie1.asm (working copy)
@@ -10,6 +10,7 @@
define(sieve_ptr,%r8)dnl
define(sieve_ptr_ub,%r9)dnl
define(root,%r10)dnl
+define(rootw,%r10w)dnl
define(prime,%r11)dnl
define(prime32,%r11d)dnl
define(sv0,%al)dnl
@@ -58,7 +59,7 @@
jnz tdslinie1_suche
tdslinie1_nextfbi:
cmpq aux_ptr,aux_ptr_ub
- movw root,root_src
+ movw rootw,root_src
leaq 8(aux_ptr),aux_ptr
ja tdslinie1_fbi_loop
tdslinie1_ende:
Index: athlon64/tdslinie2.asm
===================================================================
--- athlon64/tdslinie2.asm (revision 441)
+++ athlon64/tdslinie2.asm (working copy)
@@ -10,6 +10,7 @@
define(sieve_ptr,%r8)dnl
define(sieve_ptr_ub,%r9)dnl
define(root,%r10)dnl
+define(rootw,%r10w)dnl
define(prime,%r11)dnl
define(prime32,%r11d)dnl
define(sv0,%al)dnl
@@ -57,7 +58,7 @@
jnz tdslinie2_suche
tdslinie2_next_fbi:
cmpq aux_ptr,aux_ptr_ub
- movw root,root_src
+ movw rootw,root_src
leaq 8(aux_ptr),aux_ptr
ja tdslinie2_fbi_loop
tdslinie2_ende:
Index: athlon64/tdslinie3.asm
===================================================================
--- athlon64/tdslinie3.asm (revision 441)
+++ athlon64/tdslinie3.asm (working copy)
@@ -7,6 +7,7 @@
define(sieve_ptr,%r8)dnl
define(sieve_ptr_ub,%r9)dnl
define(root,%r10)dnl
+define(rootw,%r10w)dnl
define(prime,%r11)dnl
define(prime32,%r11d)dnl
define(sv0,%al)dnl
@@ -73,7 +74,7 @@
tdslinie3_next_j`'i:
')
cmpq aux_ptr,aux_ptr_ub
- movw root,root_src
+ movw rootw,root_src
leaq 8(aux_ptr),aux_ptr
ja tdslinie3_fbi_loop
tdslinie3_ende:
[/code]Edit the Makefiles within the lasieve4_64 and athlon64 folders to change four k8s to native:
[code]
...
CFLAGS=-O3 -march=k8 -mtune=k8 -funroll-loops
...
[/code]to[code]
...
CFLAGS=-O3 -march=native -mtune=native -funroll-loops
...
[/code]and
[code]
...
CFLAGS= -O3 -march=k8 -mtune=k8 -I.
...
[/code]to[code]
...
CFLAGS= -O3 -march=native -mtune=native -I.
...
[/code]Open the INSTALL file within the lasieve4_64 folder and perform its set of instructions:
[code]
cd athlon64
make liblasieve.a
make liblasieveI11.a
make liblasieveI12.a
make liblasieveI13.a
make liblasieveI14.a
make liblasieveI15.a
make liblasieveI16.a
cp *.a ..
cd ..
ln -s athlon64 asm
make
[/code]Watch each command to see if any errors appear. When the last make completes you will have the following sievers in the lasieve4_64 folder:
[code]
gnfs-lasieve4I11e
gnfs-lasieve4I12e
gnfs-lasieve4I13e
gnfs-lasieve4I14e
gnfs-lasieve4I15e
gnfs-lasieve4I16e
[/code]Copy or move the above six files into your Math/ggnfs/bin folder, replacing the bsquared sievers, if necessary.

Now, it might be a good idea to test them and see if they run:. In a terminal, move to the Math/ggnfs/bin folder:
[code]
cd ~/Math/ggnfs/bin
[/code]Create a sub-folder named testing:
[code]
mkdir testing
[/code]Change to the testing folder:
[code]
cd testing
[/code]Open a new file named testPoly using gedit:
[code]
gedit testPoly
[/code]Copy the following polynomial lines into the testPoly file:
[B]Note:[/B] This example testFile and the patched files from above are attached as a .tar.xz file.
[code]
n: 43715356796662829480745706047096704236720281338579999122488910362081610277175300878318314702043387129927
c4: 72
c3: 4312584054
c2: -8166581306957591
c1: -129446911934909498991070
c0: 170042303764543493053291724775
Y1: 38904204455749
Y0: -27913630115707931572790246
skew: 9145923.32
rlim: 2300000
alim: 1149999
lpbr: 26
lpba: 26
mfbr: 49
mfba: 49
rlambda: 2.6
alambda: 2.6
q0: 2300000
qintsize: 2500
#q1:1152500
#lasieve4I12e
[/code]Save and close the gedit window and on the command line enter:
[code]
../gnfs-lasieve4I12e -a -v -o testRels testPoly
[/code]You should see the following:
[code]gnfs-lasieve4I12e (with asm64): L1_BITS=15, SVN $Revision$
FBsize 89232+0 (deg 4), 169510+0 (deg 1)
total yield: 9851, q=2301199 (0.00376 sec/rel)
[/code]with the numbers increasing. Eventually you will see the completion:
[code]
total yield: 17861, q=2302511 (0.00375 sec/rel)
172 Special q, 264 reduction iterations
reports: 62453230->7087009->6511990->2180263->1522185->903714
Number of relations with k rational and l algebraic primes for (k,l)=:

Total yield: 17861
0/0 mpqs failures, 3273/1395 vain mpqs
milliseconds total: Sieve 18036 Sched 0 medsched 12013
TD 19677 (Init 1698, MPQS 6284) Sieve-Change 17330
TD side 0: init/small/medium/large/search: 488 1530 688 768 3617
sieve: init/small/medium/large/search: 944 4403 607 2354 1140
TD side 1: init/small/medium/large/search: 159 1174 630 794 1734
sieve: init/small/medium/large/search: 517 2780 597 2400 2294
[/code]


All times are UTC. The time now is 12:14.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.