@@ -10,8 +10,8 @@ from cpython cimport Py_INCREF, PyNumber_Index
1010from cpython.object cimport Py_EQ, Py_NE
1111
1212def api_version ():
13- # Those where the last defined numbers.
14- return (- 9997 , 1 , 0 )
13+ # (library version, module version)
14+ return (GPUARRAY_API_VERSION , 0 )
1515
1616np.import_array()
1717
@@ -235,7 +235,7 @@ cdef int strides_ok(GpuArray a, strides):
235235 return 0
236236 upper += max_axis_offset
237237 else :
238- if lower < - max_axis_offset:
238+ if lower < < size_t > ( - max_axis_offset) :
239239 return 0
240240 lower += max_axis_offset
241241 return (upper + itemsize) <= size
@@ -874,7 +874,7 @@ def from_gpudata(size_t data, offset, dtype, shape, GpuContext context=None,
874874 free(cdims)
875875 free(cstrides)
876876
877- def array (proto , dtype = None , copy = True , order = None , int ndmin = 0 ,
877+ def array (proto , dtype = None , copy = True , order = None , unsigned int ndmin = 0 ,
878878 GpuContext context = None , cls = None ):
879879 """
880880 array(obj, dtype='float64', copy=True, order=None, ndmin=0, context=None, cls=None)
@@ -890,7 +890,7 @@ def array(proto, dtype=None, copy=True, order=None, int ndmin=0,
890890 :param order: memory layout of the result
891891 :type order: string
892892 :param ndmin: minimum number of result dimensions
893- :type ndmin: int
893+ :type ndmin: unsigned int
894894 :param context: allocation context
895895 :type context: GpuContext
896896 :param cls: result class (must inherit from GpuArray)
@@ -1146,6 +1146,13 @@ cdef class GpuContext:
11461146 ctx_property(self , GA_CTX_PROP_MAXGSIZE2, & res)
11471147 return res
11481148
1149+ property largest_memblock :
1150+ " Size of the largest memory block you can allocate"
1151+ def __get__ (self ):
1152+ cdef size_t res
1153+ ctx_property(self , GA_CTX_PROP_LARGEST_MEMBLOCK, & res)
1154+ return res
1155+
11491156
11501157cdef class flags(object ):
11511158 cdef int fl
@@ -1377,21 +1384,24 @@ cdef GpuArray pygpu_reshape(GpuArray a, unsigned int nd, const size_t *newdims,
13771384 if compute_axis < 0 :
13781385 array_reshape(res, a, nd, newdims, ord , nocopy)
13791386 return res
1380- if compute_axis >= nd:
1387+ cdef unsigned int caxis = < unsigned int > compute_axis
1388+ if caxis >= nd:
13811389 raise ValueError (" You wanted us to compute the shape of a dimensions that don't exist" )
13821390
13831391 cdef size_t * cdims
13841392 cdef size_t tot = 1
1393+ cdef unsigned int i
13851394 for i in range (nd):
1386- if i != compute_axis :
1395+ if i != caxis :
13871396 tot *= newdims[i]
13881397 cdims = < size_t * > calloc(nd, sizeof(size_t))
13891398 if cdims == NULL :
13901399 raise MemoryError , " could not allocate cdims"
13911400
1401+ cdef size_t d
13921402 for i in range (nd):
13931403 d = newdims[i]
1394- if i == compute_axis :
1404+ if i == caxis :
13951405 d = a.size // tot
13961406
13971407 if d * tot != a.size:
@@ -1530,7 +1540,7 @@ cdef class GpuArray:
15301540 k = PyNumber_Index(key)
15311541 if k < 0 :
15321542 k += self .ga.dimensions[i]
1533- if k < 0 or k >= self .ga.dimensions[i]:
1543+ if k < 0 or ( < size_t > k) >= self .ga.dimensions[i]:
15341544 raise IndexError , " index %d out of bounds" % (i,)
15351545 start[0 ] = k
15361546 step[0 ] = 0
@@ -1539,9 +1549,7 @@ cdef class GpuArray:
15391549 pass
15401550
15411551 if isinstance (key, slice ):
1542- # C compiler complains about argument 1 (key) because it's
1543- # declared as a PyObject. But we know it's a slice so it's ok.
1544- PySlice_GetIndicesEx(< slice_object> key, self .ga.dimensions[i],
1552+ PySlice_GetIndicesEx(key, self .ga.dimensions[i],
15451553 start, stop, step, & dummy)
15461554 if stop[0 ] < start[0 ] and step[0 ] > 0 :
15471555 stop[0 ] = start[0 ]
0 commit comments