Register FAQ Search Today's Posts Mark Forums Read

 2009-02-27, 23:34 #1 frmky     Jul 2003 So Cal 32×233 Posts Is libecm thread-safe? I'm trying to extend Paul Zimmermann's aliq2.c from http://www.loria.fr/~zimmerma/records/aliquot.html to run the ECM on multiple threads. I've done this: Code: `#pragma omp parallel for for (i=0;i
 2009-02-28, 03:20 #2 jasonp Tribal Bullet     Oct 2004 2·29·61 Posts Are you sure OpenMP spawn multiple threads, so that each function call gets its own stack? Maybe you also need an array of ecm_params entries, initialized before running the loop in parallel?
2009-02-28, 03:24   #3
frmky

Jul 2003
So Cal

32×233 Posts

Quote:
 Originally Posted by jasonp Are you sure OpenMP spawn multiple threads, so that each function call gets its own stack?

Quote:
 Originally Posted by jasonp Maybe you also need an array of ecm_params entries, initialized before running the loop in parallel?
I'll figure out how to do that in a few days. I also sometime plan to see if I can figure out how to use libmsieve as well.

Greg

2009-02-28, 07:10   #4
fivemack
(loop (#_fork))

Feb 2006
Cambridge, England

24·3·7·19 Posts

Quote:
 Originally Posted by frmky Is ecm_factor() not thread-safe? If not, would it be difficult to make it so?
It is not thread-safe - there is a single global prime-generating object which is not protected by locks (so your multiple-frees come when thread 1 has deleted the sieving array while thread 2 is trying to read from it), and if you add locks you get the obvious problem that thread 1 picks up some primes and thread 2 others when computing the first product of primes. I'm not sure how fiddly it is to fix, but fiddlier than I'd first thought.

2009-02-28, 14:57   #5
jasonp
Tribal Bullet

Oct 2004

2·29·61 Posts

Quote:
 Originally Posted by frmky I'll figure out how to do that in a few days. I also sometime plan to see if I can figure out how to use libmsieve as well.
libmsieve should be completely thread safe, if you write to different log files and data files with each instance. The library has no writeable globals.

 2009-02-28, 16:08 #6 akruppa     "Nancy" Aug 2002 Alexandria 1001101000112 Posts Most of GMP-ECM has been written without thread-safeness (or indeed a library) in mind, so I'm not surprised it isn't... the prime sieve's state in static variables is obviously a problem, but I think there are some other static variables, too. (Never mind the brilliant idea of putting temp space in the mpmod struct, or mixing mpz/mpmod for temp data... half of the code should be rewritten from scratch. ) Alex

 Similar Threads Thread Thread Starter Forum Replies Last Post petrw1 Hardware 14 2009-03-25 13:17 yqiang GMP-ECM 2 2007-04-22 00:14 poire GMP-ECM 2 2006-03-21 14:41 Unregistered Software 12 2004-07-16 01:06 JuanTutors Hardware 6 2004-06-24 10:15

All times are UTC. The time now is 23:13.

Mon May 17 23:13:40 UTC 2021 up 39 days, 17:54, 0 users, load averages: 2.78, 2.36, 2.38