[Numpy-discussion] Numerical Python and LAPACK on 64-bit machines

Roman Geus geus at inf.ethz.ch
Wed Mar 6 00:51:10 CST 2002


Dear Numerical Python user and developers

I ran into the following problem:

The python application I'm developing uses Numerical Python and other
C modules that call LAPACK. My application runs well on 32bit
architectures:

When I tried to run the application on a HP-UX 64bit machine the
application produced bus errors. After a long debugging session I
found out that Fortran integers are still 32bit wide on this
machine. Therefore also the HP LAPACK library has to called using
32bit integers. Numerical Python however codes Fortran integers as C
'long int' variables, which are 64bit wide on this machine.

To make my application run on the HP-UX 64bit machine, I had to change
all 'long int' to 'int' variables in Src/lapack_litemodule.c, which
is a rather painful hack (see end of message for an example).

My question is: 

Should Fortran integers not be coded as 'int' instead of 'long int' in
Numerical Python? This way, it would still work on all 32 bit machines
and also on the 64-bit machines I know.

Would this work on all 64-bit machines?

Thanks for your comments/help.

-- Roman Geus



E.g. the lapack_lite_dgetrf() function now looks like this:


static PyObject *lapack_lite_dgetrf(PyObject *self, PyObject *args)
{
int  lapack_lite_status__;
int m;
int n;
PyObject *a;
int lda;
PyObject *ipiv;
int info;

 int i; 
 int *ipiv_int;
 int ipiv_len;

TRY(PyArg_ParseTuple(args,"iiOiOi",&m,&n,&a,&lda,&ipiv,&info));

TRY(lapack_lite_CheckObject(a,PyArray_DOUBLE,"a","PyArray_DOUBLE","dgetrf")); 
TRY(lapack_lite_CheckObject(ipiv,PyArray_LONG,"ipiv","PyArray_LONG","dgetrf"));  
 ipiv_len = m < n ? m : n;
 ipiv_int = (int *)malloc(ipiv_len * sizeof(int));
 assert(ipiv_int);
 for (i = 0; i < ipiv_len; i ++)
   ipiv_int[i] = LDATA(ipiv)[i];

#if defined(NO_APPEND_FORTRAN)
lapack_lite_status__ = dgetrf(&m,&n,DDATA(a),&lda,ipiv_int,&info);
#else
lapack_lite_status__ = dgetrf_(&m,&n,DDATA(a),&lda,ipiv_int,&info);
#endif

 for (i = 0; i < ipiv_len; i ++)
   LDATA(ipiv)[i] = ipiv_int[i];

 free(ipiv);

return
Py_BuildValue("{s:l,s:l,s:l,s:l,s:l}","dgetrf_",(long)lapack_lite_status__,"m",(long)m,"n",(long)n,"lda",(long)lda,"info",(long)info);
}




More information about the Numpy-discussion mailing list