[SciPy-user] openmp and weave?

Daniel Wheeler daniel.wheeler2 at gmail.com
Mon Apr 7 14:23:17 EDT 2008


On Wed, Nov 7, 2007 at 6:55 PM, william ratcliff
<william.ratcliff at gmail.com> wrote:
 > Has anyone had any luck using weave with openMP?

Yes. I have been trying a test case and getting reasonable speed ups.
You'll need gcc version 4.3, 4.2 doesn't seem to work. I have recorded
some of the results on the pages below. Be warned, I am inexperienced
in parallel computing so there is a chance of gross errors in my
thinking and coding.

   <https://www.matforge.org/msel/wiki/2008/04/04/16.48>
   <https://www.matforge.org/msel/wiki/2008/03/24/15.37>
   <https://www.matforge.org/msel/wiki/2008/03/20/15.46>

The following is the test code for the above results.

   <https://www.matforge.org/msel/wiki/2008/04/07/13.24>

Note that there is no need to recompile everything with 4.3, only
weave. Getting 4.3 built was a little involved. The links above
provide some rudimentary instructions.

The above results are for a machine with 2 and another with 8 nodes. I
have also been evaluating openmp on a 64 node Altix machine. There are
 a number of issues with building scipy and numpy that have been
resolved mostly concerning the SGI's scientific library, but I am
currently having issues with getting weave to compile on the Altix.
This seems to be due to having all the python stuff compiled with gcc,
but using the Intel compiler for weave.

Cheers



 > If so, what did you
 >  have to do?  I've started by updating my compiler to MinGW:
 >  gcc-4.2.1-dw-2-2 (and similarly for g++), but am running into problems
 >  with code written in weave that doesn't use any of openmp:
 >
 >  Here is the code:
 >
 >  import numpy as N
 >  import weave
 >  from weave import converters
 >
 >
 >
 >  def blitz_interpolate(x,y):
 >
 >
 >     code = """
 >     int pts = Ny[0];
 >  //#pragma omp parallel for
 >     for (int i=0; i < pts-1; i++){
 >         y(i) = sin( exp( cos( - exp( sin(x(i)) ) ) ) );
 >      }
 >     return_val = 3;
 >     """
 >     extra=["-fopenmp -Lc:/python25/ -lPthreadGC2"]
 >     extra=[]
 >     z=weave.inline(code,['x','y'],type_converters=converters.blitz,compiler='gcc')
 >     print z
 >     return
 >
 >
 >
 >
 >
 >  if __name__=="__main__":
 >     x=N.arange(1000)
 >     y=N.zeros(x.shape,'d')
 >     blitz_interpolate(x,y)
 >     print x[35], y[35],N.sin(N.exp(N.cos(-N.exp(N.sin(x[35])))))
 >
 >
 >
 >
 >
 >  This works fine with version 3.4.2 of gcc, g++
 >
 >  Thanks,
 >  William
 >  _______________________________________________
 >  SciPy-user mailing list
 >  SciPy-user at scipy.org
 >  http://projects.scipy.org/mailman/listinfo/scipy-user
 >


-- 
Daniel Wheeler



More information about the SciPy-User mailing list