[SciPy-user] openmp and weave?

william ratcliff william.ratcliff@gmail....
Wed Nov 7 16:55:32 CST 2007


Has anyone had any luck using weave with openMP?  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


More information about the SciPy-user mailing list