mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > GMP-ECM

Reply
 
Thread Tools
Old 2015-03-06, 21:19   #67
Antonio
 
Antonio's Avatar
 
"Antonio Key"
Sep 2011
UK

32×59 Posts
Default

Quote:
Originally Posted by WraithX View Post
A big thanks to casevh for suggesting and Antonio for verifying this solution. I've decided to simplify the code a bit and have put the eval(n.replace('^', '**').replace('/', '//')) in the num_digits function, so now the use of num_digits looks like: format(ecm_n, num_digits(ecm_n)). This looks a lot cleaner, and any future changes can be made in one place.

Here is the updated version, ecm.py v0.33.
Glad to be of service, thanks for the update.
Antonio is offline   Reply With Quote
Old 2015-03-09, 19:30   #68
Antonio
 
Antonio's Avatar
 
"Antonio Key"
Sep 2011
UK

32·59 Posts
Default

Is there a way to specify B1 AND B2 when using the python script?
The standard ECM command line doesn't work.

Code:
F:\ECM>ecm.py -maxmem 12288 -inp num2ecm.txt -c 2100 250000 425000000
-> ___________________________________________________________________
-> | Running ecm.py, a Python driver for distributing GMP-ECM work   |
-> | on a single machine.  It is copyright, 2011-2015, David Cleaver |
-> | and is a conversion of factmsieve.py that is Copyright, 2010,   |
-> | Brian Gladman. Version 0.33 (Python 2.6 or later)  5th Mar 2015 |
-> |_________________________________________________________________|
inp_file = num2ecm.txt
-> Number(s) to factor:
-> (85*2^67652-1)/(3*924972809) (20358 digits)
->=============================================================================
-> Working on number: (85*2^67652-1)/(3*924972809) (20358 digits)
-> Currently working on: job4826.txt
-> Starting 3 instances of GMP-ECM...
-> ecm 250000 -c 700 -maxmem 4096 425000000 < job4826.txt > job4826_t00.txt
-> ecm 250000 -c 700 -maxmem 4096 425000000 < job4826.txt > job4826_t01.txt
-> ecm 250000 -c 700 -maxmem 4096 425000000 < job4826.txt > job4826_t02.txt
Invalid B2 value: -c
Invalid B2 value: -c
Invalid B2 value: -c
GMP-ECM 7.0-dev [configured with GMP 6.0.0, --enable-asm-redc] [ECM]
-> *** Error: unexpected return value: 1
Antonio is offline   Reply With Quote
Old 2015-03-15, 19:16   #69
WraithX
 
WraithX's Avatar
 
Mar 2006

7308 Posts
Default Announcing ecm.py v0.34...

Quote:
Originally Posted by Antonio View Post
Is there a way to specify B1 AND B2 when using the python script?
The standard ECM command line doesn't work.
Code:
F:\ECM>ecm.py -maxmem 12288 -inp num2ecm.txt -c 2100 250000 425000000
Thank you for putting ecm.py through its paces! It should be possible to specify both B1 and B2 now.

Announcing ecm.py v0.34:
Code:
New features:
 - Can now specify both B1 and B2 (B2 is optional, if not specified gmp-ecm will choose a value)
 - Can now echo numbers from the command line into ecm.py, like so:
      echo <num> | python.exe ecm.py [gmp-ecm options] [ecm.py options] B1 [B2]

And as a reminder, ecm.py can be used in any of the following three ways:
USAGE: python.exe ecm.py [gmp-ecm options] [ecm.py options] B1 [B2] < <in_file>
  or: echo <num> | python.exe ecm.py [gmp-ecm options] [ecm.py options] B1 [B2]
  or: ecm.py -inp <in_file> [gmp-ecm options] [ecm.py options] B1 [B2]
    where <in_file> is a file with the number(s) to factor (one per line)
Attached Files
File Type: zip ecm-py_v0.34.zip (14.9 KB, 141 views)
WraithX is offline   Reply With Quote
Old 2016-06-08, 04:32   #70
cgy606
 
Feb 2012

32·7 Posts
Default

Quote:
Originally Posted by WraithX View Post
Ok, I have what appears to be a working version of this driver ready. This release will be version 0.01, but hopefully it will function well for everyone. Like factMsieve.py, this requires Python 2.6 or higher to run. Here are some notes about its use. A typical command line will look like one of the following:

D:\Programming\python\ecm_py>c:\python26\python.exe ecm.py -c 100 -one -maxmem 1500 -threads 2 -out all_out.txt 1000000 < test2.txt
or
D:\Programming\python\ecm_py>echo 189137687020123159261852192605885322671854225839439913905089 | c:\python26\python.exe ecm.py -c 100 -one -maxmem 1500 -threads 2 -out all_out.txt 1000000

