mersenneforum.org  

Go Back   mersenneforum.org > Factoring Projects > YAFU

Reply
 
Thread Tools
Old 2011-02-17, 19:03   #562
Mr. Odd
 
Mar 2010

3×19 Posts
Default

Thanks for that! Any chance you can get the parallel ecm option for Windows machines?
Mr. Odd is offline   Reply With Quote
Old 2011-02-17, 19:09   #563
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

1101110000012 Posts
Default

Quote:
Originally Posted by Mr. Odd View Post
Thanks for that! Any chance you can get the parallel ecm option for Windows machines?
As of now, no. bchaffin used shared memory together with a function called fork() to get parallel ecm going. From what I understand, shared memory is possible to do in windows, but there just isn't a good (any?) way to emulate fork() on windows. The only alternative I can see is a completely different approach using external processes and parsing of log files, which is not an attractive option. So for the foreseeable future, it will remain linux only :(
bsquared is offline   Reply With Quote
Old 2011-02-17, 19:29   #564
bchaffin
 
Sep 2010
Portland, OR

22·3·31 Posts
Default

Quote:
Originally Posted by bsquared View Post
As of now, no. bchaffin used shared memory together with a function called fork() to get parallel ecm going. From what I understand, shared memory is possible to do in windows, but there just isn't a good (any?) way to emulate fork() on windows. The only alternative I can see is a completely different approach using external processes and parsing of log files, which is not an attractive option. So for the foreseeable future, it will remain linux only :(
Yes, I did a bunch of googling on this, but I don't really know much about Windows programming and it seems very difficult. fork() creates two copies of the process in its current state, including all data; the processes can then continue independently from the point where fork() was called, each updating their own copy of all program state. Windows has nothing like this. You can use threads, which share all program state, or you can launch a new process from the very beginning. So you would need a totally different approach on Windows, essentially equivalent to running multiple YAFUs from the command line and having them all automatically join together to collaborate.

Before I attempt that (if I ever do) I would look at gmp-ecm to see how hard it would be to give it a thread-safe library call. That's a pretty daunting task since it's a big code base which haven't looked at yet, but it's on my list.

In any event, multi-threaded ecm probably isn't coming to Windows any time soon. Sorry, I'd do it if I knew how.

One thought though: I read that Cygwin supports fork() on Windows (reportedly with some really ugly hacks). I haven't tried it, but if you could get YAFU to compile under Cygwin, it might work.
bchaffin is offline   Reply With Quote
Old 2011-02-17, 19:31   #565
lorgix
 
lorgix's Avatar
 
Sep 2010
Scandinavia

3·5·41 Posts
Default

Quote:
Originally Posted by Mr. Odd View Post
Thanks for that! Any chance you can get the parallel ecm option for Windows machines?
I actually asked for that before parallell ecm was in the Linux version. I'm very futuristic you see, I even wrote Isaac Asimov's autobiography before he was born (under a pseudonym).

Quote:
Originally Posted by bsquared View Post
As of now, no. bchaffin used shared memory together with a function called fork() to get parallel ecm going. From what I understand, shared memory is possible to do in windows, but there just isn't a good (any?) way to emulate fork() on windows. The only alternative I can see is a completely different approach using external processes and parsing of log files, which is not an attractive option. So for the foreseeable future, it will remain linux only :(
That's too bad. Also, there is no spoon so no help there... I'll just keep running several instances then.

Looking forward to the patch. Thanks Ben!
lorgix is offline   Reply With Quote
Old 2011-02-17, 19:42   #566
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

DC116 Posts
Default

Quote:
Originally Posted by bchaffin View Post

Before I attempt that (if I ever do) I would look at gmp-ecm to see how hard it would be to give it a thread-safe library call. That's a pretty daunting task since it's a big code base which haven't looked at yet, but it's on my list.
I started to look into this once. If I remember right, it seemed like the major problem came from a global repository of primes (or nextprimes). There may be other roadblocks too, but I remember that being one of them.

Quote:
Originally Posted by bchaffin View Post
In any event, multi-threaded ecm probably isn't coming to Windows any time soon. Sorry, I'd do it if I knew how.

One thought though: I read that Cygwin supports fork() on Windows (reportedly with some really ugly hacks). I haven't tried it, but if you could get YAFU to compile under Cygwin, it might work.
Yeah, maybe so. I didn't go the Cygwin route on purpose, of course, because it requires extra baggage (cygwin.dll) to run on windows. Does anyone know if it will build 64 bit binaries?
bsquared is offline   Reply With Quote
Old 2011-02-17, 20:07   #567
Brian Gladman
 
