mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > YAFU

Reply
 
Thread Tools
Old 2021-06-03, 05:55   #1
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

2·199 Posts
Default Stop yafu during ECM

When pressing ctrl-c during ECM under linux it only kills the current ECM instance, i.e. just the one curve, but keeps going otherwise.


I press ctrl-z and then kill -9 the process, but that's somewhat cumbersome. Is there another way?
bur is offline   Reply With Quote
Old 2021-06-03, 13:08   #2
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

2·1,789 Posts
Default

I just hold down ctrl-C until yafu actually sees one and quits. It may be annoying, but it's less annoying than me going back and re-thinking and re-implementing the signal-handling strategy for ecm/factor.
bsquared is offline   Reply With Quote
Old 2021-06-03, 17:51   #3
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

2·199 Posts
Default

Ok, thanks.
bur is offline   Reply With Quote
Old 2021-06-08, 11:56   #4
kruoli
 
kruoli's Avatar
 
"Oliver"
Sep 2017
Porta Westfalica, DE

12078 Posts
Default

Maybe you could use the return value of ecm if it is killed by ^C?

Code:
~$ ecm 1e9
GMP-ECM 7.0.4 [configured with GMP 6.2.0, --enable-asm-redc] [ECM]
2^1277-1
Input number is 2^1277-1 (385 digits)
Using B1=1000000000, B2=19071176724616, polynomial Dickson(30), sigma=0:8818687562867645865
^C
~$ echo $?
130
If the return value of ecm is 130, interrupt. Or print a message and wait at least a second or two for the user to hit ^C again. Just an idea.
kruoli is online now   Reply With Quote
Old 2021-06-08, 13:49   #5
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

DFA16 Posts
Default

Quote:
Originally Posted by kruoli View Post
Maybe you could use the return value of ecm if it is killed by ^C?

Code:
~$ ecm 1e9
GMP-ECM 7.0.4 [configured with GMP 6.2.0, --enable-asm-redc] [ECM]
2^1277-1
Input number is 2^1277-1 (385 digits)
Using B1=1000000000, B2=19071176724616, polynomial Dickson(30), sigma=0:8818687562867645865
^C
~$ echo $?
130
If the return value of ecm is 130, interrupt. Or print a message and wait at least a second or two for the user to hit ^C again. Just an idea.
Good idea, but I've tried that
Quote:
Originally Posted by yafu: ecm.c
// run system command
retcode = system(cmd);

free(tmpstr);
free(cmd);

// this is what I observed ecm returning on ctrl-c. hopefully it is portable.
if (retcode == 33280)
ECM_ABORT = 1;
But it's not portable... I've seen different numbers returned at different times on different systems.

Waiting for a second is a good idea also. Will have to consider that.
bsquared is offline   Reply With Quote
Old 2021-06-08, 13:59   #6
kruoli
 
kruoli's Avatar
 
"Oliver"
Sep 2017
Porta Westfalica, DE

647 Posts
Default

There might be a workaround for this. I'm interested in your opinion.

When starting YAFU, execute ecm and send it ^C programmatically and observe the resulting return code. Save it.

Another possibility would be to handle all return codes that are not defined by ecm itself (the manpage mentions only 0, 1, 2, 6, 8, 10 an 14) and are not handled otherwise as an abortion, because in this case, either the process was interrupted by the user or something else went horribly wrong.
kruoli is online now   Reply With Quote
Old 2021-06-08, 14:13   #7
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

357810 Posts
Default

Quote:
Originally Posted by kruoli View Post
There might be a workaround for this. I'm interested in your opinion.

When starting YAFU, execute ecm and send it ^C programmatically and observe the resulting return code. Save it.

Another possibility would be to handle all return codes that are not defined by ecm itself (the manpage mentions only 0, 1, 2, 6, 8, 10 an 14) and are not handled otherwise as an abortion, because in this case, either the process was interrupted by the user or something else went horribly wrong.
I appreciate the ideas!

I'm not super keen on handling specific return codes (after my first failed attempt) because they are subject to change and I don't want to have to keep tabs on them.

Saving the return code on a test run seems like it could be the best way to go. However, yafu already does a lot of stuff on initialization so I have to pay attention to what gets added to it. If a use case involves running yafu in a loop, e.g. in a 'foreach', the init cost can start to add up significantly.

Building on that thought would be to add the return code test to the "tune" command. Then it could get saved in the .ini file or something.
bsquared is offline   Reply With Quote
Old 2021-06-12, 02:14   #8
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

13668 Posts
Default

This Stack Overflow post on Unix process waits shows a possible elegant solution for Unix-like systems, but it's entirely unportable to Windows, as the latter doesn't have signals.
Happy5214 is offline   Reply With Quote
Old 2021-06-15, 08:42   #9
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

2·199 Posts
Default

Quote:
I just hold down ctrl-C until yafu actually sees one and quits.
On my system yafu won't even quit when switching to new B1/B2 values, i.e. when it reached the NFS stage. Maybe it'd be possible to catch the Ctrl-C and exit when yafu switches to the next B1 value?

But if it's too much hassle, forget about it, Ctrl-Z and kill works after all.

Last fiddled with by bur on 2021-06-15 at 08:44
bur is offline   Reply With Quote
Old 2021-06-15, 10:42   #10
Happy5214
 
Happy5214's Avatar
 
"Alexander"
Nov 2008
The Alamo City

2F616 Posts
Default

I've attached an old script I used to use to control aliqueit, which in my configuration called yafu inside. It used a Unix FIFO (named pipe) and the echo shell command to do process and command control. I don't know how much use it'll be to you in its current form, but if you're looking for a script that can control yafu or aliqueit (and even stop them in progress and resume from that point), you can reply here or hit me up via PM.
Attached Files
File Type: txt main.pl.txt (2.0 KB, 39 views)
Happy5214 is offline   Reply With Quote
Old 2021-08-04, 09:16   #11
bur
 
bur's Avatar
 
Aug 2020
79*6581e-4;3*2539e-3

6168 Posts
Default

Thanks, when I have some time I'll gladly look into it. I wanted to get into scripting for a while. Mostly to do ECM via yafu and switch to CADO for NFS.
bur is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
yafu ignoring yafu.ini chris2be8 YAFU 6 2019-10-17 16:22
Running YAFU via Aliqueit doesn't find yafu.ini EdH YAFU 8 2018-03-14 17:22
When will it stop? ThomRuley Msieve 20 2010-05-19 02:12
Should we stop at k=249? jocelynl 15k Search 2 2004-07-10 13:31
RMA - stop LLR bug paulunderwood 3*2^n-1 Search 8 2004-05-19 07:10

All times are UTC. The time now is 22:31.


Sun Oct 17 22:31:46 UTC 2021 up 86 days, 17 hrs, 0 users, load averages: 1.03, 1.68, 2.18

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, 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.