The command line has to have /path/to/python.exe before ecm.py. This is needed because of a limitation in Windows (possibly Linux also) where just writing ecm.py will not allow redirection to work properly. This seems to be based on a mishandling of starting python scripts through file associations. However, if the program is called as python.exe ecm.py (if python is in your path), or /path/to/python.exe ecm.py, redirection will work correctly. This includes both piping-in (echo ... | python ecm.py) and file redirection (python ecm.py ... < num.txt).

You can use all the standard gmp-ecm command line options.
If you use -c N (run N curves), then each gmp-ecm instance will get -c (N/num_threads) curves to run, with the first few instances running more if that division is not exact.
If you use -maxmem N (limit ecm.exe memory usage in Stage 2 to < N MB of memory), then each instance of gmp-ecm will use only -maxmem (N/num_threads) to make sure that the total memory used by all instances of gmp-ecm doesn't go over your limit.

When this script is factoring a number, it creates a job file representing how much work you've asked to complete on that number. It also keeps track of how many curves have been run on this number, and timings to help you know how long each stage is taking on average. Each instance of gmp-ecm will write to its own file. The script monitors these files to see how much work has been done, and updates a counter on the screen to let you know how far along the job is.

The script has an auto-resume feature. If the job is interrupted by a power outage or with Ctrl-C, you don't have to worry about losing work. The next time you start up the job with the same command line on the same number, it will read in the old job files to see how much work had been done, and then pick up where it left off. If you turn off auto-resume, the script won't check for previous runs, it will just start a new job.

Here are the options available that are specific to the script:
-threads N This will run N copies of gmp-ecm on the input number(s) you specify.
-r <file> Resume the specified job file. After finishing this job, the script will stop.
-out <file> Save work done (on all input numbers) to the specified file.

These command line options can be intermixed with regular gmp-ecm command line options. Also, please make sure that B1 is the last option in your ecm command line. If not, the program will not behave as expected. In future releases I think I can post a proper error if B1 isn't the last option, but for now, a correct command line should work as expected.

Before running, please set the path to your gmp-ecm executable. You can also set a default number of threads to use if you dont' want to specify that on the command line. Also, you can run multiple copies of this script in the same directory. There shouldn't be any collisions between separate jobs being run.

If anyone is interested in running this, I'd like to hear how well it works for you. If you encounter a problem, I can try to find a solution and post updated versions as I have time. Now, let the fun begin!
Hi WraithX,

I was wondering if you (or somebody else) could help me running the python script. So I am using python 2.6 for Mac OSX Yosemite 10.10.5. I have gmp-ecm 7.0 installed and the python script ecm.py in the same folder. I am running the python script using the command:

bash-3.2$ echo "2^521-1" | python ecm.py -c 100 -threads 2 1000000
-> ___________________________________________________________________
-> | Running ecm.py, a Python driver for distributing GMP-ECM work |
-> | on a single machine. It is copyright, 2011-2015, David Cleaver |
-> | and is a conversion of factmsieve.py that is Copyright, 2010, |
-> | Brian Gladman. Version 0.34 (Python 2.6 or later) 14th Mar 2015 |
-> |_________________________________________________________________|

-> Number(s) to factor:
-> 2^521-1 (157 digits)
-> Could not find the program: ./Users/cgy606/Documents/yafu/ecm-7.0./ecm
-> Did you set the path properly in this script?
-> It is currently set to:
-> ECM_BIN_PATH = ./Users/cgy606/Documents/yafu/ecm-7.0

Apparently their is an issue with the ecm binary path. However, ecm 7.0 does work:

bash-3.2$ echo "2^521-1" | ecm -c 2 1000000
GMP-ECM 6.4 [configured with GMP 6.0.0, --enable-asm-redc] [ECM]
Input number is 2^521-1 (157 digits)
Using B1=1000000, B2=1045563762, polynomial Dickson(6), sigma=3061204579
Step 1 took 6590ms
Step 2 took 3210ms
Run 2 out of 2:
Using B1=1000000, B2=1045563762, polynomial Dickson(6), sigma=717933293
Step 1 took 6671ms
Step 2 took 3162ms

Although it says gmp-ecm 6.4, I downloaded the latest version. Any thoughts on how to get this to work?
cgy606 is offline   Reply With Quote
Old 2016-06-08, 04:58   #71
VBCurtis
 
