[Numpy-discussion] Fixes to Numexpr under 64 bit platforms

Ivan Vilata i Balaguer ivilata at carabos.com
Tue Dec 26 03:00:19 CST 2006


Hi all, here you have a patch that fixes some type declaration bugs
which cause Numexpr to crash under 64 bit platforms.  All of them are
confusions between the ``int`` and ``intp`` types, which happen to be
the same under 32 bit platforms but not under 64 bit ones, which caused
garbage values to be used as shapes and strides.

The errors where easy to spot by looking at the warnings yielded by the
compiler.  Changes have been tested under a Dual Core AMD Opteron 270
running SuSE 10.0 X86-64 with Python 2.4 and 2.5.

Have nice holidays,

::

	Ivan Vilata i Balaguer   >qo<   http://www.carabos.com/
	       Cárabos Coop. V.  V  V   Enjoy Data
	                          ""
-------------- next part --------------
Index: interpreter.c
===================================================================
--- interpreter.c	(revision 2465)
+++ interpreter.c	(working copy)
@@ -704,7 +704,7 @@
     rawmemsize = BLOCK_SIZE1 * (size_from_sig(constsig) + size_from_sig(tempsig));
     mem = PyMem_New(char *, 1 + n_inputs + n_constants + n_temps);
     rawmem = PyMem_New(char, rawmemsize);
-    memsteps = PyMem_New(int, 1 + n_inputs + n_constants + n_temps);
+    memsteps = PyMem_New(intp, 1 + n_inputs + n_constants + n_temps);
     if (!mem || !rawmem || !memsteps) {
         Py_DECREF(constants);
         Py_DECREF(constsig);
@@ -822,8 +822,8 @@
     int count;
     int size;
     int findex;
-    int *shape;
-    int *strides;
+    intp *shape;
+    intp *strides;
     int *index;
     char *buffer;
 };
@@ -956,7 +956,7 @@
     PyObject *output = NULL, *a_inputs = NULL;
     struct index_data *inddata = NULL;
     unsigned int n_inputs, n_dimensions = 0;
-    int shape[MAX_DIMS];
+    intp shape[MAX_DIMS];
     int i, j, size, r, pc_error;
     char **inputs = NULL;
     intp strides[MAX_DIMS]; /* clean up XXX */
@@ -1032,7 +1032,7 @@
     for (i = 0; i < n_inputs; i++) {
         PyObject *a = PyTuple_GET_ITEM(a_inputs, i);
         PyObject *b;
-        int strides[MAX_DIMS];
+        intp strides[MAX_DIMS];
         int delta = n_dimensions - PyArray_NDIM(a);
         if (PyArray_NDIM(a)) {
             for (j = 0; j < n_dimensions; j++)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 309 bytes
Desc: Digital signature
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061226/1a965d62/attachment.bin 


More information about the Numpy-discussion mailing list