Brian Gladman's Avatar
 
May 2008
Worcester, United Kingdom

22·7·19 Posts
Default

Quote:
Originally Posted by bsquared View Post
I started to look into this once. If I remember right, it seemed like the major problem came from a global repository of primes (or nextprimes). There may be other roadblocks too, but I remember that being one of them.

Yeah, maybe so. I didn't go the Cygwin route on purpose, of course, because it requires extra baggage (cygwin.dll) to run on windows. Does anyone know if it will build 64 bit binaries?
What is wrong with using a portable library such as pthreads for this. I tend to use this rather than the Windows model since my code is then available to Linux users. I would hope that YAFU would adopt a similar strategy and not adopt a thread execution model that is not portable when, as far as I am aware, a suitable portable alternative exists.
Brian Gladman is offline   Reply With Quote
Old 2011-02-17, 20:16   #568
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

7×503 Posts
Default

Quote:
Originally Posted by Brian Gladman View Post
What is wrong with using a portable library such as pthreads for this. I tend to use this rather than the Windows model since my code is then available to Linux users. I would hope that YAFU would adopt a similar strategy and not adopt a thread execution model that is not portable when, as far as I am aware, a suitable portable alternative exists.
Maybe you know something I don't.... but I haven't been able to use pthreads or any other threading library to parallelize GMP-ECM because the threads stomp on each other's global storage. I.e, gmp-ecm is not inherently thread-safe. Am I missing knowledge of some capability of pthreads?
bsquared is offline   Reply With Quote
Old 2011-02-17, 20:33   #569
Brian Gladman
 
Brian Gladman's Avatar
 
May 2008
Worcester, United Kingdom

22·7·19 Posts
Default

Quote:
Originally Posted by bsquared View Post
Maybe you know something I don't.... but I haven't been able to use pthreads or any other threading library to parallelize GMP-ECM because the threads stomp on each other's global storage. I.e, gmp-ecm is not inherently thread-safe. Am I missing knowledge of some capability of pthreads?
No, Ben, I wasn't commenting on the specifics of your problem but on what appeared to be an introduction of a way of running something with multiple threads based only on the *nix model (fork etc.).

I don't know anything about the specifics of ECM thread safety (or lack of it) but I doubt that pthreads can magically introduce thread safety where there is none. How much global data is involved and is it well defined and well structured?
Brian Gladman is offline   Reply With Quote
Old 2011-02-17, 20:44   #570
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

7·503 Posts
Default

Quote:
Originally Posted by Brian Gladman View Post
No, Ben, I wasn't commenting on the specifics of your problem but on what appeared to be an introduction of a way of running something with multiple threads based only on the *nix model (fork etc.).
Ah, I see, sorry for misunderstanding. Yes, I generally do not like to use non-portable solutions either. This specific feature was generously contributed by bchaffin who strongly wanted support for parallel ECM, enough to write his own code to accomplish it. He obviously works primarily (entirely?) within linux. Since it was relatively easy to make his work invisible to windows builds, I saw no reason not to add it. But in general this doesn't represent a departure from the desire to maintain equivalent cross-platform functionality and performance.
Quote:
Originally Posted by Brian Gladman View Post
How much global data is involved and is it well defined and well structured?
That's the problem - I don't know for sure. I'm not familiar enough with the code and all my (brief) attempts to become so have ended in frustration, so far.
bsquared is offline   Reply With Quote
Old 2011-02-17, 21:47   #571
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

3×1,181 Posts
Default

You could ask the GMP-ECM mailing list, the maintainers are very responsive. Alex can comment too if he's reading :)

IIRC the global state for generating primes was supposed to be the only non-reentrant part of the library. You might be able to add a __thread keyword to the relevant data items and see if it still works.
jasonp is offline   Reply With Quote
Old 2011-02-18, 14:01   #572
bsquared
 
bsquared's Avatar
 
"Ben"
Feb 2007

352110 Posts
Default Patched 1.24 available

NFS should now be working again in the 1.24 download.

Cheers!
- b.
bsquared is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running YAFU via Aliqueit doesn't find yafu.ini EdH YAFU 8 2018-03-14 17:22
YAFU-1.34 bsquared YAFU 119 2015-11-05 16:24
Yafu bug. storflyt32 YAFU 2 2015-06-29 05:19
yafu-1.33 bsquared YAFU 12 2012-11-08 04:12
yafu-1.32.1 bsquared YAFU 21 2012-09-04 19:44

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


Fri Aug 6 05:34:32 UTC 2021 up 14 days, 3 mins, 1 user, load averages: 3.52, 3.04, 2.74

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.