VBCurtis's Avatar
 
"Curtis"
Feb 2005
Riverside, CA

29·149 Posts
Default

Did you compile the new ECM, or just download the files? Your second invocation does not indicate what folder you are in when invoking ecm, so I can't tell if that old ECM binary is located in a different folder. Seems likely, since it's 6.4.
VBCurtis is offline   Reply With Quote
Old 2016-06-08, 05:16   #72
cgy606
 
Feb 2012

32·7 Posts
Default

Quote:
Originally Posted by VBCurtis View Post
Did you compile the new ECM, or just download the files? Your second invocation does not indicate what folder you are in when invoking ecm, so I can't tell if that old ECM binary is located in a different folder. Seems likely, since it's 6.4.
Okay, so I was able to configure by running that script, now I tried to run install-sh:

bash-3.2$ ls
AUTHORS addlaws.h config.log ecm.c libtool pentium4 stamp-h1
COPYING aprtcle config.m4 ecm.h listz.c pm1.c stamp-h2
COPYING.LIB arm config.status ecm.h.in longlong.h pm1fs2.c test.ecm
ChangeLog athlon config.sub ecm.py ltmain.sh polyeval.c test.pm1
Fgw.c auxarith.c configure ecm.xml lucas.c powerpc32 test.pp1
INSTALL auxi.c configure.ac ecm2.c m4 powerpc64 test_mulredc.c
INSTALL-ecm auxlib.c cudakernel.cu ecm_int.h main.c pp1.c testlong.ecm
M877.save b1_ainc.c cudakernel.h ecm_ntt.c median.c prime95.save testlong.pm1
M997.save basicdefs.h cudawrapper.c ecm_py.log memusage.c random.c testlong.pp1
Makefile batch.c depcomp ecmfactor.c mips resume.c torsions.h
Makefile.am bench_mulredc.c dummy.save eval.c missing rho.c tune.c
Makefile.in bestd.c dummy2.save factor.c mpmod.c schoen_strass.c x86
NEWS c155 ecm-ecm.h generic mpmod.h sets_long.c x86_64
README candi.c ecm-gmp.h getprime_r.c mpzspm.c sp.c
README.lib champions.h ecm-gpu.h getprime_r.h mpzspv.c sp.h
TODO compile ecm-impl.h hppa mul_lo.c sparc64
Z2102.n config.guess ecm-params.h ia64 ntt_gfp.c spm.c
acinclude.m4 config.h ecm-py_v0.34.zip install-sh numbers.txt spv.c
aclocal.m4 config.h.in ecm.1 ks-multiply.c parametrizations.c stage2.c
bash-3.2$ ./install-sh
./install-sh: no input file specified.
bash-3.2$ sh install-sh
install-sh: no input file specified.
bash-3.2$ sh INSTALL
INSTALL: line 1: Installation: command not found
INSTALL: line 2: AUTHORS: command not found
INSTALL: line 4: syntax error near unexpected token `C'
INSTALL: line 4: `Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,'
bash-3.2$ sh INSTALL-ecm
INSTALL-ecm: line 1: Instructions: command not found
INSTALL-ecm: line 3: syntax error near unexpected token `)'
INSTALL-ecm: line 3: `0) you first need to install the GNU MP (GMP) library.'
bash-3.2$

I pretty sure I am doing something boneheaded...
cgy606 is offline   Reply With Quote
Old 2016-06-08, 07:42   #73
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

11100001101012 Posts
Default

INSTALL is a text file. Open it and read its contents to tell you how to install GMP-ECM. It should be something like this:

Code:
./configure
make
make test
make install
Dubslow is offline   Reply With Quote
Old 2016-06-08, 08:03   #74
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

57516 Posts
Default

Quote:
Originally Posted by cgy606 View Post
However, ecm 7.0 does work:

bash-3.2$ echo "2^521-1" | ecm -c 2 1000000
GMP-ECM 6.4 [configured with GMP 6.0.0, --enable-asm-redc] [ECM]
Input number is 2^521-1 (157 digits)
I would make no (ecm) factorization work on a known Mersenne prime.
R. Gerbicz is offline   Reply With Quote
Old 2016-06-08, 15:25   #75
cgy606
 
Feb 2012

32×7 Posts
Default

Quote:
Originally Posted by Dubslow View Post
INSTALL is a text file. Open it and read its contents to tell you how to install GMP-ECM. It should be something like this:

Code:
./configure
make
make test
make install
Thanks for the help. I built gmp-ecm 7.0 (and I believe its a proper built, see the terminal output below). However, I still think there is something wrong with the path set to the ecm binaries. Has anybody actually ran this python script on a mac (or unix)?

