Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it is possible to use pathos with gmpy2 ? #279

Open
christopher52 opened this issue Nov 30, 2023 · 2 comments
Open

it is possible to use pathos with gmpy2 ? #279

christopher52 opened this issue Nov 30, 2023 · 2 comments

Comments

@christopher52
Copy link

christopher52 commented Nov 30, 2023

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
Copy link
Member

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
Copy link
Author

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants