uqfoundation / pathos

parallel graph management and execution in heterogeneous computing
http://pathos.rtfd.io
Other
1.36k stars 91 forks source link

it is possible to use pathos with gmpy2 ? #279

Open christopher52 opened 7 months ago

christopher52 commented 7 months ago

HELLO ! I'm writting a program that works without pathos but it uses 1 processor / 16. I found a prime number with 40000 digits but it takes 1 week to get the result (only 1 processor) My goal is to find faster very large prime numbers with rounding floats (more than 40000 digits) thanks pathos and gmpy2 in order to get prime integers.

At the beginning of my program : import gmpy2 from gmpy2 import mpz, mpfr, is_prime import sys sys.set_int_max_str_digits(0) import ppft

LOCAL_WORKERS = 'autodetect' #XXX: 'autodetect' or 0,1,2,... print("Known servers: [('local',)] %s" % (job_server.ppservers)) result : 16 processors

n_list = [ ] while n < 9999999: if is_prime(n): n_list.append(n) if len(n_list) > 1: resultat = MyEquation inputs = (resultat) jobs = [(input, job_server.submit(is_prime, (input, ), (newprimes, ), ("math", ))) for input in inputs] for input, job in jobs: print(MyEquation) ("is_prime" is a function imported already written by gmpy2) ("newprimes" is a function I wrote using mpfr and mpz from gmpy2 for calcul) ("resultat" and "myEquation" are variable as result from using calcul with mpz and mpfr)

But I get these errors : TypeError: 'mpfr' object is not iterable TypeError: 'mpz' object is not iterable

your help would be much appreciated! Thanks, Christophe

mmckerns commented 7 months ago

Most likely the answer is yes, you can use gmpy2 with pathos. It's hard to tell what is going on, because you don't provide details that would allow me to try it. From the error, it would seem that you aren't meeting the submit function requirements for how to perform a parallel map (i.e. mpfr seems to need to be passed as a list) -- its hard to tell from the lack of details. I'd need to see a minimal example that reproduces what you are seeing... both the code and the traceback.

christopher52 commented 7 months ago

Thank you very much ! You are right : I'm not sure to have the submit function requirements for how to perform a parallel map . I will come back after some research...