bash-3.2$ echo "116! + 5" | ecm -c 1 1000000
GMP-ECM 7.0-rc2 [configured with GMP 6.0.0, --enable-asm-redc] [ECM]
Input number is 116!+5 (191 digits)
Using B1=1000000, B2=1045563762, polynomial Dickson(6), sigma=1:2621072992
Step 1 took 9334ms
********** Factor found in step 1: 2045
Found composite factor of 4 digits: 2045
Composite cofactor (116!+5)/2045 has 188 digits
bash-3.2$ pwd
/Users/cgy606/Documents/yafu/ecm-7.0
bash-3.2$ echo "16592218505877252817595384320726519331245298560877363179444333539424579615734146863694149619172215730904092217599971446347242578938012841662398382297100491858685120782396088019559902200489" | python ecm.py -c 16 -threads 4 1000000
-> ___________________________________________________________________
-> | Running ecm.py, a Python driver for distributing GMP-ECM work |
-> | on a single machine. It is copyright, 2011-2015, David Cleaver |
-> | and is a conversion of factmsieve.py that is Copyright, 2010, |
-> | Brian Gladman. Version 0.34 (Python 2.6 or later) 14th Mar 2015 |
-> |_________________________________________________________________|

-> Number(s) to factor:
-> 16592218505877252817595384320726519331245298560877363179444333539424579615734146863694149619172215730904092217599971446347242578938012841662398382297100491858685120782396088019559902200489 (188 digits)
-> Could not find the program: ./Users/cgy606/Documents/yafu/ecm-7.0./ecm
-> Did you set the path properly in this script?
-> It is currently set to:
-> ECM_BIN_PATH = ./Users/cgy606/Documents/yafu/ecm-7.0
cgy606 is offline   Reply With Quote
Old 2016-06-08, 21:10   #76
Dubslow
Basketry That Evening!
 
Dubslow's Avatar
 
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88

160658 Posts
Default

Edit the script and change this line:

Code:
ECM_BIN_PATH = ./Users/cgy606/Documents/yafu/ecm-7.0
to this line:

Code:
ECM_BIN_PATH = ecm
If that doesn't work, then get the shell output of which ecm and set ECM_BIN_PATH to that.
Dubslow is offline   Reply With Quote
Old 2016-06-09, 05:39   #77
cgy606
 
Feb 2012

32×7 Posts
Default

Quote:
Originally Posted by Dubslow View Post
Edit the script and change this line:

Code:
ECM_BIN_PATH = ./Users/cgy606/Documents/yafu/ecm-7.0
to this line:

Code:
ECM_BIN_PATH = ecm
If that doesn't work, then get the shell output of which ecm and set ECM_BIN_PATH to that.
That didn't work:

[code]bash-3.2$ which ecm
/usr/local/bin/ecm
bash-3.2$ echo "16592218505877252817595384320726519331245298560877363179444333539424579615734146863694149619172215730904092217599971446347242578938012841662398382297100491858685120782396088019559902200489" | python ecm.py -c 16 -threads 4 1000000
-> ___________________________________________________________________
-> | Running ecm.py, a Python driver for distributing GMP-ECM work |
-> | on a single machine. It is copyright, 2011-2015, David Cleaver |
-> | and is a conversion of factmsieve.py that is Copyright, 2010, |
-> | Brian Gladman. Version 0.34 (Python 2.6 or later) 14th Mar 2015 |
-> |_________________________________________________________________|

-> Number(s) to factor:
-> 16592218505877252817595384320726519331245298560877363179444333539424579615734146863694149619172215730904092217599971446347242578938012841662398382297100491858685120782396088019559902200489 (188 digits)
-> Could not find the program: ./usr/local/bin./ecm
-> Did you set the path properly in this script?
-> It is currently set to:
-> ECM_BIN_PATH = ./usr/local/bin
bash-3.2$
cgy606 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python Coding Help? kelzo Programming 3 2016-11-27 05:16
PHP vs. Python vs. C (all with GMP) daxmick Programming 2 2014-02-10 01:45
Python... Xyzzy Programming 20 2009-09-08 15:51
using libecm from python yqiang GMP-ECM 2 2007-04-22 00:14
Help w/ python. a216vcti Programming 7 2005-10-30 00:37

All times are UTC. The time now is 06:28.

Fri Sep 25 06:28:07 UTC 2020 up 15 days, 3:39, 0 users, load averages: 1.54, 1.26, 1.20

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

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.