This is my first attempt at using IPython.parallel
so please bear with me.
I read this question Parfor for Python and am having trouble implementing a simple example as follows:
import gmpy2 as gm
import numpy as np
from IPython.parallel import Client
rc = Client()
lview = rc.load_balanced_view()
lview.block = True
a = 1
def L2(ii,jj):
out = []
out.append(gm.fac(ii+jj+a))
return out
Nloop = 100
ii = range(Nloop)
jj = range(Nloop)
R2 = lview.map(L2, zip(ii, jj))
The problems I have are:
a
is defined outside the loop and I think I need to do something like "push" but am a bit confused by that. Do I need to "pull" after?- there are two arguments that are required for the function and I don't know how to pass them correctly. I tried things like
zip(ii,jj)
but got some errors. - Also,, I assume the fact that I'm using a random library
gmpy2
shouldn't affect things. Is this correct? Do I need to do anything special for this?
Ideally I would like your help so on this simple example the code runs error free.
If you think it would be beneficial to post my failed attempts at #2 let me know. I'm in the dark with #1.