[SciPy-dev] weave and 64-bit platforms

Robert Kern robert.kern at gmail.com
Thu Jun 22 18:08:32 EDT 2006


Fernando Perez wrote:
> 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.

That segment of code is in standard_array_spec.py . I think those int*s should 
be intp*s. I think I made that modification in my checkout copy, but I never 
tested it on 32-bit so I didn't check it in.

If you can provide an example for me to try without thinking, I'll test it on my 
machine with that change and you test it on your 32-bit machine.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the SciPy-Dev mailing list