mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   YAFU (https://www.mersenneforum.org/forumdisplay.php?f=96)
-   -   Stop yafu during ECM (https://www.mersenneforum.org/showthread.php?t=26870)

bur 2021-06-03 05:55

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?

bsquared 2021-06-03 13:08

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.

bur 2021-06-03 17:51

Ok, thanks.

kruoli 2021-06-08 11:56

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

[CODE][B]~$[/B] 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
[B]~$[/B] echo $?
130[/CODE]

If the return value of [C]ecm[/C] 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.

bsquared 2021-06-08 13:49

[QUOTE=kruoli;580327]Maybe you could use the return value of [C]ecm[/C] if it is killed by ^C?

[CODE][B]~$[/B] 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
[B]~$[/B] echo $?
130[/CODE]

If the return value of [C]ecm[/C] 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.[/QUOTE]

Good idea, but I've tried that :smile:
[QUOTE=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;[/QUOTE]

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.

kruoli 2021-06-08 13:59

There [I]might[/I] be a workaround for this. :smile: I'm interested in your opinion.

When starting YAFU, execute [C]ecm[/C] 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 [C]ecm[/C] 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.

bsquared 2021-06-08 14:13

[QUOTE=kruoli;580342]There [I]might[/I] be a workaround for this. :smile: I'm interested in your opinion.

When starting YAFU, execute [C]ecm[/C] 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 [C]ecm[/C] 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.[/QUOTE]

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.

Happy5214 2021-06-12 02:14

[URL="https://stackoverflow.com/questions/58745646/is-there-any-way-to-figure-out-that-child-process-was-killed-with-sigkill-by-the"]This Stack Overflow post on Unix process waits[/URL] shows a possible elegant solution for Unix-like systems, but it's entirely unportable to Windows, as the latter doesn't have signals.

bur 2021-06-15 08:42

[QUOTE]I just hold down ctrl-C until yafu actually sees one and quits.[/QUOTE]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.

Happy5214 2021-06-15 10:42

1 Attachment(s)
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.

bur 2021-08-04 09:16

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.


All times are UTC. The time now is 00:34.

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