[SciPy-dev] weave and 64-bit platforms

Fernando Perez fperez.net at gmail.com
Thu Jun 22 17:02:50 CDT 2006


Hi all,

the following little script

planck[~]> cat weavebug.py
#!/usr/bin/env python
import numpy as N
from scipy.weave import inline

vec = N.rand(100)

code = """
double sum = 0.0;
int npts = Nvec[0];
for (int i=0;i<npts;++i) {
    sum += vec[i];
}
return_val = sum;
"""

print inline(code,['vec'])
print vec.sum()

# EOF

works just fine on my 32-bit desktop, but is failing on a 64-bit install with:

[mjm at infinite private]$ python weavebug.py
<weave: compiling>
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:
In function `PyObject* compiled_func(PyObject*, PyObject*)':
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:662:
error: cannot convert `intp*' to `int*' in initialization
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:663:
error: cannot convert `intp*' to `int*' in initialization
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:
In function `PyObject* compiled_func(PyObject*, PyObject*)':
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:662:
error: cannot convert `intp*' to `int*' in initialization
/home/mjm/.python23_compiled/sc_117c9bd1cecd5efd70827f0f4991867b1.cpp:663:
error: cannot convert `intp*' to `int*' in initialization

the relevant python numbers are:

Python 2.3.4 (#1, Feb  2 2005, 11:44:13)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
   >>> import numpy
   >>> from scipy import weave
   >>> numpy.__version__
'0.9.9.2635'
   >>> weave.__version__
'0.4.9'
   >>> import scipy
   >>> scipy.__version__
'0.5.0.1982'


Now, looking at the generated cpp files shows stuff like:

           /* argument conversion code */
           py_vec = get_variable("vec",raw_locals,raw_globals);
           PyArrayObject* vec_array = convert_to_numpy(py_vec,"vec");
           conversion_numpy_check_type(vec_array,PyArray_DOUBLE,"vec");
           int* Nvec = vec_array->dimensions;
           int* Svec = vec_array->strides;

and those last two lines are probably not kosher on a 64-bit system.

Is anyone comfortable enough with 64-bit issues to know how to fix this one?
Unfortunately the problem is happening on a collaborator's machine to which I
don't have direct access, so it's not easy for me to test anything if I make
changes to the source.  And given that I'm not very experienced with how numpy
handles 64-bit cleanness, I'm really afraid I'd break something if I tried.

If nobody can tackle this one, but is at least willing to provide some
pointers, I'd be very grateful.  It's critical enough for me that I'll fix it
myself if need be.

Cheers,

f




More information about the Scipy-dev mailing list