![]() |
![]() |
#1 |
Jul 2003
So Cal
1000001000102 Posts |
![]()
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<nt;i++) { //printf("Thread: %d\n",i); ress[i] = ecm_factor(ps[i], ns[i], B1, NULL); } Thanks, Greg |
![]() |
![]() |
![]() |
#2 |
Tribal Bullet
Oct 2004
24·13·17 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?
|
![]() |
![]() |
![]() |
#3 | ||
Jul 2003
So Cal
2·3·347 Posts |
![]() Quote:
Quote:
Greg |
||
![]() |
![]() |
![]() |
#4 |
(loop (#_fork))
Feb 2006
Cambridge, England
13×491 Posts |
![]()
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.
|
![]() |
![]() |
![]() |
#5 |
Tribal Bullet
Oct 2004
24·13·17 Posts |
![]()
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.
|
![]() |
![]() |
![]() |
#6 |
"Nancy"
Aug 2002
Alexandria
2,467 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 |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
SAFE MODE.... | petrw1 | Hardware | 14 | 2009-03-25 13:17 |
using libecm from python | yqiang | GMP-ECM | 2 | 2007-04-22 00:14 |
Can't bind libecm.a with C++ files | poire | GMP-ECM | 2 | 2006-03-21 14:41 |
Safe Mode | Unregistered | Software | 12 | 2004-07-16 01:06 |
Safe Mode | JuanTutors | Hardware | 6 | 2004-06-24 10:15 |